From 3d04f62e6c9124e2d37b5d09191a02fc6390d16f Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期五, 13 十月 2023 17:07:10 +0800
Subject: [PATCH] bug修复

---
 src/common/untils/request.js |   27 ++++++++-------------------
 1 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/src/common/untils/request.js b/src/common/untils/request.js
index 4939506..66ec3c5 100644
--- a/src/common/untils/request.js
+++ b/src/common/untils/request.js
@@ -1,6 +1,5 @@
 import axios from "axios"
 import { Message } from "element-ui"
-import Cookies from 'js-cookie'
 
 // import router from '@/router'
 
@@ -15,7 +14,7 @@
         prod:`//${window.location.hostname}:9080`,
         test:`//192.168.20.119:9080`,
         // 鎯宠烦鍒版湰鍦板惎鍔ㄧ殑鐧诲綍椤电殑璇濋渶瑕佹妸dev鏀规垚浣犳湰鍦伴」鐩矾寰�
-        dev: `//192.168.20.119:9080`
+        dev: `//192.168.20.124:8081`
     }
 
     if (location.href.includes('192.168.20.119')) {
@@ -27,24 +26,14 @@
     }
 }
 
-function getToken(){
-    const localStorageToken = localStorage.getItem('token')
-    const cookieToken = Cookies.get("token")
-    if (localStorageToken){
-        return  localStorageToken
-    }else if ( cookieToken) {
-        localStorage.setItem('token',cookieToken)
-        return cookieToken
-    }else {
-        return ''
-    }
-}
-
 /* //POST浼犲弬搴忓垪鍖�(娣诲姞璇锋眰鎷︽埅鍣�) */
 Axios.interceptors.request.use(
   (config) => {
     // 鑻ユ槸鏈夊仛閴存潈token , 灏辩粰澶撮儴甯︿笂token
-    let token = getToken()
+    let token = document.cookie.replace(
+        /(?:(?:^|.*;\s*)token\s*\=\s*([^;]*).*$)|^.*$/,
+        "$1",
+    );
     if (token) {
       config.headers.Authorization = "Bearer " + token;
     }
@@ -66,9 +55,9 @@
       console.log("瀹㈡埛鍚嶇О閲嶅")
       return res
     } else if([2012,2013,2014,2015].includes(res.data.code)){
-        //   JWT閴存潈澶辨晥 璺宠浆鍒扮櫥褰曢〉
-        window.location = getApsPage()+'/login'
-        return Promise.reject(res.data)
+      //   JWT閴存潈澶辨晥 璺宠浆鍒扮櫥褰曢〉
+      window.location = getApsPage()+'/login'
+      return Promise.reject(res.data)
     } else {
       Message({
         message: res.data.msg,

--
Gitblit v1.8.0