import { AxiosInstance, AxiosRequestConfig, CancelTokenStatic } from 'axios' import { CustomAjaxMethods } from './compatibleMethods' import { RequestCreator } from './methods' export type AnyObj = Record export interface AjaxOption extends AxiosRequestConfig { /** 是否发送FormData数据,仅用于post类请求,为true则使用qs.stringify序列化数据 */ sendFormData?: boolean /** 当前请求的取消函数名称,使用ajax.canceller[cancelKey]()的方式调用 */ cancelKey?: string /** 如果有值,则请求直接resolve这个值,阻断请求发送。用于开发mock数据 */ mock?: any // [k: string]: any } export type RequestMethods = 'get' | 'post' | 'patch' | 'put' | 'delete' | 'head' | 'options' export type ProxyedAttrs = 'request' | 'interceptors' export type CancellerType = { [K: string]: () => void } export interface AjaxInstance extends Pick { /** @deprecated 即将废弃,请使用ajax.get方法替换 */ query: CustomAjaxMethods /** @deprecated 即将废弃,请使用ajax.post方法替换 */ create: CustomAjaxMethods /** @deprecated 即将废弃,请使用ajax.delete方法替换 */ deletes: CustomAjaxMethods /** @deprecated 即将废弃,请使用ajax.put方法替换 */ putWay: CustomAjaxMethods /** @deprecated 即将废弃,请使用ajax.patch方法替换 */ patchWay: CustomAjaxMethods head: RequestCreator get: RequestCreator post: RequestCreator put: RequestCreator delete: RequestCreator patch: RequestCreator canceller: CancellerType $baseUrl: string $options: AjaxOption $engine: AxiosInstance CancelToken: CancelTokenStatic } export type AxiosMethods = 'GET' | 'POST' | 'DELETE' | 'PUT' | 'PATCH' | 'HEAD'