From dab59f7624a2fb8d4114bb67b554ff09d91f810c Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期四, 10 四月 2025 13:07:36 +0800 Subject: [PATCH] Merge branch 'radio-frequency-cable' of http://114.132.189.42:9002/r/lims-ruoyi-before into radio-frequency-cable --- src/plugins/download.js | 39 +++++++++++++++++++++++---------------- 1 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/plugins/download.js b/src/plugins/download.js index c0c1878..44698da 100644 --- a/src/plugins/download.js +++ b/src/plugins/download.js @@ -4,6 +4,7 @@ import { getToken } from "@/utils/auth"; import errorCode from "@/utils/errorCode"; import { blobValidate } from "@/utils/ruoyi"; +import Vue from "vue"; const baseURL = process.env.VUE_APP_BASE_API; let downloadLoadingInstance; @@ -80,22 +81,28 @@ downloadLoadingInstance.close(); }); }, - saveAs(text, name, opts) { - if (typeof text === "string") { - // 璺緞涓嬭浇 - saveAs(text, name, opts); - Message.success("鏁版嵁瀵煎嚭鎴愬姛"); - } else { - // 娴佷笅杞� - blobToText(text) - .then((result) => { - Message.error(result.msg); - }) - .catch(() => { - saveAs(text, name, opts); - Message.success("鏁版嵁瀵煎嚭鎴愬姛"); - }); - } + async saveAs(fileUrl, fileName) { + try { + 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 { + this.printErrMsg(response.data); + } + } catch (error) { + Message.error("涓嬭浇澶辫触锛�" + error.message); + } }, async printErrMsg(data) { const resText = await data.text(); -- Gitblit v1.9.3