mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-09 13:53:38 +08:00
style: format style
This commit is contained in:
68
src/utils/http/types.d.ts
vendored
68
src/utils/http/types.d.ts
vendored
@@ -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>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user