From b373b324b677d377abbcbefd7434e4af4d8f64cc Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 10 三月 2025 17:52:09 +0800
Subject: [PATCH] 设备搬迁

---
 src/plugins/download.js |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/src/plugins/download.js b/src/plugins/download.js
index c0c1878..d814fb9 100644
--- a/src/plugins/download.js
+++ b/src/plugins/download.js
@@ -80,11 +80,30 @@
         downloadLoadingInstance.close();
       });
   },
-  saveAs(text, name, opts) {
+  async saveAs(text, name, opts) {
     if (typeof text === "string") {
       // 璺緞涓嬭浇
-      saveAs(text, name, opts);
-      Message.success("鏁版嵁瀵煎嚭鎴愬姛");
+      try {
+        let state = /\.(jpg|jpeg|png|gif)$/i.test(text); // 鍒ゆ柇鏄惁涓哄浘鐗�
+        let url1 = "";
+        if (state) {
+          url1 = Vue.prototype.javaApi + "/img/" + text;
+        } else {
+          url1 = Vue.prototype.javaApi + "/word/" + text;
+        }
+        // 浣跨敤 fetch 鑾峰彇鏂囦欢
+        const response = await fetch(url1);
+        if (!response.ok) {
+          throw new Error("鏂囦欢涓嬭浇澶辫触: " + response.statusText);
+        }
+        // 灏嗘枃浠惰浆鎹负 Blob
+        const blob = await response.blob();
+        // 浣跨敤 saveAs 淇濆瓨鏂囦欢
+        saveAs(blob, filename);
+        Message.success("鏁版嵁瀵煎嚭鎴愬姛");
+      } catch (error) {
+        Message.error(error);
+      }
     } else {
       // 娴佷笅杞�
       blobToText(text)

--
Gitblit v1.9.3