提交 1fc563c1 编写于 作者: Q qiang

chore: build

上级 105993af
...@@ -21444,11 +21444,12 @@ var serviceContext = (function () { ...@@ -21444,11 +21444,12 @@ var serviceContext = (function () {
const hasSuccess = isFn(success); const hasSuccess = isFn(success);
const hasFail = isFn(fail); const hasFail = isFn(fail);
const hasComplete = isFn(complete); const hasComplete = isFn(complete);
Promise.resolve().then(() => { Promise.resolve().then(() => {
if (typeof enabled === 'undefined') { if (typeof enabled === 'undefined') {
enabled = false; enabled = false;
cid = ''; cid = '';
cidErrMsg = 'unipush is not enabled'; cidErrMsg = 'uniPush is not enabled';
} }
getPushCidCallbacks.push((cid, errMsg) => { getPushCidCallbacks.push((cid, errMsg) => {
let res; let res;
......
此差异已折叠。
...@@ -1776,11 +1776,12 @@ function getPushClientId (args) { ...@@ -1776,11 +1776,12 @@ function getPushClientId (args) {
const hasSuccess = isFn(success); const hasSuccess = isFn(success);
const hasFail = isFn(fail); const hasFail = isFn(fail);
const hasComplete = isFn(complete); const hasComplete = isFn(complete);
Promise.resolve().then(() => { Promise.resolve().then(() => {
if (typeof enabled === 'undefined') { if (typeof enabled === 'undefined') {
enabled = false; enabled = false;
cid = ''; cid = '';
cidErrMsg = 'unipush is not enabled'; cidErrMsg = 'uniPush is not enabled';
} }
getPushCidCallbacks.push((cid, errMsg) => { getPushCidCallbacks.push((cid, errMsg) => {
let res; let res;
......
...@@ -1424,11 +1424,12 @@ function getPushClientId (args) { ...@@ -1424,11 +1424,12 @@ function getPushClientId (args) {
const hasSuccess = isFn(success); const hasSuccess = isFn(success);
const hasFail = isFn(fail); const hasFail = isFn(fail);
const hasComplete = isFn(complete); const hasComplete = isFn(complete);
Promise.resolve().then(() => { Promise.resolve().then(() => {
if (typeof enabled === 'undefined') { if (typeof enabled === 'undefined') {
enabled = false; enabled = false;
cid = ''; cid = '';
cidErrMsg = 'unipush is not enabled'; cidErrMsg = 'uniPush is not enabled';
} }
getPushCidCallbacks.push((cid, errMsg) => { getPushCidCallbacks.push((cid, errMsg) => {
let res; let res;
......
...@@ -1061,11 +1061,12 @@ function getPushClientId (args) { ...@@ -1061,11 +1061,12 @@ function getPushClientId (args) {
const hasSuccess = isFn(success); const hasSuccess = isFn(success);
const hasFail = isFn(fail); const hasFail = isFn(fail);
const hasComplete = isFn(complete); const hasComplete = isFn(complete);
Promise.resolve().then(() => { Promise.resolve().then(() => {
if (typeof enabled === 'undefined') { if (typeof enabled === 'undefined') {
enabled = false; enabled = false;
cid = ''; cid = '';
cidErrMsg = 'unipush is not enabled'; cidErrMsg = 'uniPush is not enabled';
} }
getPushCidCallbacks.push((cid, errMsg) => { getPushCidCallbacks.push((cid, errMsg) => {
let res; let res;
......
...@@ -1229,11 +1229,12 @@ function getPushClientId (args) { ...@@ -1229,11 +1229,12 @@ function getPushClientId (args) {
const hasSuccess = isFn(success); const hasSuccess = isFn(success);
const hasFail = isFn(fail); const hasFail = isFn(fail);
const hasComplete = isFn(complete); const hasComplete = isFn(complete);
Promise.resolve().then(() => { Promise.resolve().then(() => {
if (typeof enabled === 'undefined') { if (typeof enabled === 'undefined') {
enabled = false; enabled = false;
cid = ''; cid = '';
cidErrMsg = 'unipush is not enabled'; cidErrMsg = 'uniPush is not enabled';
} }
getPushCidCallbacks.push((cid, errMsg) => { getPushCidCallbacks.push((cid, errMsg) => {
let res; let res;
......
...@@ -1279,11 +1279,12 @@ function getPushClientId (args) { ...@@ -1279,11 +1279,12 @@ function getPushClientId (args) {
const hasSuccess = isFn(success); const hasSuccess = isFn(success);
const hasFail = isFn(fail); const hasFail = isFn(fail);
const hasComplete = isFn(complete); const hasComplete = isFn(complete);
Promise.resolve().then(() => { Promise.resolve().then(() => {
if (typeof enabled === 'undefined') { if (typeof enabled === 'undefined') {
enabled = false; enabled = false;
cid = ''; cid = '';
cidErrMsg = 'unipush is not enabled'; cidErrMsg = 'uniPush is not enabled';
} }
getPushCidCallbacks.push((cid, errMsg) => { getPushCidCallbacks.push((cid, errMsg) => {
let res; let res;
......
...@@ -1389,11 +1389,12 @@ function getPushClientId (args) { ...@@ -1389,11 +1389,12 @@ function getPushClientId (args) {
const hasSuccess = isFn(success); const hasSuccess = isFn(success);
const hasFail = isFn(fail); const hasFail = isFn(fail);
const hasComplete = isFn(complete); const hasComplete = isFn(complete);
Promise.resolve().then(() => { Promise.resolve().then(() => {
if (typeof enabled === 'undefined') { if (typeof enabled === 'undefined') {
enabled = false; enabled = false;
cid = ''; cid = '';
cidErrMsg = 'unipush is not enabled'; cidErrMsg = 'uniPush is not enabled';
} }
getPushCidCallbacks.push((cid, errMsg) => { getPushCidCallbacks.push((cid, errMsg) => {
let res; let res;
......
...@@ -1481,11 +1481,12 @@ function getPushClientId (args) { ...@@ -1481,11 +1481,12 @@ function getPushClientId (args) {
const hasSuccess = isFn(success); const hasSuccess = isFn(success);
const hasFail = isFn(fail); const hasFail = isFn(fail);
const hasComplete = isFn(complete); const hasComplete = isFn(complete);
Promise.resolve().then(() => { Promise.resolve().then(() => {
if (typeof enabled === 'undefined') { if (typeof enabled === 'undefined') {
enabled = false; enabled = false;
cid = ''; cid = '';
cidErrMsg = 'unipush is not enabled'; cidErrMsg = 'uniPush is not enabled';
} }
getPushCidCallbacks.push((cid, errMsg) => { getPushCidCallbacks.push((cid, errMsg) => {
let res; let res;
...@@ -2422,6 +2423,7 @@ function initRefs (vm) { ...@@ -2422,6 +2423,7 @@ function initRefs (vm) {
} }
const instances = Object.create(null); const instances = Object.create(null);
const components = Object.create(null);
function initRelation ({ function initRelation ({
vuePid, vuePid,
...@@ -2641,17 +2643,26 @@ function parseBaseComponent (vueComponentOptions, { ...@@ -2641,17 +2643,26 @@ function parseBaseComponent (vueComponentOptions, {
return [componentOptions, VueComponent] return [componentOptions, VueComponent]
} }
const components = []; function currentComponents (mpInstance, callback) {
const webviewId = mpInstance.__webviewId__;
const currentComponents = components[webviewId];
if (currentComponents) {
callback(currentComponents);
}
}
function parseComponent (vueOptions) { function parseComponent (vueOptions) {
const [componentOptions, VueComponent] = parseBaseComponent(vueOptions); const [componentOptions, VueComponent] = parseBaseComponent(vueOptions);
const lifetimes = componentOptions.lifetimes;
// 基础库 2.0 以上 attached 顺序错乱,按照 created 顺序强制纠正 // 基础库 2.0 以上 attached 顺序错乱,按照 created 顺序强制纠正
componentOptions.lifetimes.created = function created () { lifetimes.created = function created () {
currentComponents(this, components => {
components.push(this); components.push(this);
});
}; };
componentOptions.lifetimes.attached = function attached () { lifetimes.attached = function attached () {
this.__lifetimes_attached = function () { this.__lifetimes_attached = function () {
const properties = this.properties; const properties = this.properties;
...@@ -2678,6 +2689,7 @@ function parseComponent (vueOptions) { ...@@ -2678,6 +2689,7 @@ function parseComponent (vueOptions) {
// 触发首次 setData // 触发首次 setData
this.$vm.$mount(); this.$vm.$mount();
}; };
currentComponents(this, components => {
let component = this; let component = this;
while (component && component.__lifetimes_attached && components[0] && component === components[0]) { while (component && component.__lifetimes_attached && components[0] && component === components[0]) {
components.shift(); components.shift();
...@@ -2685,10 +2697,20 @@ function parseComponent (vueOptions) { ...@@ -2685,10 +2697,20 @@ function parseComponent (vueOptions) {
delete component.__lifetimes_attached; delete component.__lifetimes_attached;
component = components[0]; component = components[0];
} }
});
};
lifetimes.detached = function detached () {
currentComponents(this, components => {
const index = components.indexOf(this);
if (index >= 0) {
components.splice(index, 1);
}
});
}; };
// ready 比 handleLink 还早,初始化逻辑放到 handleLink 中 // ready 比 handleLink 还早,初始化逻辑放到 handleLink 中
delete componentOptions.lifetimes.ready; delete lifetimes.ready;
componentOptions.methods.__l = handleLink$1; componentOptions.methods.__l = handleLink$1;
...@@ -2731,8 +2753,17 @@ function parsePage (vuePageOptions) { ...@@ -2731,8 +2753,17 @@ function parsePage (vuePageOptions) {
isPage, isPage,
initRelation initRelation
}); });
const lifetimes = pageOptions.lifetimes;
const oldCreated = lifetimes.created;
lifetimes.created = function created () {
const webviewId = this.__webviewId__;
components[webviewId] = [];
if (typeof oldCreated === 'function') {
oldCreated.call(this);
}
};
// 页面需要在 ready 中触发,其他组件是在 handleLink 中触发 // 页面需要在 ready 中触发,其他组件是在 handleLink 中触发
pageOptions.lifetimes.ready = function ready () { lifetimes.ready = function ready () {
if (this.$vm && this.$vm.mpType === 'page') { if (this.$vm && this.$vm.mpType === 'page') {
this.$vm.__call_hook('created'); this.$vm.__call_hook('created');
this.$vm.__call_hook('beforeMount'); this.$vm.__call_hook('beforeMount');
...@@ -2743,8 +2774,11 @@ function parsePage (vuePageOptions) { ...@@ -2743,8 +2774,11 @@ function parsePage (vuePageOptions) {
this.is && console.warn(this.is + ' is not ready'); this.is && console.warn(this.is + ' is not ready');
} }
}; };
const oldDetached = lifetimes.detached;
pageOptions.lifetimes.detached = function detached () { lifetimes.detached = function detached () {
if (typeof oldDetached === 'function') {
oldDetached.call(this);
}
this.$vm && this.$vm.$destroy(); this.$vm && this.$vm.$destroy();
// 清理 // 清理
const webviewId = this.__webviewId__; const webviewId = this.__webviewId__;
...@@ -2753,6 +2787,7 @@ function parsePage (vuePageOptions) { ...@@ -2753,6 +2787,7 @@ function parsePage (vuePageOptions) {
delete instances[key]; delete instances[key];
} }
}); });
delete components[webviewId];
}; };
return pageOptions return pageOptions
......
...@@ -1212,11 +1212,12 @@ function getPushClientId (args) { ...@@ -1212,11 +1212,12 @@ function getPushClientId (args) {
const hasSuccess = isFn(success); const hasSuccess = isFn(success);
const hasFail = isFn(fail); const hasFail = isFn(fail);
const hasComplete = isFn(complete); const hasComplete = isFn(complete);
Promise.resolve().then(() => { Promise.resolve().then(() => {
if (typeof enabled === 'undefined') { if (typeof enabled === 'undefined') {
enabled = false; enabled = false;
cid = ''; cid = '';
cidErrMsg = 'unipush is not enabled'; cidErrMsg = 'uniPush is not enabled';
} }
getPushCidCallbacks.push((cid, errMsg) => { getPushCidCallbacks.push((cid, errMsg) => {
let res; let res;
......
...@@ -1059,11 +1059,12 @@ function getPushClientId (args) { ...@@ -1059,11 +1059,12 @@ function getPushClientId (args) {
const hasSuccess = isFn(success); const hasSuccess = isFn(success);
const hasFail = isFn(fail); const hasFail = isFn(fail);
const hasComplete = isFn(complete); const hasComplete = isFn(complete);
Promise.resolve().then(() => { Promise.resolve().then(() => {
if (typeof enabled === 'undefined') { if (typeof enabled === 'undefined') {
enabled = false; enabled = false;
cid = ''; cid = '';
cidErrMsg = 'unipush is not enabled'; cidErrMsg = 'uniPush is not enabled';
} }
getPushCidCallbacks.push((cid, errMsg) => { getPushCidCallbacks.push((cid, errMsg) => {
let res; let res;
......
...@@ -1230,11 +1230,12 @@ function getPushClientId (args) { ...@@ -1230,11 +1230,12 @@ function getPushClientId (args) {
const hasSuccess = isFn(success); const hasSuccess = isFn(success);
const hasFail = isFn(fail); const hasFail = isFn(fail);
const hasComplete = isFn(complete); const hasComplete = isFn(complete);
Promise.resolve().then(() => { Promise.resolve().then(() => {
if (typeof enabled === 'undefined') { if (typeof enabled === 'undefined') {
enabled = false; enabled = false;
cid = ''; cid = '';
cidErrMsg = 'unipush is not enabled'; cidErrMsg = 'uniPush is not enabled';
} }
getPushCidCallbacks.push((cid, errMsg) => { getPushCidCallbacks.push((cid, errMsg) => {
let res; let res;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册