/** * 数据处理类,可根据工程进行配置 */ import type { AxiosRequestConfig, AxiosResponse } from 'axios'; import type { RequestOptions, Result } from '../../../typesaxios'; export interface CreateAxiosOptions extends AxiosRequestConfig { tenantId?: string; authenticationScheme?: string; authToken?: string; transform?: AxiosTransform; setHeaders?: () => any; requestOptions?: RequestOptions; } export interface AxiosTransform { /** * @description: 请求前配置拦截器 */ beforeRequestHook?: (config: AxiosRequestConfig, options: RequestOptions) => AxiosRequestConfig; /** * @description: 处理响应数据 */ transformResponseHook?: (res: AxiosResponse, options: RequestOptions) => any; /** * @description: 请求失败处理 */ requestCatchHook?: (e: Error, options: RequestOptions) => Promise; /** * @description: 请求之前的拦截器 */ requestInterceptors?: (config: AxiosRequestConfig, options: CreateAxiosOptions) => AxiosRequestConfig; /** * @description: 请求之后的拦截器 */ responseInterceptors?: (res: AxiosResponse) => AxiosResponse; /** * @description: 请求之前的拦截器错误处理 */ requestInterceptorsCatch?: (error: Error) => void; /** * @description: 请求之后的拦截器错误处理 */ responseInterceptorsCatch?: (axiosInstance: AxiosResponse, error: Error) => void; }