import { AxiosRequestHeaders } from 'axios'

export interface FetchOptions<T extends FetchTypes> {
    controller?: AbortController;
    data?: T['request'];
    headers?: AxiosRequestHeaders;
}

export interface FetchTypes {
    request?: unknown;
    response?: unknown;
}

/**
 * Http 响应结果状态码
 */
export enum ResultCode {
    Success = 200, //成功
    InvalidToken = 4009, //令牌无效
}

/**
 * Http 通用响应对象
 */
export interface CommonResult<T = unknown> {
    code: ResultCode;
    message: string;
    total: number;
    data: T;
}

export type CommonFetchOptions<T extends FetchTypes = object> = FetchOptions<{ request: T['request'], response: CommonResult<T['response']> }>