v3.7.2 版本代码合并

This commit is contained in:
JEECG
2024-12-09 15:10:46 +08:00
parent 64b29f47e0
commit b0c4194602
118 changed files with 12729 additions and 1596 deletions

View 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
}

View 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)
}