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>
|
</template>
|
||||||
<config>
|
<config>
|
||||||
{
|
{
|
||||||
"name": "index",
|
"name": "test",
|
||||||
"title": "home"
|
"title": "test"
|
||||||
}
|
}
|
||||||
</config>
|
</config>
|
||||||
<script>
|
<script>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div>
|
<div>
|
||||||
main
|
main
|
||||||
<a-tabs v-model:activeKey="activeKey">
|
<a-tabs v-model:activeKey="activeKey">
|
||||||
<a-tab-pane key="1" tab="Tab 1"> <MicroAppWithMemoHistory key="1" name="app1" url="/app1" /></a-tab-pane>
|
<a-tab-pane key="1" tab="Tab 1"><MicroAppWithMemoHistory key="1" name="app1" url="/app1" /></a-tab-pane>
|
||||||
<a-tab-pane key="2" tab="Tab 2"><MicroAppWithMemoHistory key="2" name="app1" url="/app1/test" /></a-tab-pane>
|
<a-tab-pane key="2" tab="Tab 2"><MicroAppWithMemoHistory key="2" name="app1" url="/app1/test" /></a-tab-pane>
|
||||||
<a-tab-pane key="3" tab="Tab 3">Content of Tab Pane 3</a-tab-pane>
|
<a-tab-pane key="3" tab="Tab 3">Content of Tab Pane 3</a-tab-pane>
|
||||||
</a-tabs>
|
</a-tabs>
|
||||||
|
@ -38,9 +38,11 @@ function getSlaveRuntime() {
|
|||||||
// 子应用生命周期钩子Bootstrap
|
// 子应用生命周期钩子Bootstrap
|
||||||
export function genBootstrap(oldRender, appPromise) {
|
export function genBootstrap(oldRender, appPromise) {
|
||||||
return async (props) => {
|
return async (props) => {
|
||||||
const slaveRuntime = getSlaveRuntime();
|
if (typeof props !== 'undefined') {
|
||||||
if (slaveRuntime.bootstrap) {
|
const slaveRuntime = getSlaveRuntime();
|
||||||
await slaveRuntime.bootstrap(props);
|
if (slaveRuntime.bootstrap) {
|
||||||
|
await slaveRuntime.bootstrap(props);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
render = oldRender;
|
render = oldRender;
|
||||||
if (isPromise(appPromise)) {
|
if (isPromise(appPromise)) {
|
||||||
@ -61,23 +63,22 @@ export function genMount(mountElementId) {
|
|||||||
if (slaveRuntime.mount) {
|
if (slaveRuntime.mount) {
|
||||||
await slaveRuntime.mount(props);
|
await slaveRuntime.mount(props);
|
||||||
}
|
}
|
||||||
}
|
// 更新 clientRender 配置
|
||||||
|
const clientRenderOpts = {
|
||||||
|
// 支持通过 props 注入 container 来限定子应用 mountElementId 的查找范围
|
||||||
|
// 避免多个子应用出现在同一主应用时出现 mount 冲突
|
||||||
|
rootElement:
|
||||||
|
props?.container?.querySelector(mountElementId) || mountElementId
|
||||||
|
};
|
||||||
|
|
||||||
// 更新 clientRender 配置
|
clientRenderOptsStack.push(clientRenderOpts);
|
||||||
const clientRenderOpts = {
|
|
||||||
// 支持通过 props 注入 container 来限定子应用 mountElementId 的查找范围
|
|
||||||
// 避免多个子应用出现在同一主应用时出现 mount 冲突
|
|
||||||
rootElement:
|
|
||||||
props?.container?.querySelector(mountElementId) || mountElementId
|
|
||||||
};
|
|
||||||
|
|
||||||
clientRenderOptsStack.push(clientRenderOpts);
|
if(props.url){
|
||||||
|
history.url = props.url || '/';
|
||||||
if(props.url){
|
}
|
||||||
history.url = props.url || '/';
|
if(props.onRouterInit){
|
||||||
}
|
history.onRouterInit = props.onRouterInit;
|
||||||
if(props.onRouterInit){
|
}
|
||||||
history.onRouterInit = props.onRouterInit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 第一次 mount 会自动触发 render,非第一次 mount 则需手动触发
|
// 第一次 mount 会自动触发 render,非第一次 mount 则需手动触发
|
||||||
|
Loading…
x
Reference in New Issue
Block a user