cloud-JG/src/app.ts
2025-09-08 11:04:50 +08:00

61 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @Author: zzy 411037547@qq.com
* @Date: 2023-05-26 10:05:48
* @LastEditors: zzy 411037547@qq.com
* @LastEditTime: 2023-05-26 11:15:58
* @FilePath: \cloud-platform\src\app.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
import globalState from './globalState';
import { routePreloader } from './utils/routePreloader';
// import { getMicroAppRouteComponent } from 'umi';
// 将全局state注入子应用
export function useQiankunStateForSlave() {
return {
globalState,
};
}
// 注册子应用
export const qiankun = {
apps: [
{
name: 'internalManage',
// entry: '//dev.eshangtech.com:16060/merchantManagement/'
entry: '//localhost:8888/internalManage/',
},
],
}
// 应用启动时的初始化配置
export async function getInitialState() {
// 预加载关键路由以优化首屏加载
setTimeout(() => {
routePreloader.preloadCriticalRoutes().then(() => {
console.log('关键路由预加载完成');
}).catch(error => {
console.warn('关键路由预加载失败:', error);
});
}, 1000); // 延迟1秒后开始预加载避免影响首屏渲染
return {
preloadEnabled: true,
};
}
// export const patchRoutes = ({ routes }: any) => {
// console.info('routes', routes);
// routes[0].routes[1].routes[0].routes.forEach((item: any, index: number) => {
// if (item.microApp) {
// routes[0].routes[1].routes[0].routes[index].component = (() => getMicroAppRouteComponent({
// appName: item.microApp,
// base: item.microAppProps?.base || '/',
// masterHistoryType: item.microAppProps?.history || 'browser',
// routeProps: {}
// }))()
// }
// });
// }