From cc4749faaa9a2bd9660e7b827e46f30a74043028 Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期四, 14 十二月 2023 13:10:40 +0800
Subject: [PATCH] 修改样式

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

diff --git a/src/utils/request.js b/src/utils/request.js
index 39cb883..6b3b29d 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -1,12 +1,12 @@
 import axios from 'axios'
 import { ElNotification , ElMessageBox, ElMessage, ElLoading } from 'element-plus'
-import { getToken } from '@/utils/auth'
+import {getToken, removeToken} 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'
-
+import router from '../router'
 let downloadLoadingInstance;
 // 是否显示重新登录
 export let isRelogin = { show: false };
@@ -17,7 +17,7 @@
   // axios中请求配置有baseURL选项,表示请求URL公共部分
   baseURL: import.meta.env.VITE_APP_BASE_API,
   // 超时
-  timeout: 10000
+  timeout: 60000
 })
 
 // request拦截器
@@ -27,7 +27,7 @@
   // 是否需要防止数据重复提交
   const isRepeatSubmit = (config.headers || {}).repeatSubmit === false
   if (getToken() && !isToken) {
-    config.headers['Authorization'] = 'Bearer ' + getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
+    config.headers['Authorization'] =  getToken() // 让每个请求携带自定义token 请根据实际情况自行修改
   }
   // get请求映射params参数
   if (config.method === 'get' && config.params) {
@@ -76,7 +76,7 @@
     // 未设置状态码则默认成功状态
     const code = res.data.code || 200;
     // 获取错误信息
-    const msg = errorCode[code] || res.data.msg || errorCode['default']
+    const msg = errorCode[code] || res.data.message || errorCode['default']
     // 二进制数据则直接返回
     if (res.request.responseType ===  'blob' || res.request.responseType ===  'arraybuffer') {
       return res.data
@@ -87,9 +87,13 @@
           isRelogin.show = true;
           ElMessageBox.confirm('登录状态已过期,您可以继续留在该页面,或者重新登录', '系统提示', { confirmButtonText: '重新登录', cancelButtonText: '取消', type: 'warning' }).then(() => {
             isRelogin.show = false;
-            useUserStore().logOut().then(() => {
-              location.href = '/index';
-            })
+            removeToken()
+            location.href = '/homePage';
+            // useUserStore().logOut().then(() => {
+            //   // router.push('/homePage')
+            //
+            //   location.href = '/homePage';
+            // })
           }).catch(() => {
             isRelogin.show = false
           });

--
Gitblit v1.9.2