配置好了vue2的子应用接入

This commit is contained in:
2026-06-20 23:42:22 +08:00
commit 2499043df4
19 changed files with 2648 additions and 0 deletions

51
src/config/subApps.ts Normal file
View File

@@ -0,0 +1,51 @@
/**
* 子应用配置列表
*
* 后续对接 Vue 2 子应用时,在此处添加/修改配置即可
*
* @see https://jd-opensource.github.io/micro-app/docs.html#/configure
*/
export interface SubAppConfig {
/** 应用名称,全局唯一,字母开头 */
name: string
/** 子应用地址(开发环境填写 devServer 地址) */
url: string
/** 基座分配给子应用的路由前缀 */
baseroute: string
/** 是否使用 iframe 沙箱Vite 子应用必须开启Webpack 子应用可选) */
iframe?: boolean
/** 是否保活子应用,避免重复加载 */
keepAlive?: boolean
/** 路由模式native | native-scope */
routerMode?: 'native' | 'native-scope'
/** 是否禁用样式隔离 */
disableScopecss?: boolean
/** 是否禁用沙箱 */
disableSandbox?: boolean
}
// ============================================================
// 当前对接的子应用列表
// 后续对接 Vue 2 项目时,修改 url 为实际的子应用地址
// ============================================================
export const subApps: SubAppConfig[] = [
{
name: 'vue2-app',
// TODO: 替换为你的 Vue 2 子应用实际地址
url: 'http://localhost:5173/',
baseroute: '/child-app',
// Vite 子应用必须开启 iframe 模式
// with 沙箱的 new Function() 不支持 ES Module 的 import/export 语法)
iframe: true,
keepAlive: true,
routerMode: 'native'
}
]
/**
* 根据名称查找子应用配置
*/
export function getSubAppConfig(name: string): SubAppConfig | undefined {
return subApps.find((app) => app.name === name)
}