Skip to content

Commit 576e377

Browse files
committed
fix: next to login when token is not right
1 parent 9788cda commit 576e377

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/permission.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import router from './router'
22
import store from './store'
33
import NProgress from 'nprogress' // Progress 进度条
44
import 'nprogress/nprogress.css'// Progress 进度条样式
5+
import { Message } from 'element-ui'
56
import { getToken } from '@/utils/auth' // 验权
67

78
const whiteList = ['/login'] // 不重定向白名单
@@ -14,6 +15,11 @@ router.beforeEach((to, from, next) => {
1415
if (store.getters.roles.length === 0) {
1516
store.dispatch('GetInfo').then(res => { // 拉取用户信息
1617
next()
18+
}).catch(() => {
19+
store.dispatch('FedLogOut').then(() => {
20+
Message.error('验证失败,请重新登录')
21+
next({ path: '/login' })
22+
})
1723
})
1824
} else {
1925
next()

0 commit comments

Comments
 (0)