plus-ui/src/utils/save.ts
2026-03-16 19:20:22 +08:00

14 lines
357 B
TypeScript

export function saveBlob(blob: Blob, fileName: string) {
const downloadLink = document.createElement('a');
const objectUrl = URL.createObjectURL(blob);
downloadLink.href = objectUrl;
downloadLink.download = fileName;
downloadLink.rel = 'noopener';
downloadLink.click();
setTimeout(() => {
URL.revokeObjectURL(objectUrl);
}, 40_000);
}