提交 35578647 编写于 作者: fxy060608's avatar fxy060608

fix(mp-toutiao): clean up vms

上级 4feda7d4
......@@ -231,13 +231,13 @@ const promiseInterceptor = {
};
const SYNC_API_RE =
/^\$|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
/^\$|sendNativeEvent|restoreGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64/;
const CONTEXT_API_RE = /^create|Manager$/;
const ASYNC_API = ['createBLEConnection'];
const CALLBACK_API_RE = /^on/;
const CALLBACK_API_RE = /^on|^off/;
function isContextApi (name) {
return CONTEXT_API_RE.test(name)
......@@ -1699,6 +1699,17 @@ function parsePage (vuePageOptions) {
} else {
this.is && console.warn(this.is + ' is not ready');
}
};
pageOptions.lifetimes.detached = function detached () {
this.$vm && this.$vm.$destroy();
// 清理
const webviewId = this.__webviewId__;
webviewId && Object.keys(instances).forEach(key => {
if (key.indexOf(webviewId + '_') === 0) {
delete instances[key];
}
});
};
return pageOptions
......
import {
isPage,
isPage,
instances,
initRelation
} from './util'
......@@ -21,6 +22,17 @@ export default function parsePage (vuePageOptions) {
} else {
this.is && console.warn(this.is + ' is not ready')
}
}
pageOptions.lifetimes.detached = function detached () {
this.$vm && this.$vm.$destroy()
// 清理
const webviewId = this.__webviewId__
webviewId && Object.keys(instances).forEach(key => {
if (key.indexOf(webviewId + '_') === 0) {
delete instances[key]
}
})
}
return pageOptions
......
......@@ -51,7 +51,7 @@ export function initRefs (vm) {
}
}
const instances = Object.create(null)
export const instances = Object.create(null)
export function initRelation ({
vuePid,
......@@ -101,4 +101,4 @@ export function handleLink ({
vm._isMounted = true
vm.__call_hook('mounted')
vm.__call_hook('onReady')
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册