mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
fix: 修复qiankun内存泄露
This commit is contained in:
parent
fbf32d6afc
commit
6cb1672cf4
@ -14,6 +14,7 @@
|
|||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
return {
|
return {
|
||||||
|
leak: new Array(5 * 1024 * 1024)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
export default {
|
export default {
|
||||||
setup() {
|
setup() {
|
||||||
return {
|
return {
|
||||||
|
leak: new Array(5 * 1024 * 1024)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
|
import { defineComponent, watch, onUnmounted } from 'vue';
|
||||||
import {
|
|
||||||
defineComponent, isRef, watch
|
|
||||||
} from 'vue';
|
|
||||||
import { MicroApp } from './MicroApp';
|
import { MicroApp } from './MicroApp';
|
||||||
|
|
||||||
|
|
||||||
export const MicroAppWithMemoHistory = defineComponent({
|
export const MicroAppWithMemoHistory = defineComponent({
|
||||||
components: {
|
components: {
|
||||||
MicroApp
|
MicroApp
|
||||||
@ -26,9 +22,21 @@ export const MicroAppWithMemoHistory = defineComponent({
|
|||||||
microRouter = router;
|
microRouter = router;
|
||||||
microRouter.push(props.url);
|
microRouter.push(props.url);
|
||||||
};
|
};
|
||||||
watch(()=>props.url, () => {
|
watch(
|
||||||
|
() => props.url,
|
||||||
|
() => {
|
||||||
microRouter.push(props.url);
|
microRouter.push(props.url);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
onUnmounted(() => {
|
||||||
|
microRouter = null;
|
||||||
});
|
});
|
||||||
return () => <MicroApp onRouterInit={onRouterInit} {...props} {...attrs}></MicroApp>;
|
return () => (
|
||||||
|
<MicroApp
|
||||||
|
onRouterInit={onRouterInit}
|
||||||
|
{...props}
|
||||||
|
{...attrs}
|
||||||
|
></MicroApp>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { plugin, ApplyPluginsType } from '@@/core/coreExports';
|
import { plugin, ApplyPluginsType, getHistory, destroyRouter } from '@@/core/coreExports';
|
||||||
{{#HAS_PLUGIN_MODEL}}
|
{{#HAS_PLUGIN_MODEL}}
|
||||||
import { setModelState } from './qiankunModel';
|
import { setModelState } from './qiankunModel';
|
||||||
{{/HAS_PLUGIN_MODEL}}
|
{{/HAS_PLUGIN_MODEL}}
|
||||||
@ -49,6 +49,7 @@ export function genBootstrap(oldRender, appPromise) {
|
|||||||
if (isPromise(appPromise)) {
|
if (isPromise(appPromise)) {
|
||||||
cacheAppPromise = appPromise;
|
cacheAppPromise = appPromise;
|
||||||
}
|
}
|
||||||
|
appPromise = null;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +116,12 @@ export function genUpdate() {
|
|||||||
// 子应用生命周期钩子Unmount
|
// 子应用生命周期钩子Unmount
|
||||||
export function genUnmount() {
|
export function genUnmount() {
|
||||||
return async (props) => {
|
return async (props) => {
|
||||||
|
Object.keys(history).forEach(key=>{
|
||||||
|
delete history[key]
|
||||||
|
})
|
||||||
|
const routerHistory = getHistory();
|
||||||
|
routerHistory?.destroy();
|
||||||
|
destroyRouter();
|
||||||
if (cache[props.name]) {
|
if (cache[props.name]) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const app = cache[props.name];
|
const app = cache[props.name];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user