chenghongxing 4 years ago
commit ec2c70d181
  1. 10
      src/router/guards.js

@ -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…
Cancel
Save