Skip to content

Commit 8105a04

Browse files
committed
增加权限校验
1 parent b7b6edb commit 8105a04

File tree

2 files changed

+8
-20
lines changed

2 files changed

+8
-20
lines changed

src/mock/index2.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ mockList.forEach((b) => {
1919
for (let key in b) {
2020
let { state, url, method, result } = b[key]
2121
if (state) {
22-
// Mock.mock(RegExp(url + '??.*'), method, {
23-
// code: 200,
24-
// message: 'success',
25-
// data: result,
26-
// })
27-
Mock.mock(RegExp(url + '??.*'), method, result)
22+
Mock.mock(RegExp(url + '??.*'), method, {
23+
code: 200,
24+
message: 'success',
25+
data: result,
26+
})
27+
// Mock.mock(RegExp(url + '??.*'), method, result)
2828
}
2929
}
3030
})

src/permission.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,11 @@ router.beforeEach(async (to, from, next) => {
3030

3131
if (hasToken) {
3232
if (to.path === '/login') {
33-
/* ↓↓↓↓↓↓↓↓↓↓↓这一段要不要?↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
34-
// if (loadFromSession('userRoutes', []).length < 1) {
35-
// // 路由权限表不存在
36-
// // 退出登录
37-
// await store.dispatch('user/resetToken')
38-
// next(`/login?redirect=${to.path}`)
39-
// return
40-
// }
41-
/* ↑↑↑↑↑↑↑↑↑↑↑这一段要不要?↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑*/
42-
43-
// if is logged in, redirect to the home page
33+
// if is logged in, redirect to the home page // 有token访问login页面,就跳到首页
4434
next({ path: '/', replace: true })
45-
} else if (whiteList.indexOf(to.path !== -1)) {
46-
next()
4735
} else {
4836
// 如果动态路由存在,则直接next
49-
if (store.getters.add_routes.length > 0) {
37+
if (store.getters.roles.length > 0) {
5038
next()
5139
} else {
5240
// 否则,再次尝试动态生成路由

0 commit comments

Comments
 (0)