From 7db725d9f4148741c2443e50f30b36befcf383b8 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Mon, 5 Oct 2026 17:05:11 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=BE=AE=E5=89=8D=E7=AB=AF):=20=E8=BF=9C?= =?UTF-8?q?=E7=AB=AF=E5=BA=94=E7=94=A8=E6=94=B9=E4=B8=BA=20Layout=20?= =?UTF-8?q?=E5=AD=90=E8=B7=AF=E7=94=B1=EF=BC=8C=E4=B8=8D=E5=86=8D=E8=A6=86?= =?UTF-8?q?=E7=9B=96=20GERP=20=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 此前 /remote-app/:code 经 router.addRoute 注册为顶层路由,会绕过 DefaultLayout 直接铺满整屏(盖住侧边栏/顶栏);现给布局父路由命名 Layout 并以 router.addRoute('Layout', ...) 注入子路由,远端页面渲染在 GERP 框架内(保留导航与标签页)。 --- src/apps/remoteRoutes.ts | 6 ++++-- src/router/index.ts | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/apps/remoteRoutes.ts b/src/apps/remoteRoutes.ts index 3eb6575..6e35bc0 100644 --- a/src/apps/remoteRoutes.ts +++ b/src/apps/remoteRoutes.ts @@ -29,12 +29,14 @@ const REMOTE_DEMO_APP: AppFrontendModule = { * 安装远端应用路由(宿主启动时调用一次) * * 注入 `/remote-app/:code`:由 RemoteAppHost 按 AppCode 动态加载远端组件渲染。 + * **作为 Layout 的子路由注入**,使远端页面渲染在 GERP 框架内(侧边栏/顶栏/标签页保留); + * 若注册为顶层路由,会绕过 DefaultLayout 直接覆盖整个外壳。 * 注意路由不带 menuGuarded —— 远端应用暂不参与后端菜单过滤,由清单/接口自行控权限。 */ export function InstallRemoteAppRoutes(router: Router): void { registerRemoteApp(REMOTE_DEMO_APP) - router.addRoute({ - path: '/remote-app/:code', + router.addRoute('Layout', { + path: 'remote-app/:code', name: 'RemoteApp', component: () => import('@/views/RemoteAppHost.vue'), meta: { title: '远端应用', requiresAuth: true }, diff --git a/src/router/index.ts b/src/router/index.ts index 2828eae..21d0889 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -15,6 +15,9 @@ export const staticRoutes: RouteRecordRaw[] = [ }, { path: '/', + // 命名父路由:远端微前端应用经 router.addRoute('Layout', ...) 注入为子路由, + // 从而享有完整框架(侧边栏/顶栏/标签页),而不是盖住 GERP 外壳 + name: 'Layout', component: () => import('@/layouts/DefaultLayout.vue'), redirect: '/dashboard', children: [