|
@@ -25,7 +25,7 @@ axiosRetry(request, {
|
|
|
retryDelay: () => 300,
|
|
|
shouldResetTimeout: true,
|
|
|
retryCondition(error) {
|
|
|
- return (error?.response?.status || '').toString().startsWith('5')
|
|
|
+ return error?.response?.status === 502
|
|
|
},
|
|
|
})
|
|
|
|
|
@@ -62,12 +62,12 @@ request.interceptors.response.use(
|
|
|
(response) => {
|
|
|
useMainStore().serverTime = new Date(response.headers?.['date']).getTime()
|
|
|
useMainStore().diffTime = useMainStore().serverTime - Date.now()
|
|
|
- if (response.data.hasError && whiteList.indexOf(response.config.url) == -1) {
|
|
|
+ if (response?.data?.hasError && whiteList.indexOf(response?.config?.url) == -1) {
|
|
|
const errMsg = response.data?.failRecords.map((v: any) => [v.msg, v.lineNum].join('--'))?.join('\n')
|
|
|
toastError(errMsg)
|
|
|
return Promise.reject(response.data)
|
|
|
}
|
|
|
- if (response.config.download && response.config.responseType === 'blob') {
|
|
|
+ if (response?.config?.download && response?.config?.responseType === 'blob') {
|
|
|
downloadBlob(response.data, extractFileName(response.headers?.['content-disposition'] as string))
|
|
|
}
|
|
|
return response.data
|
|
@@ -89,9 +89,7 @@ request.interceptors.response.use(
|
|
|
return Promise.reject(error)
|
|
|
}
|
|
|
let msg = ''
|
|
|
- if ((error?.response?.status || '').toString().startsWith('5')) {
|
|
|
- msg = '服务器异常,请联系管理员'
|
|
|
- }
|
|
|
+
|
|
|
if (error.config?.responseType === 'blob') {
|
|
|
try {
|
|
|
const e = JSON.parse(await error?.response?.data?.text())
|
|
@@ -102,7 +100,15 @@ request.interceptors.response.use(
|
|
|
}
|
|
|
console.log('msg', msg)
|
|
|
if (!msg) {
|
|
|
- msg = error?.response?.data?.message || error.message || error.code || error.name
|
|
|
+ if (error?.response?.data?.message) {
|
|
|
+ msg = error?.response?.data?.message
|
|
|
+ } else {
|
|
|
+ if (error?.response?.status === 502) {
|
|
|
+ msg = '服务器异常,请联系管理员'
|
|
|
+ } else {
|
|
|
+ msg = error.message || error.code || error.name
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
toastError(msg)
|
|
|
} else {
|