|
@@ -23,28 +23,18 @@ router.beforeEach((to, from, next) => { |
|
@@ -23,28 +23,18 @@ router.beforeEach((to, from, next) => { |
|
23
|
// 拉取user_info
|
23
|
// 拉取user_info
|
|
24
|
const roles = res.roles
|
24
|
const roles = res.roles
|
|
25
|
store.dispatch('GenerateRoutes', { roles }).then(accessRoutes => {
|
25
|
store.dispatch('GenerateRoutes', { roles }).then(accessRoutes => {
|
|
26
|
- // 测试 默认静态页面
|
|
|
|
27
|
- // store.dispatch('permission/generateRoutes', { roles }).then(accessRoutes => {
|
|
|
|
28
|
// 根据roles权限生成可访问的路由表
|
26
|
// 根据roles权限生成可访问的路由表
|
|
29
|
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
27
|
router.addRoutes(accessRoutes) // 动态添加可访问路由表
|
|
30
|
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
28
|
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
|
31
|
})
|
29
|
})
|
|
32
|
- })
|
|
|
|
33
|
- .catch(err => {
|
|
|
|
34
|
- store.dispatch('FedLogOut').then(() => {
|
30
|
+ }).catch(err => {
|
|
|
|
31
|
+ store.dispatch('LogOut').then(() => {
|
|
35
|
Message.error(err)
|
32
|
Message.error(err)
|
|
36
|
next({ path: '/' })
|
33
|
next({ path: '/' })
|
|
37
|
})
|
34
|
})
|
|
38
|
})
|
35
|
})
|
|
39
|
} else {
|
36
|
} else {
|
|
40
|
next()
|
37
|
next()
|
|
41
|
- // 没有动态改变权限的需求可直接next() 删除下方权限判断 ↓
|
|
|
|
42
|
- // if (hasPermission(store.getters.roles, to.meta.roles)) {
|
|
|
|
43
|
- // next()
|
|
|
|
44
|
- // } else {
|
|
|
|
45
|
- // next({ path: '/401', replace: true, query: { noGoBack: true }})
|
|
|
|
46
|
- // }
|
|
|
|
47
|
- // 可删 ↑
|
|
|
|
48
|
}
|
38
|
}
|
|
49
|
}
|
39
|
}
|
|
50
|
} else {
|
40
|
} else {
|