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

fix(mp-toutiao): clean up vms

上级 4feda7d4
...@@ -231,13 +231,13 @@ const promiseInterceptor = { ...@@ -231,13 +231,13 @@ const promiseInterceptor = {
}; };
const SYNC_API_RE = 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 CONTEXT_API_RE = /^create|Manager$/;
const ASYNC_API = ['createBLEConnection']; const ASYNC_API = ['createBLEConnection'];
const CALLBACK_API_RE = /^on/; const CALLBACK_API_RE = /^on|^off/;
function isContextApi (name) { function isContextApi (name) {
return CONTEXT_API_RE.test(name) return CONTEXT_API_RE.test(name)
...@@ -1699,6 +1699,17 @@ function parsePage (vuePageOptions) { ...@@ -1699,6 +1699,17 @@ function parsePage (vuePageOptions) {
} else { } else {
this.is && console.warn(this.is + ' is not ready'); 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 return pageOptions
......
import { import {
isPage, isPage,
instances,
initRelation initRelation
} from './util' } from './util'
...@@ -21,6 +22,17 @@ export default function parsePage (vuePageOptions) { ...@@ -21,6 +22,17 @@ export default function parsePage (vuePageOptions) {
} else { } else {
this.is && console.warn(this.is + ' is not ready') 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 return pageOptions
......
...@@ -51,7 +51,7 @@ export function initRefs (vm) { ...@@ -51,7 +51,7 @@ export function initRefs (vm) {
} }
} }
const instances = Object.create(null) export const instances = Object.create(null)
export function initRelation ({ export function initRelation ({
vuePid, vuePid,
...@@ -101,4 +101,4 @@ export function handleLink ({ ...@@ -101,4 +101,4 @@ export function handleLink ({
vm._isMounted = true vm._isMounted = true
vm.__call_hook('mounted') vm.__call_hook('mounted')
vm.__call_hook('onReady') vm.__call_hook('onReady')
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册