提交 21ac1cf7 编写于 作者: Q qiang

chore: build mp-kuaishou

上级 205ca818
......@@ -192,7 +192,7 @@ function queue (hooks, data) {
}
if (res === false) {
return {
then () {}
then () { }
}
}
}
......@@ -240,15 +240,15 @@ function getApiInterceptorHooks (method) {
if (hook !== 'returnValue') {
interceptor[hook] = globalInterceptors[hook].slice();
}
});
const scopedInterceptor = scopedInterceptors[method];
if (scopedInterceptor) {
Object.keys(scopedInterceptor).forEach(hook => {
if (hook !== 'returnValue') {
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
}
});
}
});
const scopedInterceptor = scopedInterceptors[method];
if (scopedInterceptor) {
Object.keys(scopedInterceptor).forEach(hook => {
if (hook !== 'returnValue') {
interceptor[hook] = (interceptor[hook] || []).concat(scopedInterceptor[hook]);
}
});
}
return interceptor
}
......@@ -272,10 +272,14 @@ const promiseInterceptor = {
if (!isPromise(res)) {
return res
}
return res.then(res => {
return res[1]
}).catch(res => {
return res[0]
return new Promise((resolve, reject) => {
res.then(res => {
if (res[0]) {
reject(res[0]);
} else {
resolve(res[1]);
}
});
})
}
};
......@@ -1803,8 +1807,59 @@ function parseComponent (vueComponentOptions) {
})
}
/**
* 用于延迟调用 setData
* 在 setData 真实调用的时机需执行 fixSetDataEnd
* @param {*} mpInstance
*/
function fixSetDataStart (mpInstance) {
const setData = mpInstance.setData;
const setDataArgs = [];
mpInstance.setData = function () {
setDataArgs.push(arguments);
};
mpInstance.__fixInitData = function () {
this.setData = setData;
const fn = () => {
setDataArgs.forEach(args => {
setData.apply(this, args);
});
};
if (setDataArgs.length) {
if (this.groupSetData) {
this.groupSetData(fn);
} else {
fn();
}
}
};
}
/**
* 恢复真实的 setData 方法
* @param {*} mpInstance
*/
function fixSetDataEnd (mpInstance) {
if (mpInstance.__fixInitData) {
mpInstance.__fixInitData();
delete mpInstance.__fixInitData;
}
}
function parseComponent$1 (vueComponentOptions) {
return parseComponent(vueComponentOptions)
const componentOptions = parseComponent(vueComponentOptions);
const oldAttached = componentOptions.lifetimes.attached;
componentOptions.lifetimes.attached = function attached () {
// 暂不区分版本
if (isPage.call(this)) {
// 解决快手小程序页面 attached 生命周期 setData 导致数据同步异常的问题
fixSetDataStart(this);
setTimeout(() => {
fixSetDataEnd(this);
}, 0);
}
oldAttached.call(this);
};
return componentOptions
}
const hooks$1 = [
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册