From 2b2310c50c0a45b2a8fe9964492ee3a96e0f465d Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 22 四月 2025 09:46:45 +0800
Subject: [PATCH] 检验任务调整
---
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