|
@@ -3,7 +3,7 @@
|
|
|
*/
|
|
|
import { userStore } from '@/store/mobx'
|
|
|
import { PendingType, ResponseData } from '@/types/request'
|
|
|
-import { default as consts, default as CONSTS } from '@/utils/consts'
|
|
|
+import consts from '@/utils/consts'
|
|
|
import { storage } from '@/utils/util'
|
|
|
import { message } from 'antd'
|
|
|
import axios, { AxiosRequestConfig, AxiosResponse } from 'axios'
|
|
@@ -22,7 +22,7 @@ const removePending = (config: AxiosRequestConfig) => {
|
|
|
}
|
|
|
}
|
|
|
const service = axios.create({
|
|
|
- baseURL: process.env.NODE_ENV === 'development' ? CONSTS.BASE_URL.DEV : CONSTS.BASE_URL.PROD,
|
|
|
+ baseURL: process.env.NODE_ENV === 'development' ? consts.BASE_URL.DEV : consts.BASE_URL.PROD,
|
|
|
timeout: 5000,
|
|
|
withCredentials: true
|
|
|
})
|
|
@@ -55,7 +55,7 @@ service.interceptors.response.use(
|
|
|
const data: ResponseData = response.data
|
|
|
|
|
|
// 对Code不等于Success进行message提示
|
|
|
- if (data.code !== CONSTS.RET_CODE.SUCCESS) {
|
|
|
+ if (data.code !== consts.RET_CODE.SUCCESS) {
|
|
|
message.error(data.msg)
|
|
|
if (consts.TOKEN_INVALID_CODE.includes(data.code)) {
|
|
|
userStore.logout()
|
|
@@ -70,7 +70,7 @@ service.interceptors.response.use(
|
|
|
error => {
|
|
|
const response = error.response
|
|
|
const config = error.config
|
|
|
- const { COUNT: RETRY_COUNT, DELAY: RETRY_DELAY } = CONSTS.RETRY
|
|
|
+ const { COUNT: RETRY_COUNT, DELAY: RETRY_DELAY } = consts.RETRY
|
|
|
if (config && RETRY_COUNT) {
|
|
|
// 设置一个静态属性追踪重试次数
|
|
|
config.__retryCount = config.__retryCount || 0
|