fix: redirect problem in mix navigation mode; 🐛

修复:混合模式下重定向问题;
master
iczer 4 years ago
parent 10fc9c11b8
commit acd66d7d6c
  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