mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
fix(qiankun): 切出子应用时,因为app是异步数据导致未及时unmount
This commit is contained in:
parent
34691cbb89
commit
77e074d03a
@ -16,7 +16,7 @@ function isPromise(obj) {
|
|||||||
|
|
||||||
|
|
||||||
let render = () => {};
|
let render = () => {};
|
||||||
let app = null;
|
let cacheAppPromise = null;
|
||||||
let hasMountedAtLeastOnce = false;
|
let hasMountedAtLeastOnce = false;
|
||||||
|
|
||||||
export default () => defer.promise;
|
export default () => defer.promise;
|
||||||
@ -40,7 +40,7 @@ export function genBootstrap(oldRender, appPromise) {
|
|||||||
}
|
}
|
||||||
render = oldRender;
|
render = oldRender;
|
||||||
if (isPromise(appPromise)) {
|
if (isPromise(appPromise)) {
|
||||||
app = await appPromise;
|
cacheAppPromise = appPromise;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -63,7 +63,7 @@ export function genMount() {
|
|||||||
if (hasMountedAtLeastOnce) {
|
if (hasMountedAtLeastOnce) {
|
||||||
const appPromise = render();
|
const appPromise = render();
|
||||||
if (isPromise(appPromise)) {
|
if (isPromise(appPromise)) {
|
||||||
app = await appPromise;
|
cacheAppPromise = appPromise;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
defer.resolve();
|
defer.resolve();
|
||||||
@ -93,7 +93,8 @@ export function genUnmount(mountElementId) {
|
|||||||
? props.container.querySelector(mountElementId)
|
? props.container.querySelector(mountElementId)
|
||||||
: document.querySelector(mountElementId);
|
: document.querySelector(mountElementId);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
if (container && app) {
|
if (container && cacheAppPromise) {
|
||||||
|
const app = await cacheAppPromise;
|
||||||
app.unmount(container);
|
app.unmount(container);
|
||||||
}
|
}
|
||||||
const slaveRuntime = getSlaveRuntime();
|
const slaveRuntime = getSlaveRuntime();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user