mirror of
https://gitee.com/dromara/go-view.git
synced 2025-10-14 06:22:10 +08:00
新增取消下次请求开始时未完成的上一次请求
This commit is contained in:
parent
686222cb19
commit
4308ab952f
@ -8,7 +8,11 @@ import {
|
|||||||
RequestParamsObjType
|
RequestParamsObjType
|
||||||
} from '@/enums/httpEnum'
|
} from '@/enums/httpEnum'
|
||||||
import type { RequestGlobalConfigType, RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
import type { RequestGlobalConfigType, RequestConfigType } from '@/store/modules/chartEditStore/chartEditStore.d'
|
||||||
|
//新增取消下次请求开始时未完成的上一次请求 --start
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
let cancel:any;
|
||||||
|
//新增取消下次请求开始时未完成的上一次请求 --end
|
||||||
export const get = <T = any>(url: string, params?: object) => {
|
export const get = <T = any>(url: string, params?: object) => {
|
||||||
return axiosInstance<T>({
|
return axiosInstance<T>({
|
||||||
url: url,
|
url: url,
|
||||||
@ -18,13 +22,18 @@ export const get = <T = any>(url: string, params?: object) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const post = <T = any>(url: string, data?: object, headersType?: string) => {
|
export const post = <T = any>(url: string, data?: object, headersType?: string) => {
|
||||||
|
if (cancel !== undefined) {
|
||||||
|
cancel();
|
||||||
|
}
|
||||||
return axiosInstance<T>({
|
return axiosInstance<T>({
|
||||||
url: url,
|
url: url,
|
||||||
method: RequestHttpEnum.POST,
|
method: RequestHttpEnum.POST,
|
||||||
data: data,
|
data: data,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': headersType || ContentTypeEnum.JSON
|
'Content-Type': headersType || ContentTypeEnum.JSON
|
||||||
}
|
},
|
||||||
|
//新增取消下次请求开始时未完成的上一次请求
|
||||||
|
cancelToken: new axios.CancelToken(c => cancel = c)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +172,7 @@ export const customizeHttp = (targetParams: RequestConfigType, globalParams: Req
|
|||||||
params = translateStr(params)
|
params = translateStr(params)
|
||||||
// form 类型处理
|
// form 类型处理
|
||||||
let formData: FormData = new FormData()
|
let formData: FormData = new FormData()
|
||||||
|
formData.set('default', 'defaultData')
|
||||||
// 类型处理
|
// 类型处理
|
||||||
|
|
||||||
switch (requestParamsBodyType) {
|
switch (requestParamsBodyType) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user