diff --git a/src/main.js b/src/main.js index dd759e8d06dc24b3e6e000c83844ab03c643d6aa..c4224f2ce16d2d33bad66be4c6497efc5be4e6cc 100644 --- a/src/main.js +++ b/src/main.js @@ -70,7 +70,6 @@ router.beforeEach((to, from, next) => { }); } } else { // 页é¢ä¸éœ€è¦æƒé™ 直接进入 - console.log(store.getters.roles) if (store.getters.roles.length !== 0) { next(); } else { @@ -87,7 +86,7 @@ router.beforeEach((to, from, next) => { } } } else { - if (whiteList.indexOf(to.path) !== -1) { // 在å…登入白åå•,直接进入 + if (whiteList.indexOf(to.path) !== -1) { // 在å…登录白åå•,直接进入 next() } else { next('/login'); // å¦åˆ™å…¨éƒ¨é‡å®šå‘到登录页 diff --git a/src/store/permission.js b/src/store/permission.js index 7e14b0d23b8aae1cb9176f02713a0840546897cf..7972f2b42a17440f062368195681125c8f1e1397 100644 --- a/src/store/permission.js +++ b/src/store/permission.js @@ -3,8 +3,7 @@ const permission = { permissionRoutes: [] }, init(data) { - const roles = data.roles; - const router = data.router; + const { roles, router } = data; const permissionRoutes = router.filter(v => { if (roles.indexOf('admin') >= 0) return true; if (this.hasPermission(roles, v)) { @@ -22,10 +21,10 @@ const permission = { } return false; }); - this.permissionRoutes = permissionRoutes; + this.state.permissionRoutes = permissionRoutes; }, get() { - return this.permissionRoutes + return this.state.permissionRoutes }, hasPermission(roles, route) { if (route.meta && route.meta.role) {