From 9cf06d77201f75b518133203614c989b7c9f39b2 Mon Sep 17 00:00:00 2001
From: husq <931347610@qq.com>
Date: Tue, 29 Aug 2023 18:12:36 +0800
Subject: [PATCH] 前端跨域配置、项目列表、登录、登出等功能对接、项目列表样式修改
---
src/api/http/request.ts | 74 ++++++++++++++++++------------------
1 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/src/api/http/request.ts b/src/api/http/request.ts
index d03d57e..5505fd6 100644
--- a/src/api/http/request.ts
+++ b/src/api/http/request.ts
@@ -23,7 +23,7 @@
config => {
config.headers[ELocalStorageKey.Token] = getAuthToken()
// config.headers[REQUEST_ID] = uuidv4()
- config.baseURL = CURRENT_CONFIG.baseURL
+ // config.baseURL = CURRENT_CONFIG.baseURL
return config
},
error => {
@@ -33,50 +33,50 @@
instance.interceptors.response.use(
response => {
- console.info('URL: ' + response.config.baseURL + response.config.url, '\nData: ', response.data, '\nResponse:', response)
+ // console.info('URL: ' + response.config.baseURL + response.config.url, '\nData: ', response.data, '\nResponse:', response)
if (response.data.code && !response.data.success) {
message.error(response.data.message)
}
return response
},
err => {
- const requestId = err?.config?.headers && err?.config?.headers[REQUEST_ID]
- if (requestId) {
- console.info(REQUEST_ID, ':', requestId)
- }
- console.info('url: ', err?.config?.url, `【${err?.config?.method}】 \n>>>> err: `, err)
-
- let description = '-'
- if (err.response?.data && err.response.data.message) {
- description = err.response.data.message
- }
- if (err.response?.data && err.response.data.result) {
- description = err.response.data.result.message
- }
- // @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')
- return
- }
- if (err.response?.status !== 200) {
- message.error(`ERROR_CODE: ${err.response?.status}`)
- }
- // if (err.response?.status === 403) {
- // // window.location.href = '/'
+ message.error(`ERROR_INFO: ${err}`)
+ // const requestId = err?.config?.headers && err?.config?.headers[REQUEST_ID]
+ // if (requestId) {
+ // console.info(REQUEST_ID, ':', requestId)
// }
- if (err.response?.status === 401) {
- console.error(err.response)
- const flag: number = Number(localStorage.getItem(ELocalStorageKey.Flag))
- switch (flag) {
- case EUserType.Web:
- router.push(ERouterName.LOGIN)
- break
- case EUserType.Pilot:
- router.push(ERouterName.PILOT)
- break
- }
- }
+ // console.info('url: ', err?.config?.url, `【${err?.config?.method}】 \n>>>> err: `, err)
+ // let description = '-'
+ // if (err.response?.data && err.response.data.message) {
+ // description = err.response.data.message
+ // }
+ // if (err.response?.data && err.response.data.result) {
+ // description = err.response.data.result.message
+ // }
+ // // @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')
+ // return
+ // }
+ // if (err.response?.status !== 200) {
+ // message.error(`ERROR_CODE: ${err.response?.status}`)
+ // }
+ // // if (err.response?.status === 403) {
+ // // // window.location.href = '/'
+ // // }
+ // if (err.response?.status === 401) {
+ // console.error(err.response)
+ // const flag: number = Number(localStorage.getItem(ELocalStorageKey.Flag))
+ // switch (flag) {
+ // case EUserType.Web:
+ // router.push(ERouterName.LOGIN)
+ // break
+ // case EUserType.Pilot:
+ // router.push(ERouterName.PILOT)
+ // break
+ // }
+ // }
return Promise.reject(err)
},
)
--
Gitblit v1.9.3