Skip to content

Commit 624af00

Browse files
committed
refine code
1 parent d820ca9 commit 624af00

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/main.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ router.beforeEach((to, from, next) => {
7070
});
7171
}
7272
} else { // 页面不需要权限 直接进入
73-
console.log(store.getters.roles)
7473
if (store.getters.roles.length !== 0) {
7574
next();
7675
} else {
@@ -87,7 +86,7 @@ router.beforeEach((to, from, next) => {
8786
}
8887
}
8988
} else {
90-
if (whiteList.indexOf(to.path) !== -1) { // 在免登入白名单,直接进入
89+
if (whiteList.indexOf(to.path) !== -1) { // 在免登录白名单,直接进入
9190
next()
9291
} else {
9392
next('/login'); // 否则全部重定向到登录页

src/store/permission.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ const permission = {
33
permissionRoutes: []
44
},
55
init(data) {
6-
const roles = data.roles;
7-
const router = data.router;
6+
const { roles, router } = data;
87
const permissionRoutes = router.filter(v => {
98
if (roles.indexOf('admin') >= 0) return true;
109
if (this.hasPermission(roles, v)) {
@@ -22,10 +21,10 @@ const permission = {
2221
}
2322
return false;
2423
});
25-
this.permissionRoutes = permissionRoutes;
24+
this.state.permissionRoutes = permissionRoutes;
2625
},
2726
get() {
28-
return this.permissionRoutes
27+
return this.state.permissionRoutes
2928
},
3029
hasPermission(roles, route) {
3130
if (route.meta && route.meta.role) {

0 commit comments

Comments
 (0)