fix: 修复代码生成异常提示

This commit is contained in:
xlsea
2024-11-04 11:16:53 +08:00
parent d5479c2f68
commit df5dd24c29
10 changed files with 83 additions and 65 deletions

View File

@ -88,7 +88,14 @@ export function useDownload() {
Clientid: clientId!
}
})
.then(async response => response.blob())
.then(async response => {
if (response.headers.get('Content-Type')?.includes('application/json')) {
const res = await response.json();
const code = res.code as CommonType.ErrorCode;
throw new Error(errorCodeRecord[code] || res.msg || errorCodeRecord.default);
}
return response.blob();
})
.then(data => downloadByData(data, fileName, 'application/zip'))
.catch(err => window.$message?.error(err.message))
.finally(() => window.$loading?.endLoading());