|
@@ -46,6 +46,23 @@ service.interceptors.response.use(
|
|
|
const code = response.data.code
|
|
|
|
|
|
if (code === 401) {
|
|
|
+ store.dispatch('user/resetToken')
|
|
|
+ if (URL.indexOf('login') !== -1) {
|
|
|
+ location.reload() // 为了重新实例化vue-router对象 避免bug
|
|
|
+ } else {
|
|
|
+ MessageBox.confirm(
|
|
|
+ '登录状态已过期,您可以继续留在该页面,或者重新登录',
|
|
|
+ '系统提示',
|
|
|
+ {
|
|
|
+ confirmButtonText: '重新登录',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }
|
|
|
+ ).then(() => {
|
|
|
+ location.reload() // 为了重新实例化vue-router对象 避免bug
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else if (code === 6401) {
|
|
|
store.dispatch('user/resetToken')
|
|
|
MessageBox.confirm(
|
|
|
'登录状态已过期,您可以继续留在该页面,或者重新登录',
|
|
@@ -58,6 +75,7 @@ service.interceptors.response.use(
|
|
|
).then(() => {
|
|
|
location.reload() // 为了重新实例化vue-router对象 避免bug
|
|
|
})
|
|
|
+ return false
|
|
|
} else if (code === 400) {
|
|
|
Message({
|
|
|
message: response.data.msg,
|