fix(export): harden downloads and CSV encoding

This commit is contained in:
Supra4E8C
2026-02-22 12:42:32 +08:00
Unverified
parent a47c990cf4
commit c75aeecec5
5 changed files with 48 additions and 47 deletions
+22
View File
@@ -0,0 +1,22 @@
export type DownloadBlobOptions = {
filename: string;
blob: Blob;
revokeDelayMs?: number;
};
export function downloadBlob({ filename, blob, revokeDelayMs = 1000 }: DownloadBlobOptions) {
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = filename;
link.rel = 'noopener';
link.style.display = 'none';
document.body.appendChild(link);
link.click();
window.setTimeout(() => {
window.URL.revokeObjectURL(url);
link.remove();
}, revokeDelayMs);
}