mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-24 15:06:39 +08:00
v3.7.2 版本代码合并
This commit is contained in:
12
jeecgboot-vue3/src/qiankun/micro/index.ts
Normal file
12
jeecgboot-vue3/src/qiankun/micro/index.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import {qiankunWindow} from 'vite-plugin-qiankun/dist/helper'
|
||||
|
||||
/**
|
||||
* 【JEECG作为乾坤子应用】【判断当前是否是以乾坤子应用的模式运行】
|
||||
*/
|
||||
export function checkIsQiankunMicro(): boolean {
|
||||
return !!qiankunWindow.__POWERED_BY_QIANKUN__;
|
||||
}
|
||||
|
||||
export function getGlobal() {
|
||||
return (checkIsQiankunMicro() ? qiankunWindow : window) as Window
|
||||
}
|
||||
57
jeecgboot-vue3/src/qiankun/micro/qiankunMicro.ts
Normal file
57
jeecgboot-vue3/src/qiankun/micro/qiankunMicro.ts
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 【JEECG作为乾坤子应用】
|
||||
*/
|
||||
import type {App} from 'vue';
|
||||
import type {MainAppProps} from "#/main";
|
||||
|
||||
import {destroyStore} from "@/store";
|
||||
import {destroyRouter} from "@/router";
|
||||
import {clearComponent} from "@/components/jeecg/JVxeTable/src/componentMap";
|
||||
|
||||
import {renderWithQiankun} from 'vite-plugin-qiankun/dist/helper';
|
||||
|
||||
/**
|
||||
* 以乾坤子应用模式运行
|
||||
* @param render
|
||||
*/
|
||||
export async function useQiankunMicroApp(render: (props?: MainAppProps) => Promise<App>) {
|
||||
let instance: Nullable<App> = null;
|
||||
|
||||
// 注册乾坤子应用生命周期函数
|
||||
renderWithQiankun({
|
||||
async mount(props) {
|
||||
console.debug('[qiankun-micro] mount - props :', props)
|
||||
instance = await render({
|
||||
container: props.container!,
|
||||
hideSider: props.hideSider,
|
||||
hideHeader: props.hideHeader,
|
||||
hideMultiTabs: props.hideMultiTabs,
|
||||
});
|
||||
},
|
||||
bootstrap() {
|
||||
console.debug('[qiankun-micro] bootstrap');
|
||||
},
|
||||
update(props) {
|
||||
console.debug('[qiankun-micro] update: ', props);
|
||||
},
|
||||
unmount(props) {
|
||||
console.debug('[qiankun-micro] unmount: ', props);
|
||||
|
||||
destroyStore();
|
||||
destroyRouter();
|
||||
|
||||
if (instance) {
|
||||
clearComponent();
|
||||
instance.unmount();
|
||||
instance._container.innerHTML = '';
|
||||
instance = null;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
return instance!
|
||||
}
|
||||
|
||||
export async function autoUseQiankunMicro(fn: Fn) {
|
||||
return useQiankunMicroApp(fn)
|
||||
}
|
||||
Reference in New Issue
Block a user