提交 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)
......@@ -1701,6 +1701,17 @@ function parsePage (vuePageOptions) {
}
};
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,
instances,
initRelation
} from './util'
......@@ -23,5 +24,16 @@ export default function parsePage (vuePageOptions) {
}
}
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,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册