fix(knowledgeBase): 知识库下载文件命名不对
This commit is contained in:
1 parent
dabf140e41
commit
a768eb9024
13 files changed
+299
-28
No files matched your search
@@ -1,9 +1,11 @@
|
||||
/**
|
||||
* shared/api/client.ts
|
||||
* 跨域 HTTP 客户端:envelope 解析、BusinessError、requestJson、requestBlob。
|
||||
* 依赖:auth、vue-i18n、shared/utils/download(Content-Disposition 文件名)。
|
||||
* 所有 feature API 层应通过此模块发起请求;二进制下载走 requestBlob,失败仍为 BusinessError。
|
||||
*/
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { parseContentDispositionFilename } from '@/shared/utils/download';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
export interface ApiSuccessEnvelope<T> {
|
||||
@@ -217,11 +219,9 @@ export async function requestBlob(url: string, init?: RequestInit): Promise<Blob
|
||||
}
|
||||
|
||||
const blob = await res.blob();
|
||||
const disposition = res.headers.get('Content-Disposition') || '';
|
||||
const filename = disposition.match(/filename\*?=(?:UTF-8''|")?([^";]+)"?/i)?.[1];
|
||||
return {
|
||||
blob,
|
||||
filename: filename ? decodeURIComponent(filename) : undefined,
|
||||
filename: parseContentDispositionFilename(res.headers.get('Content-Disposition')),
|
||||
requestId: requestIdHeader,
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user