# up 401 message box
This commit is contained in:
parent
5835498ab3
commit
3d033a55f7
|
@ -1,5 +1,5 @@
|
|||
import axios from 'axios'
|
||||
import { Message } from 'element-ui'
|
||||
import { Message, MessageBox } from 'element-ui'
|
||||
import store from '@/store'
|
||||
import { getToken } from '@/utils/auth'
|
||||
|
||||
|
@ -63,6 +63,18 @@ service.interceptors.response.use(
|
|||
error => {
|
||||
console.log('err' + error)
|
||||
if (error && error.response) {
|
||||
if (error.response.status === 401) {
|
||||
console.log(666)
|
||||
MessageBox.confirm('登录过期你已被登出,可以取消继续留在该页面,或者重新登录', '确定登出', {
|
||||
confirmButtonText: '重新登录',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
store.dispatch('FedLogOut').then(() => {
|
||||
location.reload() // 为了重新实例化vue-router对象 避免bug
|
||||
})
|
||||
})
|
||||
}
|
||||
// check login error response from server api
|
||||
const login_error = error.response.data.non_field_errors
|
||||
if (login_error) {
|
||||
|
|
Loading…
Reference in New Issue