权限页面优化

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);

View file

@ -21,10 +21,7 @@ service.interceptors.request.use(config => {
})
service.interceptors.response.use(
response => {
console.log(response)
return response;
},
response => response,
error => {
console.log('err' + error);// for debug
const code = error.response.data;

View file

@ -39,7 +39,11 @@
},
methods: {
back() {
this.$router.go(-1)
if (this.$route.query.noGoBack) {
this.$router.push({ path: '/dashboard' });
} else {
this.$router.go(-1);
}
}
}
};