mirror of
https://github.com/WeBankFinTech/fes.js.git
synced 2025-04-06 03:59:53 +08:00
fix(plugin-qiankun): 当子应用单独运行时,不执行qiankun钩子和一些qiankun的逻辑
This commit is contained in:
parent
8444f64f10
commit
08aa7b09cb
@ -10,3 +10,22 @@ export const beforeRender = {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export const qiankun = {
|
||||
// 应用加载之前
|
||||
async bootstrap(props) {
|
||||
console.log('app1 bootstrap', props);
|
||||
},
|
||||
// 应用 render 之前触发
|
||||
async mount(props) {
|
||||
console.log('app1 mount', props);
|
||||
},
|
||||
// 当 props 更新时触发
|
||||
async update(props) {
|
||||
console.log('app1 update', props);
|
||||
},
|
||||
// 应用卸载之后触发
|
||||
async unmount(props) {
|
||||
console.log('app1 unmount', props);
|
||||
}
|
||||
};
|
||||
|
@ -5,8 +5,8 @@
|
||||
</template>
|
||||
<config>
|
||||
{
|
||||
"name": "index",
|
||||
"title": "home"
|
||||
"name": "test",
|
||||
"title": "test"
|
||||
}
|
||||
</config>
|
||||
<script>
|
||||
|
@ -38,10 +38,12 @@ function getSlaveRuntime() {
|
||||
// 子应用生命周期钩子Bootstrap
|
||||
export function genBootstrap(oldRender, appPromise) {
|
||||
return async (props) => {
|
||||
if (typeof props !== 'undefined') {
|
||||
const slaveRuntime = getSlaveRuntime();
|
||||
if (slaveRuntime.bootstrap) {
|
||||
await slaveRuntime.bootstrap(props);
|
||||
}
|
||||
}
|
||||
render = oldRender;
|
||||
if (isPromise(appPromise)) {
|
||||
cacheAppPromise = appPromise;
|
||||
@ -61,8 +63,6 @@ export function genMount(mountElementId) {
|
||||
if (slaveRuntime.mount) {
|
||||
await slaveRuntime.mount(props);
|
||||
}
|
||||
}
|
||||
|
||||
// 更新 clientRender 配置
|
||||
const clientRenderOpts = {
|
||||
// 支持通过 props 注入 container 来限定子应用 mountElementId 的查找范围
|
||||
@ -79,6 +79,7 @@ export function genMount(mountElementId) {
|
||||
if(props.onRouterInit){
|
||||
history.onRouterInit = props.onRouterInit;
|
||||
}
|
||||
}
|
||||
|
||||
// 第一次 mount 会自动触发 render,非第一次 mount 则需手动触发
|
||||
if (hasMountedAtLeastOnce) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user