diff --git a/frontend/src/pages/DataAnnotation/Home/ExportAnnotationDialog.tsx b/frontend/src/pages/DataAnnotation/Home/ExportAnnotationDialog.tsx index ccc6df3..05f8506 100644 --- a/frontend/src/pages/DataAnnotation/Home/ExportAnnotationDialog.tsx +++ b/frontend/src/pages/DataAnnotation/Home/ExportAnnotationDialog.tsx @@ -106,13 +106,6 @@ export default function ExportAnnotationDialog({ const values = await form.validateFields(); setExporting(true); - const blob = await downloadAnnotationsUsingGet( - projectId, - values.format, - values.onlyAnnotated, - values.includeData - ); - // 获取文件名 const formatExt: Record = { json: "json", @@ -124,15 +117,14 @@ export default function ExportAnnotationDialog({ const ext = formatExt[values.format as ExportFormat] || "json"; const filename = `${projectName}_annotations.${ext}`; - // 下载文件 - const url = window.URL.createObjectURL(blob as Blob); - const a = document.createElement("a"); - a.href = url; - a.download = filename; - document.body.appendChild(a); - a.click(); - window.URL.revokeObjectURL(url); - document.body.removeChild(a); + // 下载文件(download函数内部已处理下载逻辑) + await downloadAnnotationsUsingGet( + projectId, + values.format, + values.onlyAnnotated, + values.includeData, + filename + ); message.success("导出成功"); onClose(); diff --git a/frontend/src/pages/DataAnnotation/annotation.api.ts b/frontend/src/pages/DataAnnotation/annotation.api.ts index 5acf0a6..9adb01a 100644 --- a/frontend/src/pages/DataAnnotation/annotation.api.ts +++ b/frontend/src/pages/DataAnnotation/annotation.api.ts @@ -109,12 +109,13 @@ export function downloadAnnotationsUsingGet( projectId: string, format: ExportFormat = "json", onlyAnnotated: boolean = true, - includeData: boolean = false + includeData: boolean = false, + filename?: string ) { const params = new URLSearchParams({ format, only_annotated: String(onlyAnnotated), include_data: String(includeData), }); - return download(`/api/annotation/export/projects/${projectId}/download?${params.toString()}`); + return download(`/api/annotation/export/projects/${projectId}/download?${params.toString()}`, null, filename); }