🐛 修复导入错误提示重复弹出并丢失业务文案
- axios 拦截器:blob 请求(导入/导出)在业务校验失败时后端返回的是 JSON(Content-Type: application/json),而 axios 在 responseType='blob' 下把响应体解析成 Blob,直接读 res.data.msg 取不到任何字段, status 退回 res.status、文案落到「系统错误」兜底,用户误以为系统崩溃。 现按 Content-Type 判断:JSON 才解析回对象,真·文件流保持原样不动。 - 统一提示出口 notifiedError():弹窗后给 Error 打 _notified 标记, 业务层据此避免同一条错误被弹两次。 - import-excel:拦截器已提示过的错误不再重复 $message.error; >500/网络异常等仍由 resolveErrorMessage 从 Blob 中取 msg 兜底。
This commit is contained in:
@@ -153,7 +153,11 @@ export const handleImportExcel = async (vm, option, column, businessName, onSucc
|
||||
option.onSuccess(res);
|
||||
}
|
||||
} catch (error) {
|
||||
vm.$message.error(await resolveErrorMessage(error));
|
||||
// 拦截器已提示过的错误(如后端 400 返回的业务提示)不再重复弹一次,
|
||||
// 只保留一次清晰的中文提示。
|
||||
if (!error?._notified) {
|
||||
vm.$message.error(await resolveErrorMessage(error));
|
||||
}
|
||||
if (typeof option.onError === 'function') {
|
||||
option.onError(error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user