diff --git a/src/api/modules/biz/onboarding.ts b/src/api/modules/biz/onboarding.ts index a231eb1..23fc3a9 100644 --- a/src/api/modules/biz/onboarding.ts +++ b/src/api/modules/biz/onboarding.ts @@ -228,12 +228,28 @@ export const onboardingTaskApi = { }, /** 使用后台登录令牌读取文件流,供入职材料下载和图片预览使用。 */ - downloadFile(fileId: number) { - return fileHttp.get( + async downloadFile(fileId: number) { + const response: any = await fileHttp.get( "download", { id: fileId }, { responseType: "blob", loading: false, cancel: false } ); + + const blob = response?.data; + const contentType = String(response?.headers?.["content-type"] || blob?.type || ""); + if (blob instanceof Blob && contentType.toLowerCase().includes("application/json")) { + try { + const result = JSON.parse(await blob.text()); + throw new Error(result?.msg || "文件下载失败"); + } catch (error) { + if (error instanceof SyntaxError) { + throw new Error("文件下载失败"); + } + throw error; + } + } + + return response; }, create(params: Record) { diff --git a/src/components/SearchForm/index.vue b/src/components/SearchForm/index.vue index b961824..4dee66a 100644 --- a/src/components/SearchForm/index.vue +++ b/src/components/SearchForm/index.vue @@ -1,7 +1,7 @@ + + + + -