From 1e5ac4c55fcc766352275c6027952bbe2c17fb8d Mon Sep 17 00:00:00 2001
From: 若依 <yzz_ivy@163.com>
Date: 星期三, 08 六月 2022 19:23:36 +0800
Subject: [PATCH] Merge pull request #60 from zzh948498/master

---
 src/utils/request.js |   19 ++++++++-----------
 1 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/src/utils/request.js b/src/utils/request.js
index 46b55b2..79c720c 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -1,15 +1,15 @@
 import axios from 'axios'
 import { ElNotification , ElMessageBox, ElMessage, ElLoading } from 'element-plus'
-import store from '@/store'
 import { getToken } from '@/utils/auth'
 import errorCode from '@/utils/errorCode'
 import { tansParams, blobValidate } from '@/utils/ruoyi'
 import cache from '@/plugins/cache'
 import { saveAs } from 'file-saver'
+import useUserStore from '@/store/modules/user'
 
 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;
         ElMessageBox.confirm('鐧诲綍鐘舵�佸凡杩囨湡锛屾偍鍙互缁х画鐣欏湪璇ラ〉闈紝鎴栬�呴噸鏂扮櫥褰�', '绯荤粺鎻愮ず', {
           confirmButtonText: '閲嶆柊鐧诲綍',
           cancelButtonText: '鍙栨秷',
           type: 'warning'
         }
       ).then(() => {
-        isReloginShow = false;
-        store.dispatch('LogOut').then(() => {
-          // 濡傛灉鏄櫥褰曢〉闈笉闇�瑕侀噸鏂板姞杞�
-          if (window.location.hash.indexOf("#/login") != 0) {
-            location.href = '/index';
-          }
+        isRelogin.show = false;
+        useUserStore().logOut().then(() => {
+          location.href = '/index';
         })
       }).catch(() => {
-        isReloginShow = false;
+        isRelogin.show = false;
       });
     }
       return Promise.reject('鏃犳晥鐨勪細璇濓紝鎴栬�呬細璇濆凡杩囨湡锛岃閲嶆柊鐧诲綍銆�')

--
Gitblit v1.9.3