mirror of
https://gitee.com/fantastic-admin/basic.git
synced 2024-12-04 21:18:16 +08:00
优化拦截器里 toLogin 方法,先清除用户信息状态再跳转登录页
This commit is contained in:
parent
ac02f25e84
commit
65eff15674
@ -5,11 +5,13 @@ import store from '@/store/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const toLogin = () => {
|
||||
router.push({
|
||||
name: 'login',
|
||||
query: {
|
||||
redirect: router.currentRoute.value.path !== '/login' ? router.currentRoute.value.fullPath : undefined
|
||||
}
|
||||
store.dispatch('user/logout').then(() => {
|
||||
router.push({
|
||||
name: 'login',
|
||||
query: {
|
||||
redirect: router.currentRoute.value.path !== '/login' ? router.currentRoute.value.fullPath : undefined
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -34,9 +34,12 @@ const actions = {
|
||||
})
|
||||
},
|
||||
logout({ commit }) {
|
||||
commit('removeUserData')
|
||||
commit('menu/invalidRoutes', null, { root: true })
|
||||
commit('menu/removeRoutes', null, { root: true })
|
||||
return new Promise(resolve => {
|
||||
commit('removeUserData')
|
||||
commit('menu/invalidRoutes', null, { root: true })
|
||||
commit('menu/removeRoutes', null, { root: true })
|
||||
resolve()
|
||||
})
|
||||
},
|
||||
// 获取我的权限
|
||||
getPermissions({ state, commit }) {
|
||||
|
Loading…
Reference in New Issue
Block a user