diff --git a/ruoyi-ui-next/src/stores/modules/permission.ts b/ruoyi-ui-next/src/stores/modules/permission.ts index 371f9c9..608e7db 100644 --- a/ruoyi-ui-next/src/stores/modules/permission.ts +++ b/ruoyi-ui-next/src/stores/modules/permission.ts @@ -55,7 +55,13 @@ export const usePermissionStore = defineStore('permission', () => { function filterAsyncRouter(menuList: any[]): RouteRecordRaw[] { return menuList .filter((menu: any) => menu.visible !== '1' || menu.children) - .map((menu: any) => { + .flatMap((menu: any) => { + // 如果顶级菜单 path 是 '/' 且 component 是 Layout, + // 直接展开它的 children,避免与 constantRoutes 中的 '/' 路由冲突 + if (menu.path === '/' && menu.component === 'Layout' && menu.children) { + return filterAsyncRouter(menu.children) + } + const route: any = { path: menu.path, name: menu.name || convertRouteName(menu.path),