bug修复

This commit is contained in:
wuhongjian 2022-10-21 16:45:53 +08:00
parent 44da94a71e
commit 67574732c7
1 changed files with 11 additions and 11 deletions

View File

@ -161,14 +161,14 @@ instance.interceptors.response.use(
console.log('接口error', error)
if (loadingInstance) loadingInstance.close()
const { response, message } = error
const { response, myMessage } = error
if (error.response) {
console.log('接口返回', response)
console.log('接口返回headers', response.headers)
console.log('接口返回REDIRECT', response.headers.redirect)
const { status, data } = response
handleCode(status, data.msg || message, response.headers.redirect)
handleCode(status, data.msg || myMessage, response.headers.redirect)
if (response.headers.token) {
setAccessToken(response.headers.token)
}
@ -179,18 +179,18 @@ instance.interceptors.response.use(
return Promise.reject(error)
} else {
let { message } = error
if (message === 'Network Error') {
message = '后端接口连接异常'
// let { message } = error
if (error.message === 'Network Error') {
error.message = '后端接口连接异常'
}
if (message.includes('timeout')) {
message = '后端接口请求超时'
if (error.message.includes('timeout')) {
error.message = '后端接口请求超时'
}
if (message.includes('Request failed with status code')) {
const code = message.substr(message.length - 3)
message = '后端接口' + code + '异常'
if (error.message.includes('Request failed with status code')) {
const code = error.message.substr(error.message.length - 3)
error.message = '后端接口' + code + '异常'
}
message.error(message || `后端接口未知异常`)
message.error(error.message || `后端接口未知异常`)
return Promise.reject(error)
}
}