身份跳转后台
This commit is contained in:
@ -14,7 +14,6 @@ router.beforeEach((to, from, next) => {
|
||||
NProgress.start()
|
||||
// 跳过登录验证
|
||||
next();
|
||||
return;
|
||||
if (getToken()) {
|
||||
to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
|
||||
/* has token*/
|
||||
@ -27,15 +26,16 @@ router.beforeEach((to, from, next) => {
|
||||
if (store.getters.roles.length === 0) {
|
||||
// 判断当前用户是否已拉取完user_info信息
|
||||
store.dispatch('GetInfo').then(() => {
|
||||
store.dispatch('GenerateRoutes').then(accessRoutes => {
|
||||
// 根据roles权限生成可访问的路由表
|
||||
accessRoutes.forEach(route => {
|
||||
if (!isHttp(route.path)) {
|
||||
router.addRoute(route) // 动态添加可访问路由表
|
||||
}
|
||||
})
|
||||
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
||||
})
|
||||
next({ ...to, replace: true })
|
||||
// store.dispatch('GenerateRoutes').then(accessRoutes => {
|
||||
// // 根据roles权限生成可访问的路由表
|
||||
// accessRoutes.forEach(route => {
|
||||
// if (!isHttp(route.path)) {
|
||||
// router.addRoute(route) // 动态添加可访问路由表
|
||||
// }
|
||||
// })
|
||||
// next({ ...to, replace: true }) // hack方法 确保addRoutes已完成
|
||||
// })
|
||||
}).catch(err => {
|
||||
store.dispatch('LogOut').then(() => {
|
||||
ElMessage.error(err)
|
||||
|
Reference in New Issue
Block a user