|
@ -9,6 +9,8 @@ import Layout from '@/layout/index'; |
|
|
*/ |
|
|
*/ |
|
|
// 提取路由
|
|
|
// 提取路由
|
|
|
const pickRoutes = ['/reservoir', '/dike', '/sluice', '/aiSupervision']; |
|
|
const pickRoutes = ['/reservoir', '/dike', '/sluice', '/aiSupervision']; |
|
|
|
|
|
// 根据meta.title提取的路由
|
|
|
|
|
|
const pickRouteNames = ['一张图'] |
|
|
|
|
|
|
|
|
const permission = { |
|
|
const permission = { |
|
|
state: { |
|
|
state: { |
|
@ -16,7 +18,8 @@ const permission = { |
|
|
routes: [], |
|
|
routes: [], |
|
|
addRoutes: [], |
|
|
addRoutes: [], |
|
|
originRoutes: [], |
|
|
originRoutes: [], |
|
|
selectTab: sessionStorage.getItem('topTab') || 'dike' |
|
|
selectTab: sessionStorage.getItem('topTab') || 'dike', |
|
|
|
|
|
namesJumpMenu: [] // 跳转菜单
|
|
|
}, |
|
|
}, |
|
|
mutations: { |
|
|
mutations: { |
|
|
SET_ROUTES: (state, { routes, originRoutes }) => { |
|
|
SET_ROUTES: (state, { routes, originRoutes }) => { |
|
@ -185,12 +188,21 @@ function resolveChildrenRoutes(routes, pickRoute = permission.state.selectTab) { |
|
|
if (!routes?.length) return; |
|
|
if (!routes?.length) return; |
|
|
let pickRoutePath = `/${pickRoute}`; |
|
|
let pickRoutePath = `/${pickRoute}`; |
|
|
let tempRoutesArr = []; |
|
|
let tempRoutesArr = []; |
|
|
|
|
|
let tempRoutesNameArr = []; |
|
|
let newChildrenRoutes = []; |
|
|
let newChildrenRoutes = []; |
|
|
let newRoutes = routes.filter((v) => { |
|
|
let newRoutes = routes.filter((v) => { |
|
|
if (pickRoutes.includes(v.path)) { |
|
|
if (pickRoutes.includes(v.path)) { |
|
|
tempRoutesArr.push(v); |
|
|
tempRoutesArr.push(v); |
|
|
} |
|
|
} |
|
|
return !pickRoutes.includes(v.path); |
|
|
// 只要是名称叫“一张图”的都不展示在菜单上
|
|
|
|
|
|
if(v.meta?.title && pickRouteNames.includes(v.meta.title)) { |
|
|
|
|
|
if(!v.hidden) tempRoutesNameArr.push({ |
|
|
|
|
|
...v, |
|
|
|
|
|
label: v.meta.title, |
|
|
|
|
|
value: v.path |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
return !pickRoutes.includes(v.path) && v.meta?.title !== '一张图'; |
|
|
}); |
|
|
}); |
|
|
if (tempRoutesArr.length) { |
|
|
if (tempRoutesArr.length) { |
|
|
let parentRoute = tempRoutesArr.filter((v) => v.path === pickRoutePath)?.[0]; |
|
|
let parentRoute = tempRoutesArr.filter((v) => v.path === pickRoutePath)?.[0]; |
|
@ -201,9 +213,7 @@ function resolveChildrenRoutes(routes, pickRoute = permission.state.selectTab) { |
|
|
...v, |
|
|
...v, |
|
|
path: `${parentRoute.path}/${v.path}` |
|
|
path: `${parentRoute.path}/${v.path}` |
|
|
}; |
|
|
}; |
|
|
}) || []; |
|
|
})?.map(v=> { |
|
|
|
|
|
|
|
|
newChildrenRoutes = newChildrenRoutes.map(v=> { |
|
|
|
|
|
if(v.path && v.path != '/' && (!v.children || !v.children.length)){ |
|
|
if(v.path && v.path != '/' && (!v.children || !v.children.length)){ |
|
|
// 为了让非目录的一级菜单正常展示
|
|
|
// 为了让非目录的一级菜单正常展示
|
|
|
return { |
|
|
return { |
|
@ -219,12 +229,17 @@ function resolveChildrenRoutes(routes, pickRoute = permission.state.selectTab) { |
|
|
} else { |
|
|
} else { |
|
|
return v |
|
|
return v |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) || []; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// tempRoutesNameArr 赋值给 namesJumpMenu
|
|
|
|
|
|
permission.state.namesJumpMenu = tempRoutesNameArr; |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
topTabList: tempRoutesArr.map((v) => { |
|
|
topTabList: tempRoutesArr.map((v) => { |
|
|
return { |
|
|
return { |
|
|
|
|
|
orderNum: v.orderNum, |
|
|
label: v.meta.title, |
|
|
label: v.meta.title, |
|
|
value: v.path.slice(1) |
|
|
value: v.path.slice(1) |
|
|
}; |
|
|
}; |
|
|