From 86d16d070d50c02ff9d2f1999c44e6e1ee591a1e Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: 星期一, 19 九月 2022 13:09:21 +0800
Subject: [PATCH] 通用下载方法新增config配置选项(I5PNXE)

---
 ruoyi-ui/src/utils/request.js |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/ruoyi-ui/src/utils/request.js b/ruoyi-ui/src/utils/request.js
index 107a28d..1080f52 100644
--- a/ruoyi-ui/src/utils/request.js
+++ b/ruoyi-ui/src/utils/request.js
@@ -9,7 +9,7 @@
 
 let downloadLoadingInstance;
 // 鏄惁鏄剧ず閲嶆柊鐧诲綍
-let isReloginShow;
+export let isRelogin = { show: false };
 
 axios.defaults.headers['Content-Type'] = 'application/json;charset=utf-8'
 // 鍒涘缓axios瀹炰緥
@@ -76,23 +76,20 @@
       return res.data
     }
     if (code === 401) {
-      if (!isReloginShow) {
-        isReloginShow = true;
+      if (!isRelogin.show) {
+        isRelogin.show = true;
         MessageBox.confirm('鐧诲綍鐘舵�佸凡杩囨湡锛屾偍鍙互缁х画鐣欏湪璇ラ〉闈紝鎴栬�呴噸鏂扮櫥褰�', '绯荤粺鎻愮ず', {
           confirmButtonText: '閲嶆柊鐧诲綍',
           cancelButtonText: '鍙栨秷',
           type: 'warning'
         }
       ).then(() => {
-        isReloginShow = false;
+        isRelogin.show = false;
         store.dispatch('LogOut').then(() => {
-          // 濡傛灉鏄櫥褰曢〉闈笉闇�瑕侀噸鏂板姞杞�
-          if (window.location.hash.indexOf("#/login") != 0) {
-            location.href = '/index';
-          }
+          location.href = '/index';
         })
       }).catch(() => {
-        isReloginShow = false;
+        isRelogin.show = false;
       });
     }
       return Promise.reject('鏃犳晥鐨勪細璇濓紝鎴栬�呬細璇濆凡杩囨湡锛岃閲嶆柊鐧诲綍銆�')
@@ -133,12 +130,13 @@
 )
 
 // 閫氱敤涓嬭浇鏂规硶
-export function download(url, params, filename) {
+export function download(url, params, filename, config) {
   downloadLoadingInstance = Loading.service({ text: "姝e湪涓嬭浇鏁版嵁锛岃绋嶅��", spinner: "el-icon-loading", background: "rgba(0, 0, 0, 0.7)", })
   return service.post(url, params, {
     transformRequest: [(params) => { return tansParams(params) }],
     headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
-    responseType: 'blob'
+    responseType: 'blob',
+    ...config
   }).then(async (data) => {
     const isLogin = await blobValidate(data);
     if (isLogin) {

--
Gitblit v1.9.3