Files
lilishop-ui/manager/src/utils/downloadBlob.js
2026-06-07 16:57:23 +08:00

16 lines
418 B
JavaScript

/**
* 触发浏览器下载 blob 响应
*/
export function downloadBlob(blob, filename) {
if (!blob) return;
const link = document.createElement("a");
link.style.display = "none";
const url = window.URL.createObjectURL(new Blob([blob]));
link.href = url;
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
}