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());

View File

@ -53,6 +53,10 @@ export function useFormRules() {
};
}
function createNumberRequiredRule(message: string): App.Global.FormRule {
return { ...createRequiredRule(message), type: 'number' };
}
/** create a rule for confirming the password */
function createConfirmPwdRule(pwd: string | Ref<string> | ComputedRef<string>) {
const confirmPwdRule: App.Global.FormRule[] = [
@ -76,7 +80,8 @@ export function useFormRules() {
formRules,
defaultRequiredRule,
createRequiredRule,
createConfirmPwdRule
createConfirmPwdRule,
createNumberRequiredRule
};
}