以editor登录后切换到admin,无法访问页面权限
This commit is contained in:
parent
4d6e9a5358
commit
9e0fcb07c6
|
@ -1,4 +1,4 @@
|
|||
import router from './router'
|
||||
import router, { asyncRouterMap } from './router'
|
||||
import store from './store'
|
||||
import { Message } from 'element-ui'
|
||||
import NProgress from 'nprogress' // progress bar
|
||||
|
@ -28,7 +28,7 @@ router.beforeEach((to, from, next) => {
|
|||
store.dispatch('GetUserInfo').then(res => { // 拉取user_info
|
||||
const roles = res.data.roles // note: roles must be a array! such as: ['editor','develop']
|
||||
store.dispatch('GenerateRoutes', { roles }).then(() => { // 根据roles权限生成可访问的路由表
|
||||
router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表
|
||||
router.addRoutes(asyncRouterMap) // 动态添加可访问路由表
|
||||
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
|
||||
})
|
||||
}).catch((err) => {
|
||||
|
|
Loading…
Reference in New Issue