mirror of
https://gitee.com/elegant_wings/dbd-meeting-html.git
synced 2025-06-21 06:49:37 +08:00
加入登录失败拦截
This commit is contained in:
parent
26e919ca47
commit
441a813e12
@ -18,6 +18,7 @@ export const pureAxios = axios.create({
|
||||
})
|
||||
|
||||
const err = (error) => {
|
||||
console.log(err)
|
||||
if (error.response) {
|
||||
const data = error.response.data
|
||||
const token = storage.get(ACCESS_TOKEN)
|
||||
@ -65,6 +66,20 @@ pureAxios.interceptors.request.use(config => {
|
||||
|
||||
// response interceptor
|
||||
request.interceptors.response.use((response) => {
|
||||
const _code = response.data.code
|
||||
if (_code === 401) {
|
||||
// 登录失效
|
||||
notification.error({
|
||||
message: '错误',
|
||||
description: '请求用户信息失败,请重新登录!',
|
||||
key: 'logout'
|
||||
})
|
||||
store.dispatch('Logout').then(() => {
|
||||
setTimeout(() => {
|
||||
window.location.reload()
|
||||
}, 1500)
|
||||
})
|
||||
}
|
||||
return response.data
|
||||
}, err)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user