| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- export type Method = 'OPTIONS' | 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'CONNECT'
- /**
- * Http请求配置
- */
- export interface HttpConfig<T> {
- url: string;
- method: Method;
- enableAuthorization?: boolean; // 是否启用用户凭证
- data?: T; // 请求参数
- isAccess?: boolean
- }
- /**
- * Http响应结果
- */
- export interface HttpResponse<T> {
- code: ResultCode;
- msg: string;
- data: T;
- }
- /**
- * Http请求参数
- * @param Req 请求参数
- * @param Res 响应结果
- */
- export interface HttpRequest<T extends { req?: unknown, rsp?: unknown } = object> {
- data?: T['req'];
- enableAuthorization?: boolean;
- success?: (res: HttpResponse<T['rsp']>) => void;
- fail?: (err: string) => void;
- complete?: () => void;
- }
- /**
- * Http响应结果状态码
- */
- export enum ResultCode {
- Success = 200, // 成功
- Code = 0, // 请求成功
- Error = 7, // 失败
- InvalidToken = 8, // 令牌无效
- }
|