From aec00ecc093be803860c8675cbe1c4c776a7cb4e Mon Sep 17 00:00:00 2001
From: GuLiMmo <2820890765@qq.com>
Date: Tue, 19 Mar 2024 17:49:21 +0800
Subject: [PATCH] update: 新建航线、事件编辑、kmz文件问题修改

---
 src/api/http/request.ts |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/api/http/request.ts b/src/api/http/request.ts
index 086cd00..b66b2a9 100644
--- a/src/api/http/request.ts
+++ b/src/api/http/request.ts
@@ -1,3 +1,4 @@
+
 import axios from 'axios'
 import { uuidv4 } from '/@/utils/uuid'
 import { CURRENT_CONFIG } from './config'
@@ -6,23 +7,24 @@
 import { ELocalStorageKey, ERouterName, EUserType } from '/@/types/enums'
 export * from './type'
 
+const { baseUrl: { apiBaseUrl } } = window.globalApiConfig
+
 const REQUEST_ID = 'X-Request-Id'
 function getAuthToken () {
   return localStorage.getItem(ELocalStorageKey.Token)
 }
-
 const instance = axios.create({
   // withCredentials: true,
   headers: {
     'Content-Type': 'application/json',
   },
+  baseURL: apiBaseUrl || import.meta.env.VITE_BASE_API,
   // timeout: 12000,
 })
 
 instance.interceptors.request.use(
   config => {
-    config.headers[ELocalStorageKey.Token] = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ3b3Jrc3BhY2VfaWQiOiJlM2RlYTBmNS0zN2YyLTRkNzktYWU1OC00OTBhZjMyMjgwNjkiLCJzdWIiOiJDbG91ZEFwaVNhbXBsZSIsInVzZXJfdHlwZSI6IjEiLCJuYmYiOjE2OTQ2MDMwOTQsImxvZyI6IkxvZ2dlcltjb20uZGppLnNhbXBsZS5jb21tb24ubW9kZWwuQ3VzdG9tQ2xhaW1dIiwiaXNzIjoiREpJIiwiaWQiOiJhMTU1OWU3Yy04ZGQ4LTQ3ODAtYjk1Mi0xMDBjYzQ3OTdkYTIiLCJleHAiOjE3ODEwMDMwOTQsImlhdCI6MTY5NDYwMzA5NCwidXNlcm5hbWUiOiJhZG1pblBDIn0.EuYY3zwbTVdJuE1_3x_ZbrBT83JcbaC_dLaIIwm795k'
-    config.baseURL = CURRENT_CONFIG.baseURL
+    config.headers[ELocalStorageKey.Token] = localStorage.getItem(ELocalStorageKey.Token)
     // config.headers[REQUEST_ID] = uuidv4()
     // config.baseURL = CURRENT_CONFIG.baseURL
     return config
@@ -35,7 +37,10 @@
 instance.interceptors.response.use(
   response => {
     // console.info('URL: ' + response.config.baseURL + response.config.url, '\nData: ', response.data, '\nResponse:', response)
-
+    const whiteList = ['/manage/api/v1/live/streams/stop']
+    if (whiteList.includes(response.config.url)) {
+      return Promise.reject(response.data)
+    }
     // 处理消息返回
     // if (response.data.code && !response.data.success) {
     //   message.error(response.data.message)
@@ -61,11 +66,11 @@
     }
     // @See: https://github.com/axios/axios/issues/383
     if (!err.response || !err.response.status) {
-      message.error('The network is abnormal, please check the backend service and try again')
+      message.error('网络异常,请检查后端服务后重试')
       return
     }
     if (err.response?.status !== 200) {
-      message.error(`ERROR_CODE: ${err.response?.status}`)
+      message.error(`错误码: ${err.response?.status}`)
     }
     // if (err.response?.status === 403) {
     //   // window.location.href = '/'

--
Gitblit v1.9.3