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) => {
|
const err = (error) => {
|
||||||
|
console.log(err)
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
const data = error.response.data
|
const data = error.response.data
|
||||||
const token = storage.get(ACCESS_TOKEN)
|
const token = storage.get(ACCESS_TOKEN)
|
||||||
@ -65,12 +66,26 @@ pureAxios.interceptors.request.use(config => {
|
|||||||
|
|
||||||
// response interceptor
|
// response interceptor
|
||||||
request.interceptors.response.use((response) => {
|
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
|
return response.data
|
||||||
}, err)
|
}, err)
|
||||||
|
|
||||||
const installer = {
|
const installer = {
|
||||||
vm: {},
|
vm: {},
|
||||||
install (Vue) {
|
install(Vue) {
|
||||||
Vue.use(VueAxios, request)
|
Vue.use(VueAxios, request)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user