This commit is contained in:
张成
2025-10-09 18:21:05 +08:00
parent ba61c9e45d
commit 6be5f7ed4f
49 changed files with 97 additions and 80 deletions

View File

@@ -244,10 +244,27 @@ export default class uiTool {
let menus = uiTool.transformTree(authorityMenus)
let curRoutes = uiTool.menuToRoute(menus, ParentView, Page404)
// 合并权限路由,保留默认 home 路由
// 递归检查所有层级中是否有首页路由
const hasHomeInRoutes = (routes) => {
if (!routes || !Array.isArray(routes)) return false
for (let route of routes) {
// 检查当前路由的 path
if (route.path === '/home' || route.path === 'home') {
return true
}
// 递归检查子路由
if (route.children && route.children.length > 0) {
if (hasHomeInRoutes(route.children)) {
return true
}
}
}
return false
}
const homeRoute = mainRoute.children.find(r => r.path === '/home')
// 检查权限路由中是否有首页(基于 path 判断)
const hasHome = curRoutes.some(r => r.path === '/home' || r.path === 'home')
const hasHome = hasHomeInRoutes(curRoutes)
if (hasHome) {
// 如果权限路由中有 home使用权限路由的 home不添加默认首页