权限页面优化
This commit is contained in:
parent
5aa22731c8
commit
0476f25eba
|
@ -52,13 +52,13 @@ router.beforeEach((to, from, next) => {
|
||||||
next({ path: '/' });
|
next({ path: '/' });
|
||||||
} else {
|
} else {
|
||||||
if (to.meta && to.meta.role) { // 判断即将进入的页面是否需要权限
|
if (to.meta && to.meta.role) { // 判断即将进入的页面是否需要权限
|
||||||
if (store.getters.uid) { // 判断当前用户是否已拉去玩info信息
|
if (store.getters.uid) { // 判断当前用户是否已拉取完info信息
|
||||||
if (hasPermission(store.getters.roles, to.meta.role)) { // 判断权限
|
if (hasPermission(store.getters.roles, to.meta.role)) { // 判断权限
|
||||||
next(); // 有权限
|
next(); // 有权限
|
||||||
} else {
|
} else {
|
||||||
next('/401'); // 无权限
|
next({ path: '/401', query: { noGoBack: true } }); // 无权限
|
||||||
}
|
}
|
||||||
} else { // 未拉去info信息
|
} else { // 未拉取info信息
|
||||||
store.dispatch('GetInfo').then(() => { // 拉取info
|
store.dispatch('GetInfo').then(() => { // 拉取info
|
||||||
permission.init({ // 初始化权限
|
permission.init({ // 初始化权限
|
||||||
roles: store.getters.roles,
|
roles: store.getters.roles,
|
||||||
|
@ -67,7 +67,7 @@ router.beforeEach((to, from, next) => {
|
||||||
if (hasPermission(store.getters.roles, to.meta.role)) { // 判断权限
|
if (hasPermission(store.getters.roles, to.meta.role)) { // 判断权限
|
||||||
next();// 有权限
|
next();// 有权限
|
||||||
} else {
|
} else {
|
||||||
next('/401');// 无权限
|
next({ path: '/401', query: { noGoBack: true } }); // 无权限
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
|
|
@ -21,10 +21,7 @@ service.interceptors.request.use(config => {
|
||||||
})
|
})
|
||||||
|
|
||||||
service.interceptors.response.use(
|
service.interceptors.response.use(
|
||||||
response => {
|
response => response,
|
||||||
console.log(response)
|
|
||||||
return response;
|
|
||||||
},
|
|
||||||
error => {
|
error => {
|
||||||
console.log('err' + error);// for debug
|
console.log('err' + error);// for debug
|
||||||
const code = error.response.data;
|
const code = error.response.data;
|
||||||
|
|
|
@ -39,7 +39,11 @@
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
back() {
|
back() {
|
||||||
this.$router.go(-1)
|
if (this.$route.query.noGoBack) {
|
||||||
|
this.$router.push({ path: '/dashboard' });
|
||||||
|
} else {
|
||||||
|
this.$router.go(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue