From 6b35a453725b34422e5336b456f03b92b963f2d8 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 21 三月 2025 13:35:06 +0800
Subject: [PATCH] Merge branch 'radio-frequency-cable-before' of http://114.132.189.42:9002/r/lims-ruoyi-before into radio-frequency-cable-before

---
 src/plugins/download.js |   52 +++++++++++++++++-----------------------------------
 1 files changed, 17 insertions(+), 35 deletions(-)

diff --git a/src/plugins/download.js b/src/plugins/download.js
index 17bcf96..44698da 100644
--- a/src/plugins/download.js
+++ b/src/plugins/download.js
@@ -81,46 +81,28 @@
         downloadLoadingInstance.close();
       });
   },
-  async saveAs(text, name, opts) {
-    if (typeof text === "string") {
+  async saveAs(fileUrl, fileName) {
       try {
-        let state = /\.(jpg|jpeg|png|gif)$/i.test(text) // 鍒ゆ柇鏄惁涓哄浘鐗�
-        let url1 = ''
-        if (state) {
-          url1 = Vue.prototype.javaApi + '/img/' + text;
-        } else {
-          if (text.startsWith("/word/")) {
-            url1 = Vue.prototype.javaApi + text
-          } else if (text.startsWith("word/")) {
-            url1 = Vue.prototype.javaApi + '/' + text
+          const response = await axios({
+              method: 'get',
+              url: `${Vue.prototype.javaApi}/common/downloadMinio`,
+              params: {
+                  fileUrl,
+                  fileName
+              },
+              responseType: 'blob',
+              headers: { Authorization: 'Bearer ' + getToken() }
+          });
+  
+          if (blobValidate(response.data)) {
+              saveAs(new Blob([response.data]), fileName);
+              Message.success("涓嬭浇鎴愬姛");
           } else {
-            url1 = Vue.prototype.javaApi + '/word/' + text
+              this.printErrMsg(response.data);
           }
-        }
-        // 浣跨敤 fetch 鑾峰彇鏂囦欢
-        const response = await fetch(url1);
-        if (!response.ok) {
-          throw new Error('鏂囦欢涓嬭浇澶辫触: ' + response.statusText);
-        }
-        // 灏嗘枃浠惰浆鎹负 Blob
-        const blob = await response.blob();
-        // 浣跨敤 saveAs 淇濆瓨鏂囦欢
-        saveAs(blob, name);
-        Message.success("鏁版嵁瀵煎嚭鎴愬姛");
       } catch (error) {
-        Message.error(error);
+          Message.error("涓嬭浇澶辫触锛�" + error.message);
       }
-    } else {
-      // 娴佷笅杞�
-      blobToText(text)
-        .then((result) => {
-          Message.error(result.msg);
-        })
-        .catch(() => {
-          saveAs(text, name, opts);
-          Message.success("鏁版嵁瀵煎嚭鎴愬姛");
-        });
-    }
   },
   async printErrMsg(data) {
     const resText = await data.text();

--
Gitblit v1.9.3