mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
fix(plugin-qiankun): 当子应用存在路由而且子应用以路由的形式挂载时,需要在切换路由之前unmount子应用
This commit is contained in:
parent
444ac52e93
commit
34691cbb89
@ -13,11 +13,20 @@ import { getMasterOptions } from "./masterOptions";
|
|||||||
{{#HAS_PLUGIN_MODEL}}
|
{{#HAS_PLUGIN_MODEL}}
|
||||||
import { useModel } from '@@/core/pluginExports';
|
import { useModel } from '@@/core/pluginExports';
|
||||||
{{/HAS_PLUGIN_MODEL}}
|
{{/HAS_PLUGIN_MODEL}}
|
||||||
|
import { onBeforeRouteLeave } from "@@/core/coreExports";
|
||||||
|
|
||||||
function unmountMicroApp(microApp) {
|
let unmountPromise;
|
||||||
if (microApp && microApp.mountPromise) {
|
async function unmountMicroApp(microApp) {
|
||||||
microApp.mountPromise.then(() => microApp.unmount());
|
if (microApp) {
|
||||||
|
if (microApp.mountPromise) {
|
||||||
|
await microApp.mountPromise;
|
||||||
|
}
|
||||||
|
if (!unmountPromise) {
|
||||||
|
unmountPromise = microApp.unmount();
|
||||||
|
}
|
||||||
|
return await unmountPromise;
|
||||||
}
|
}
|
||||||
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
export const MicroApp = defineComponent({
|
export const MicroApp = defineComponent({
|
||||||
@ -156,6 +165,10 @@ export const MicroApp = defineComponent({
|
|||||||
loadApp();
|
loadApp();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onBeforeRouteLeave(async () => {
|
||||||
|
return await unmountMicroApp(microAppRef.value);
|
||||||
|
});
|
||||||
|
|
||||||
watch(()=>{
|
watch(()=>{
|
||||||
return {...{}, ...propsFromConfigRef.value, ...stateForSlave, ...propsFromParams}
|
return {...{}, ...propsFromConfigRef.value, ...stateForSlave, ...propsFromParams}
|
||||||
}, () => {
|
}, () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user