|
@@ -34,3 +34,17 @@ export function setUUID() {
|
|
|
export function isElectron() {
|
|
|
return typeof nodeRequire != "undefined";
|
|
|
}
|
|
|
+
|
|
|
+// 下载文件
|
|
|
+export async function downloadFileURL(url, name) {
|
|
|
+ const link = document.createElement("a");
|
|
|
+ link.style.display = "none";
|
|
|
+ const fileName = name || url.split("/").pop().split("?")[0];
|
|
|
+ console.log(fileName);
|
|
|
+ link.setAttribute("download", fileName);
|
|
|
+
|
|
|
+ link.href = url;
|
|
|
+ document.body.appendChild(link);
|
|
|
+ link.click();
|
|
|
+ document.body.removeChild(link);
|
|
|
+}
|