权限页面优化

This commit is contained in:
Pan
2017-05-15 18:42:25 +08:00
parent 5aa22731c8
commit 0476f25eba
3 changed files with 10 additions and 9 deletions

View File

@@ -52,13 +52,13 @@ router.beforeEach((to, from, next) => {
next({ path: '/' });
} else {
if (to.meta && to.meta.role) { // 判断即将进入的页面是否需要权限
if (store.getters.uid) { // 判断当前用户是否已拉去玩info信息
if (store.getters.uid) { // 判断当前用户是否已拉取完info信息
if (hasPermission(store.getters.roles, to.meta.role)) { // 判断权限
next(); // 有权限
} else {
next('/401'); // 无权限
next({ path: '/401', query: { noGoBack: true } }); // 无权限
}
} else { // 未拉info信息
} else { // 未拉info信息
store.dispatch('GetInfo').then(() => { // 拉取info
permission.init({ // 初始化权限
roles: store.getters.roles,
@@ -67,7 +67,7 @@ router.beforeEach((to, from, next) => {
if (hasPermission(store.getters.roles, to.meta.role)) { // 判断权限
next();// 有权限
} else {
next('/401');// 无权限
next({ path: '/401', query: { noGoBack: true } }); // 无权限
}
}).catch(err => {
console.log(err);