style: format style

This commit is contained in:
xiaoxian521
2021-07-20 17:16:42 +08:00
parent a5172c9476
commit 9bb4f34707
9 changed files with 105 additions and 99 deletions

View File

@@ -1,48 +1,50 @@
import Axios, {
AxiosRequestConfig,
Canceler,
AxiosResponse,
Method,
AxiosError
} from "axios"
AxiosRequestConfig,
Canceler,
AxiosResponse,
Method,
AxiosError
} from "axios";
import { METHODS } from './config'
import { METHODS } from "./config";
export type cancelTokenType = { cancelKey: string, cancelExecutor: Canceler }
export type cancelTokenType = { cancelKey: string; cancelExecutor: Canceler };
export type RequestMethods = Extract<Method, 'get' | 'post' | 'put' | 'delete' | 'patch' |
'option' | 'head'>
export type RequestMethods = Extract<
Method,
"get" | "post" | "put" | "delete" | "patch" | "option" | "head"
>;
export interface EnclosureHttpRequestConfig extends AxiosRequestConfig {
beforeRequestCallback?: (request: EnclosureHttpRequestConfig) => void // 请求发送之前
beforeResponseCallback?: (response: EnclosureHttpResoponse) => void // 相应返回之前
beforeRequestCallback?: (request: EnclosureHttpRequestConfig) => void; // 请求发送之前
beforeResponseCallback?: (response: EnclosureHttpResoponse) => void; // 相应返回之前
}
export interface EnclosureHttpResoponse extends AxiosResponse {
config: EnclosureHttpRequestConfig
config: EnclosureHttpRequestConfig;
}
export interface EnclosureHttpError extends AxiosError {
isCancelRequest?: boolean
isCancelRequest?: boolean;
}
export default class EnclosureHttp {
cancelTokenList: Array<cancelTokenType>
clearCancelTokenList(): void
request<T>(
method: RequestMethods,
url: string,
param?: AxiosRequestConfig,
axiosConfig?: EnclosureHttpRequestConfig
): Promise<T>
post<T>(
url: string,
params?: T,
config?: EnclosureHttpRequestConfig
): Promise<T>
get<T>(
url: string,
params?: T,
config?: EnclosureHttpRequestConfig
): Promise<T>
}
cancelTokenList: Array<cancelTokenType>;
clearCancelTokenList(): void;
request<T>(
method: RequestMethods,
url: string,
param?: AxiosRequestConfig,
axiosConfig?: EnclosureHttpRequestConfig
): Promise<T>;
post<T>(
url: string,
params?: T,
config?: EnclosureHttpRequestConfig
): Promise<T>;
get<T>(
url: string,
params?: T,
config?: EnclosureHttpRequestConfig
): Promise<T>;
}