mirror of
https://github.com/continew-org/continew-admin-ui.git
synced 2025-09-08 22:57:11 +08:00
fix: 修复导出文件后台抛出异常仍继续下载文件,不进行通知提示 (#53)
This commit is contained in:
@@ -65,7 +65,24 @@ http.interceptors.response.use(
|
||||
const { data } = response
|
||||
const { success, code, msg } = data
|
||||
|
||||
if (response.request.responseType === 'blob' || success) {
|
||||
if (response.request.responseType === 'blob') {
|
||||
const contentType = data.type
|
||||
if (contentType.startsWith('application/json')) {
|
||||
const reader = new FileReader()
|
||||
reader.readAsText(data)
|
||||
reader.onload = () => {
|
||||
const { success, msg } = JSON.parse(reader.result as string)
|
||||
if (!success) {
|
||||
handleError(msg)
|
||||
}
|
||||
}
|
||||
return Promise.reject(msg)
|
||||
} else {
|
||||
return response
|
||||
}
|
||||
}
|
||||
|
||||
if (success) {
|
||||
return response
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user