This commit is contained in:
Pan 2017-05-17 17:59:13 +08:00
parent 523a9b3de3
commit 6508b1cc3d
2 changed files with 2 additions and 3 deletions

View File

@ -47,8 +47,8 @@ router.beforeEach((to, from, next) => {
if (to.path === '/login') { if (to.path === '/login') {
next({ path: '/' }); next({ path: '/' });
} else { } else {
if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完info信息 if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
store.dispatch('GetInfo').then(res => { // 拉取info store.dispatch('GetInfo').then(res => { // 拉取user_info
const roles = res.data.role; const roles = res.data.role;
store.dispatch('GenerateRoutes', { roles }).then(() => { // 生成可访问的路由表 store.dispatch('GenerateRoutes', { roles }).then(() => { // 生成可访问的路由表
router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表 router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表

View File

@ -22,7 +22,6 @@ const permission = {
}, },
actions: { actions: {
// s
GenerateRoutes({ commit }, data) { GenerateRoutes({ commit }, data) {
return new Promise(resolve => { return new Promise(resolve => {
const { roles } = data; const { roles } = data;