|
|
@ -28,12 +28,13 @@ router.beforeEach((to, from, next) => { |
|
|
|
// 自动跳转到根路由
|
|
|
|
// 自动跳转到根路由
|
|
|
|
let root = accessRoutes.find(item => item.path === '/') |
|
|
|
let root = accessRoutes.find(item => item.path === '/') |
|
|
|
let _to |
|
|
|
let _to |
|
|
|
if (root && root.children.find(item => item.path.endsWith('index'))) { |
|
|
|
if (to.fullPath === '/' && root && root.children.find(item => item.path.endsWith('index'))) { |
|
|
|
root.redirect = root.children.find(item => item.path.endsWith('/index')).path |
|
|
|
root.redirect = root.children.find(item => item.path.endsWith('/index')).path |
|
|
|
_to = { ...to, replace: true, path: root.redirect } |
|
|
|
_to = { ...to, replace: true, path: root.redirect } |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
_to = { ...to, replace: true } |
|
|
|
_to = { ...to, replace: true } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 根据roles权限生成可访问的路由表
|
|
|
|
// 根据roles权限生成可访问的路由表
|
|
|
|
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
|
|
|
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
|
|
|
next(_to) // hack方法 确保addRoutes已完成
|
|
|
|
next(_to) // hack方法 确保addRoutes已完成
|
|
|
|