From a1d03a0e810219f8353748f6e55699bf2e1a77a6 Mon Sep 17 00:00:00 2001
From: Admin <978517621@qq.com>
Date: 星期一, 15 八月 2022 19:48:10 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/utils/request.ts |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/utils/request.ts b/src/utils/request.ts
index 4abb65d..ef709ab 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -1,7 +1,9 @@
 import axios from 'axios';
 import { ElMessage, ElMessageBox } from 'element-plus';
-import { Session } from '/@/utils/storage';
 import JSONbig from 'json-bigint';
+import Cookies from 'js-cookie';
+import {useLoginApi} from "/@/api/login";
+import { Session, } from '/@/utils/storage';
 
 // var jsonBig = require('json-bigint')({ "storeAsString": true });
 // 配置新建一个 axios 实例
@@ -18,9 +20,9 @@
                 config.data[key] = null;
             }
         }
-        if (Session.get('token')) {
-            (<any>config.headers).common['Authorization'] = `${Session.get('token')}`;
-            (<any>config.headers).common['uid'] = `${Session.get('uid')}`;
+        if (Cookies.get('token')) {
+            (<any>config.headers).common['Authorization'] = `${Cookies.get('token')}`;
+            (<any>config.headers).common['uid'] = `${Cookies.get('uid')}`;
         }
         return config;
     },
@@ -56,10 +58,13 @@
             }, 1000);
         } else if (response.data.code && response.data.code === 'A0215') {
             ElMessage.error('token失效');
-            setTimeout(() => {
-                Session.clear();
-                window.location.href = '/';
-            }, 1000);
+            // logOut;
+            useLoginApi().signOut().then(()=>{
+                setTimeout(() => {
+                    Session.clear();
+                    window.location.href = '/';
+                }, 1000);
+            })
         }
         // if(response.data.code && response.data.code !== '200'){
         return Promise.resolve(response);
@@ -88,7 +93,7 @@
         if (error.message.indexOf('timeout') != -1) {
             ElMessage.error('网络超时');
             setTimeout(() => {
-                Session.clear();
+                // Session.clear();
                 window.location.href = '/';
             }, 1000);
         } else if (error.message == 'Network Error') {

--
Gitblit v1.9.2