import type { AxiosRequestConfig, Method, AxiosResponse } from 'axios'; import axios from 'axios'; import type { TKeyValue } from '../core'; import { CryptoType } from '../core'; import requestManager from './requestManager'; export interface IRequestOption extends AxiosRequestConfig { /** * 操作成功是否提示 */ successTip?: boolean; /** * 请求方式 */ method?: Method; /** * 加密传输方式 */ crypto?: CryptoType; /** * 请求的类型key(用于cancel请求) */ requestKey?: string; /** * 是否忽略请求 */ ignoreCancel?: boolean; } declare let instance: import("axios").AxiosInstance; /** * 修改axios实例 * @param config 配置 */ export declare const configInstance: (config: AxiosRequestConfig) => void; /** * 全局设置的header */ declare let globalHeaders: () => TKeyValue; export declare const configGlobalHeader: (func: () => TKeyValue) => void; export declare const configRefreshToken: (func: () => Promise) => void; /** * 通用请求拦截器 */ declare const commonRequestInterceptor: ((option: any) => IRequestOption)[]; /** * 通用响应拦截,拦截异常信息(非200-302之间的状态码)、未授权等 */ declare const commonResponseInterceptor: ((response: AxiosResponse) => any)[]; /** * 通用响应拦截,拦截异常信息(非200-302之间的状态码)、未授权等 */ declare const commonResponseWithRefreshTokenInterceptor: (((response: AxiosResponse) => any) | (({ response }: { response: AxiosResponse; }) => Promise))[]; export declare function request(opt: IRequestOption): Promise; export declare function get(url: string, opt?: IRequestOption): Promise; export declare function post(url: string, opt?: IRequestOption): Promise; export declare function put(url: string, opt?: IRequestOption): Promise; export declare function patch(url: string, opt?: IRequestOption): Promise; export declare function del(url: string, opt?: IRequestOption): Promise; export declare function head(url: string, opt?: IRequestOption): Promise; export declare function options(url: string, opt?: IRequestOption): Promise; declare function addRequestInterceptor(onFulfilled?: (value: any) => any | Promise, onRejected?: (error: any) => any): number; declare function ejectRequestInterceptor(interceptorId: number): void; declare function addResponseInterceptor(onFulfilled?: (value: any) => any | Promise, onRejected?: (error: any) => any): number; declare function ejectResponseInterceptor(interceptorId: number): void; export { axios, instance, globalHeaders, commonRequestInterceptor, commonResponseInterceptor, commonResponseWithRefreshTokenInterceptor, addRequestInterceptor, ejectRequestInterceptor, addResponseInterceptor, ejectResponseInterceptor, requestManager, };