|
@@ -13,13 +13,18 @@ const removePending = (config: AxiosRequestConfig) => {
|
|
|
const item: number = +key
|
|
|
const list: PendingType = pending[key]
|
|
|
// 当前请求在数组中存在时执行函数体
|
|
|
- if (list.url === config.url && list.method === config.method && JSON.stringify(list.params) === JSON.stringify(config.params) && JSON.stringify(list.data) === JSON.stringify(config.data)) {
|
|
|
- // 执行取消操作
|
|
|
- list.cancel('操作太频繁,请稍后再试')
|
|
|
- // 从数组中移除记录
|
|
|
- pending.splice(item, 1)
|
|
|
+ if (
|
|
|
+ list.url === config.url &&
|
|
|
+ list.method === config.method &&
|
|
|
+ JSON.stringify(list.params) === JSON.stringify(config.params) &&
|
|
|
+ JSON.stringify(list.data) === JSON.stringify(config.data)
|
|
|
+ ) {
|
|
|
+ // 执行取消操作
|
|
|
+ list.cancel('操作太频繁,请稍后再试')
|
|
|
+ // 从数组中移除记录
|
|
|
+ pending.splice(item, 1)
|
|
|
}
|
|
|
-}
|
|
|
+ }
|
|
|
}
|
|
|
const service = axios.create({
|
|
|
baseURL: process.env.NODE_ENV === 'development' ? consts.BASE_URL.DEV : consts.BASE_URL.PROD,
|
|
@@ -39,8 +44,9 @@ service.interceptors.request.use(
|
|
|
if (request?.method !== 'get') {
|
|
|
request.headers['X-CSRF-Token'] = storage.get('csrf_token')
|
|
|
}
|
|
|
+
|
|
|
request.headers['bidsectionId'] = tenderStore.bid
|
|
|
- return request
|
|
|
+ return Promise.resolve(request)
|
|
|
},
|
|
|
err => {
|
|
|
return Promise.reject(err)
|
|
@@ -54,7 +60,6 @@ service.interceptors.response.use(
|
|
|
(response: AxiosResponse) => {
|
|
|
removePending(response.config)
|
|
|
const data: ResponseData = response.data
|
|
|
-
|
|
|
// 对Code不等于Success进行message提示
|
|
|
if (data.code !== consts.RET_CODE.SUCCESS) {
|
|
|
message.error(data.msg)
|
|
@@ -66,7 +71,7 @@ service.interceptors.response.use(
|
|
|
const token = response?.headers['x-csrf-token']
|
|
|
storage.set('csrf_token', token)
|
|
|
}
|
|
|
- return response
|
|
|
+ return Promise.resolve(response)
|
|
|
},
|
|
|
error => {
|
|
|
const response = error.response
|
|
@@ -95,13 +100,12 @@ service.interceptors.response.use(
|
|
|
}
|
|
|
)
|
|
|
|
|
|
-
|
|
|
export default {
|
|
|
get(url: string, params?: any) {
|
|
|
return service.get(url, { params })
|
|
|
},
|
|
|
post(url: string, data?: any) {
|
|
|
- return service.post(url, data )
|
|
|
+ return service.post(url, data)
|
|
|
},
|
|
|
del(url: string, data?: any) {
|
|
|
return service.delete(url, { params: data })
|