1
This commit is contained in:
@@ -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(不添加默认首页)
|
||||
|
||||
Reference in New Issue
Block a user