首页无权限跳转到第一个有权限的菜单

This commit is contained in:
姚亚男
2022-01-26 09:58:36 +08:00
parent 2cb4c1f481
commit fe83dd07ae
2 changed files with 36 additions and 3 deletions
+13 -1
View File
@@ -81,13 +81,14 @@ export function formatDate(value, fmt) {
// 生成首页路由
export function generateIndexRouter(data) {
const redirectPath = findFirstRoute(data)
let indexRouter = [{
path: '/',
name: 'dashboard',
//component: () => import('@/components/layouts/BasicLayout'),
component: resolve => require(['@/components/layouts/TabLayout'], resolve),
meta: { title: '首页' },
redirect: '/dashboard/analysis',
redirect: redirectPath,
children: [
...generateChildRouters(data)
]
@@ -560,4 +561,15 @@ export function removeArrayElement(array, prod, value) {
if(index>=0){
array.splice(index, 1);
}
}
export function findFirstRoute(data){
if (data[0]) {
if (data[0] && data[0].children && data[0].children.length > 0) {
return findFirstRoute(data[0].children)
} else {
return data[0].path
}
} else {
return '/'
}
}