refactor(admin): 用已安装的 file-saver/fast-deep-equal 替代手写下载与 JSON 比较

This commit is contained in:
2026-08-08 17:11:10 +08:00
parent 01cceea237
commit dab28f85e8
6 changed files with 16 additions and 43 deletions

View File

@@ -35,6 +35,7 @@ import {
importErrorReportUrl,
previewImportStep,
} from '../../api/imports';
import { saveAs } from 'file-saver';
import {
STEP_FIELDS,
type ImportPreviewResult,
@@ -101,12 +102,7 @@ async function downloadErrorReport(runId: string, stepKey?: ImportStepKey): Prom
});
if (!response.ok) throw new Error('错误报告下载失败');
const blob = await response.blob();
const url = URL.createObjectURL(blob);
const anchor = document.createElement('a');
anchor.href = url;
anchor.download = `导入错误报告-${runId.slice(0, 8)}.csv`;
anchor.click();
window.setTimeout(() => URL.revokeObjectURL(url), 60_000);
saveAs(blob, `导入错误报告-${runId.slice(0, 8)}.csv`);
}
export const ImportWizardModal: React.FC<ImportWizardModalProps> = ({