mirror of
https://github.com/iczer/vue-antd-admin
synced 2025-04-05 07:27:06 +08:00
Merge branch 'master' of https://github.com/iczer/vue-antd-admin
This commit is contained in:
commit
ec2c70d181
@ -66,13 +66,21 @@ const authorityGuard = (to, from, next, options) => {
|
||||
*/
|
||||
const redirectGuard = (to, from, next, options) => {
|
||||
const {store} = options
|
||||
const getFirstChild = (routes) => {
|
||||
const route = routes[0]
|
||||
if (!route.children || route.children.length === 0) {
|
||||
return route
|
||||
}
|
||||
return getFirstChild(route.children)
|
||||
}
|
||||
if (store.state.setting.layout === 'mix') {
|
||||
const firstMenu = store.getters['setting/firstMenu']
|
||||
if (firstMenu.find(item => item.fullPath === to.fullPath)) {
|
||||
store.commit('setting/setActivatedFirst', to.fullPath)
|
||||
const subMenu = store.getters['setting/subMenu']
|
||||
if (subMenu.length > 0) {
|
||||
return next({path: subMenu[0].fullPath})
|
||||
const redirect = getFirstChild(subMenu)
|
||||
return next({path: redirect.fullPath})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user