Skip to content

Commit

Permalink
some change
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Dec 4, 2018
1 parent a336e70 commit 5117b13
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@ router.beforeEach((to, from, next) => {
next({
path: '/'
})
} else {
} else {
if (store.getters.addRouters.length === 0) {
store.dispatch('GetInfo').then(res => { // 拉取user_info
const roleauthname = res.RoleAuthName.split(',')
store.dispatch('GenerateRoutes', { roleauthname }).then(() => { // 根据roles权限生成可访问的路由表
const roleauthname = res.RoleAuthName.split(',')
store.dispatch('GenerateRoutes', {
roleauthname
}).then(() => { // 根据roles权限生成可访问的路由表
router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表
next({ ...to, replace: true }) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
next({ ...to,
replace: true
}) // hack方法 确保addRoutes已完成 ,set the replace: true so the navigation will not leave a history record
})
})
}
else {
} else {
next()
}
}
Expand Down

0 comments on commit 5117b13

Please sign in to comment.