提交 0476f25e 编写于 作者: P Pan

权限页面优化

上级 5aa22731
......@@ -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);
......
......@@ -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;
......
......@@ -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);
}
}
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册