mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-ui.git
synced 2026-11-08 01:48:56 +08:00
优化财务相关功能
This commit is contained in:
15
manager/src/utils/downloadBlob.js
Normal file
15
manager/src/utils/downloadBlob.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 触发浏览器下载 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);
|
||||
}
|
||||
Reference in New Issue
Block a user