|
@@ -198,6 +198,25 @@ export function download(fileUrl, fileName) {
|
|
|
};
|
|
|
}
|
|
|
|
|
|
+export function downloadFile(fileUrl, fileName) {
|
|
|
+ fetch(fileUrl)
|
|
|
+ .then(response => response.blob())
|
|
|
+ .then(blob => {
|
|
|
+ const url = window.URL.createObjectURL(blob);
|
|
|
+ const a = document.createElement("a");
|
|
|
+ a.href = url;
|
|
|
+ a.download = fileName;
|
|
|
+ a.style.display = "none";
|
|
|
+ document.body.appendChild(a);
|
|
|
+ a.click();
|
|
|
+ window.URL.revokeObjectURL(url);
|
|
|
+ document.body.removeChild(a);
|
|
|
+ })
|
|
|
+ .catch(error => {
|
|
|
+ console.error("下载文件时发生错误:", error);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
export function get(url, params = {}) {
|
|
|
return new Promise((resolve, reject) => {
|