|
|
@ -78,37 +78,24 @@ service.interceptors.response.use(res => { |
|
|
|
if (code === 401) { |
|
|
|
if (code === 401) { |
|
|
|
if (!isRelogin.show) { |
|
|
|
if (!isRelogin.show) { |
|
|
|
isRelogin.show = true; |
|
|
|
isRelogin.show = true; |
|
|
|
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { |
|
|
|
MessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => { |
|
|
|
confirmButtonText: '重新登录', |
|
|
|
isRelogin.show = false; |
|
|
|
cancelButtonText: '取消', |
|
|
|
store.dispatch('LogOut').then(() => { |
|
|
|
type: 'warning' |
|
|
|
location.href = '/index'; |
|
|
|
} |
|
|
|
}) |
|
|
|
).then(() => { |
|
|
|
|
|
|
|
isRelogin.show = false; |
|
|
|
|
|
|
|
store.dispatch('LogOut').then(() => { |
|
|
|
|
|
|
|
location.href = '/index'; |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}).catch(() => { |
|
|
|
}).catch(() => { |
|
|
|
isRelogin.show = false; |
|
|
|
isRelogin.show = false; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
return Promise.reject('无效的会话,或者会话已过期,请重新登录。') |
|
|
|
return Promise.reject('无效的会话,或者会话已过期,请重新登录。') |
|
|
|
} else if (code === 500) { |
|
|
|
} else if (code === 500) { |
|
|
|
Message({ |
|
|
|
Message({ message: msg, type: 'error' }) |
|
|
|
message: msg, |
|
|
|
|
|
|
|
type: 'error' |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return Promise.reject(new Error(msg)) |
|
|
|
return Promise.reject(new Error(msg)) |
|
|
|
} else if (code === 601) { |
|
|
|
} else if (code === 601) { |
|
|
|
Message({ |
|
|
|
Message({ message: msg, type: 'warning' }) |
|
|
|
message: msg, |
|
|
|
|
|
|
|
type: 'warning' |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return Promise.reject('error') |
|
|
|
return Promise.reject('error') |
|
|
|
} else if (code !== 200) { |
|
|
|
} else if (code !== 200) { |
|
|
|
Notification.error({ |
|
|
|
Notification.error({ title: msg }) |
|
|
|
title: msg |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return Promise.reject('error') |
|
|
|
return Promise.reject('error') |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
return res.data |
|
|
|
return res.data |
|
|
@ -119,18 +106,12 @@ service.interceptors.response.use(res => { |
|
|
|
let { message } = error; |
|
|
|
let { message } = error; |
|
|
|
if (message == "Network Error") { |
|
|
|
if (message == "Network Error") { |
|
|
|
message = "后端接口连接异常"; |
|
|
|
message = "后端接口连接异常"; |
|
|
|
} |
|
|
|
} else if (message.includes("timeout")) { |
|
|
|
else if (message.includes("timeout")) { |
|
|
|
|
|
|
|
message = "系统接口请求超时"; |
|
|
|
message = "系统接口请求超时"; |
|
|
|
} |
|
|
|
} else if (message.includes("Request failed with status code")) { |
|
|
|
else if (message.includes("Request failed with status code")) { |
|
|
|
|
|
|
|
message = "系统接口" + message.substr(message.length - 3) + "异常"; |
|
|
|
message = "系统接口" + message.substr(message.length - 3) + "异常"; |
|
|
|
} |
|
|
|
} |
|
|
|
Message({ |
|
|
|
Message({ message: message, type: 'error', duration: 5 * 1000 }) |
|
|
|
message: message, |
|
|
|
|
|
|
|
type: 'error', |
|
|
|
|
|
|
|
duration: 5 * 1000 |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return Promise.reject(error) |
|
|
|
return Promise.reject(error) |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|