export type Method = | "get" | "GET" | "delete" | "Delete" | "head" | "HEAD" | "options" | "OPTIONS" | "post" | "POST" | "put" | "PUT" | "patch" | "PATCH"; export interface HttpRequestConfig { url?: string; method?: string; headers?: any; data?: any; params?: any; withStatusCode?: boolean; responseType?: XMLHttpRequestResponseType; redirect?: boolean; timeout?: number; } export interface HttpResponse { data: any; // 服务端返回的数据 status: number; // HTTP 状态码 headers: any; // 响应头 config: HttpRequestConfig; // 请求配置对象 } export interface Http { request(config: HttpRequestConfig): HttpResponse; get(url: string, config?: HttpRequestConfig): HttpResponse; delete(url: string, config?: HttpRequestConfig): HttpResponse; head(url: string, config?: HttpRequestConfig): HttpResponse; options(url: string, config?: HttpRequestConfig): HttpResponse; // 以下三个与上面三个多了data参数 post( url: string, data?: any, config?: HttpRequestConfig ): HttpResponse; put( url: string, data?: any, config?: HttpRequestConfig ): HttpResponse; patch( url: string, data?: any, config?: HttpRequestConfig ): HttpResponse; } export interface HttpInstance extends Http { (config: HttpRequestConfig): HttpResponse; (url: string, config?: HttpRequestConfig): HttpResponse; }