Match-id-aac8a03a414d15fb66b0400caf02e06db581b4c3
This commit is contained in:
commit
5cd66e232e
|
@ -7,5 +7,5 @@
|
||||||
"env": {
|
"env": {
|
||||||
"NODE_ENV": "development"
|
"NODE_ENV": "development"
|
||||||
},
|
},
|
||||||
"ext": "js,json"
|
"ext": "js,mjs,json"
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,16 @@ class InulaRequest implements IrInterface {
|
||||||
response: new InterceptorManager(),
|
response: new InterceptorManager(),
|
||||||
};
|
};
|
||||||
this.processRequest = processRequest;
|
this.processRequest = processRequest;
|
||||||
|
|
||||||
|
// 支持动态传递请求方法保证 this 指向正确
|
||||||
|
this.request = this.request.bind(this);
|
||||||
|
this.get = this.get.bind(this);
|
||||||
|
this.delete = this.delete.bind(this);
|
||||||
|
this.head = this.head.bind(this);
|
||||||
|
this.options = this.options.bind(this);
|
||||||
|
this.post = this.post.bind(this);
|
||||||
|
this.put = this.put.bind(this);
|
||||||
|
this.patch = this.patch.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
request<T = unknown>(requestParam: string | Record<string, any>, config?: IrRequestConfig): Promise<IrResponse<T>> {
|
request<T = unknown>(requestParam: string | Record<string, any>, config?: IrRequestConfig): Promise<IrResponse<T>> {
|
||||||
|
|
|
@ -21,10 +21,13 @@ export const fetchRequest = (config: IrRequestConfig): Promise<IrResponse> => {
|
||||||
withCredentials = false,
|
withCredentials = false,
|
||||||
onUploadProgress = null,
|
onUploadProgress = null,
|
||||||
onDownloadProgress = null,
|
onDownloadProgress = null,
|
||||||
|
signal,
|
||||||
} = config;
|
} = config;
|
||||||
|
|
||||||
let controller = new AbortController();
|
let controller = new AbortController();
|
||||||
let signal = controller.signal;
|
if (!signal) {
|
||||||
|
signal = controller.signal;
|
||||||
|
}
|
||||||
|
|
||||||
// 处理请求取消
|
// 处理请求取消
|
||||||
if (cancelToken) {
|
if (cancelToken) {
|
||||||
|
|
Loading…
Reference in New Issue