提交 | 用户 | age
|
2f6253
|
1 |
/** |
a821d9
|
2 |
* Data processing class, can be configured according to the project |
2f6253
|
3 |
*/ |
陈 |
4 |
import type { AxiosRequestConfig, AxiosResponse } from 'axios'; |
b6d5b0
|
5 |
import type { RequestOptions, Result } from '/#/axios'; |
2f6253
|
6 |
|
b7ce74
|
7 |
export interface CreateAxiosOptions extends AxiosRequestConfig { |
b6d5b0
|
8 |
authenticationScheme?: string; |
b7ce74
|
9 |
transform?: AxiosTransform; |
V |
10 |
requestOptions?: RequestOptions; |
|
11 |
} |
|
12 |
|
2f6253
|
13 |
export abstract class AxiosTransform { |
陈 |
14 |
/** |
a821d9
|
15 |
* @description: Process configuration before request |
2f6253
|
16 |
* @description: Process configuration before request |
陈 |
17 |
*/ |
|
18 |
beforeRequestHook?: (config: AxiosRequestConfig, options: RequestOptions) => AxiosRequestConfig; |
|
19 |
|
|
20 |
/** |
a821d9
|
21 |
* @description: Request successfully processed |
2f6253
|
22 |
*/ |
a821d9
|
23 |
transformRequestHook?: (res: AxiosResponse<Result>, options: RequestOptions) => any; |
2f6253
|
24 |
|
陈 |
25 |
/** |
|
26 |
* @description: 请求失败处理 |
|
27 |
*/ |
49b66e
|
28 |
requestCatchHook?: (e: Error, options: RequestOptions) => Promise<any>; |
2f6253
|
29 |
|
陈 |
30 |
/** |
|
31 |
* @description: 请求之前的拦截器 |
|
32 |
*/ |
b6d5b0
|
33 |
requestInterceptors?: ( |
V |
34 |
config: AxiosRequestConfig, |
56a966
|
35 |
options: CreateAxiosOptions, |
b6d5b0
|
36 |
) => AxiosRequestConfig; |
2f6253
|
37 |
|
陈 |
38 |
/** |
|
39 |
* @description: 请求之后的拦截器 |
|
40 |
*/ |
|
41 |
responseInterceptors?: (res: AxiosResponse<any>) => AxiosResponse<any>; |
|
42 |
|
|
43 |
/** |
|
44 |
* @description: 请求之前的拦截器错误处理 |
|
45 |
*/ |
|
46 |
requestInterceptorsCatch?: (error: Error) => void; |
|
47 |
|
|
48 |
/** |
|
49 |
* @description: 请求之后的拦截器错误处理 |
|
50 |
*/ |
136cbb
|
51 |
responseInterceptorsCatch?: (axiosInstance: AxiosResponse, error: Error) => void; |
2f6253
|
52 |
} |