|
|
|
|
@ -38,14 +38,14 @@ router.beforeEach(async(to, from, next) => {
|
|
|
|
|
} else {
|
|
|
|
|
const hasRoles = store.getters.roles && store.getters.roles.length > 0
|
|
|
|
|
if (hasRoles) {
|
|
|
|
|
// console.log('跳转1', to);
|
|
|
|
|
console.log('跳转1', to);
|
|
|
|
|
next()
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
const roles = await store.dispatch('user/getInfo')
|
|
|
|
|
const accessRoutes = await store.dispatch('permission/generateRoutes', roles)
|
|
|
|
|
router.addRoutes(accessRoutes)
|
|
|
|
|
// console.log('跳转2', to);
|
|
|
|
|
console.log('跳转2', to);
|
|
|
|
|
next({ path: to.redirectedFrom || to.path, replace: true })
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// remove token and go to login page to re-login
|
|
|
|
|
|