From ce34d17d8f2ee2ddb4d83dd5f8b4235471f074e4 Mon Sep 17 00:00:00 2001
From: odc.xiaohui <xiaohui@Q1>
Date: 星期一, 04 十二月 2023 17:43:12 +0800
Subject: [PATCH] 修改视频专网

---
 src/utils/request.ts |   45 ++++++++++++++++++++++++++++-----------------
 1 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/src/utils/request.ts b/src/utils/request.ts
index ed67713..22fd82d 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -10,6 +10,8 @@
 import { getLanguage } from '@/lang';
 import { encryptBase64, encryptWithAes, generateAesKey } from '@/utils/crypto';
 import { encrypt } from '@/utils/jsencrypt';
+import router from "@/router";
+import { ElLoading, ElMessage, ElNotification } from "element-plus";
 
 let downloadLoadingInstance: LoadingInstance;
 // 鏄惁鏄剧ず閲嶆柊鐧诲綍
@@ -93,9 +95,10 @@
   }
 );
 
+
 // 鍝嶅簲鎷︽埅鍣�
 service.interceptors.response.use(
-  (res: AxiosResponse) => {
+  async (res: AxiosResponse) => {
     // 鏈缃姸鎬佺爜鍒欓粯璁ゆ垚鍔熺姸鎬�
     const code = res.data.code || HttpStatus.SUCCESS;
     // 鑾峰彇閿欒淇℃伅
@@ -105,23 +108,31 @@
       return res.data;
     }
     if (code === 401) {
+      debugger
+      const userStore = useUserStore();
+      await userStore.logout()
+
+      console.log(code, 'code==============');
+      await router.push({ path: '/login' });
       // prettier-ignore
-      if (!isRelogin.show) {
-        isRelogin.show = true;
-        ElMessageBox.confirm('鐧诲綍鐘舵�佸凡杩囨湡锛屾偍鍙互缁х画鐣欏湪璇ラ〉闈紝鎴栬�呴噸鏂扮櫥褰�', '绯荤粺鎻愮ず', {
-          confirmButtonText: '閲嶆柊鐧诲綍',
-          cancelButtonText: '鍙栨秷',
-          type: 'warning'
-        }).then(() => {
-          isRelogin.show = false;
-          useUserStore().logout().then(() => {
-              location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index';
-            });
-        }).catch(() => {
-          isRelogin.show = false;
-        });
-      }
-      return Promise.reject('鏃犳晥鐨勪細璇濓紝鎴栬�呬細璇濆凡杩囨湡锛岃閲嶆柊鐧诲綍銆�');
+      // if (!isRelogin.show) {
+      //   // isRelogin.show = true;
+      //   isRelogin.show = true;
+      //   ElMessageBox.confirm('鐧诲綍鐘舵�佸凡杩囨湡锛屾偍鍙互缁х画鐣欏湪璇ラ〉闈紝鎴栬�呴噸鏂扮櫥褰�', '绯荤粺鎻愮ず', {
+      //     confirmButtonText: '閲嶆柊鐧诲綍',
+      //     cancelButtonText: '鍙栨秷',
+      //     type: 'warning'
+      //   }).then(() => {
+      //     isRelogin.show = false;
+      //     useUserStore().logout().then(() => {
+      //         location.href = import.meta.env.VITE_APP_CONTEXT_PATH + 'index';
+      //       });
+      //   }).catch(() => {
+      //     isRelogin.show = false;
+      //   });
+      // }
+      // return Promise.reject('鏃犳晥鐨勪細璇濓紝鎴栬�呬細璇濆凡杩囨湡锛岃閲嶆柊鐧诲綍銆�');
+      return
     } else if (code === HttpStatus.SERVER_ERROR) {
       console.log(msg);
       ElMessage({ message: msg, type: 'error' });

--
Gitblit v1.8.0