路由修正

This commit is contained in:
2025-11-14 19:17:49 +08:00
parent 9e4cfc1200
commit cb401eebe1
8 changed files with 54 additions and 98 deletions

View File

@@ -186,9 +186,12 @@ function generateRouteFromMenu(menu: SysMenu, isTopLevel = true): RouteRecordRaw
}
});
// 当前菜单指定了页面组件时,即使存在子菜单也应当渲染该页面
// 但如果 component 是布局组件,则不应该创建 path: '' 的子路由(因为布局组件已经是父路由的组件了)
if (menu.component && !isComponentLayout) {
// 当前菜单指定了页面组件时,如果存在“普通子菜单”(非 PAGE 类型)
// 则需要创建一个默认子路由来承载当前菜单的页面组件,
// 这样父级既能作为分组,又能渲染自己的页面。
// 如果只有 PAGE 类型子菜单,则直接使用当前路由组件,而不再包一层 `_page`
// 避免多出一层嵌套导致 matched 结构过深。
if (menu.component && !isComponentLayout && normalChildren.length > 0) {
route.children!.push({
path: '',
name: `${menu.menuID}_page`,