2023-05-24 11:08:08 +08:00
|
|
|
|
export type ErrorMessageMode = 'none' | 'modal' | 'message' | undefined;
|
|
|
|
|
|
|
|
|
|
export interface RequestOptions {
|
2023-09-04 11:59:50 +08:00
|
|
|
|
isTransformResponse?: boolean; // 是否需要处理请求结果
|
|
|
|
|
isReturnNativeResponse?: boolean; // 是否需要返回原生响应头
|
2023-05-24 11:08:08 +08:00
|
|
|
|
handleError?: boolean;
|
2023-09-04 11:59:50 +08:00
|
|
|
|
joinParamsToUrl?: boolean; // post请求时,是否使用URLSearchParams
|
|
|
|
|
noErrorTip?: boolean;
|
|
|
|
|
errorMessageMode?: ErrorMessageMode; // 错误信息提示模式,none不提示
|
|
|
|
|
joinTime?: boolean; // 是否加入时间戳
|
|
|
|
|
ignoreCancelToken?: boolean; // 是否不记录取消请求的token,不记录则请求不会被取消;默认为记录,在路由切换时会清除上个页面未完成的请求
|
|
|
|
|
withToken?: boolean; // 是否携带token
|
2023-05-24 11:08:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface Result<T = any> {
|
2023-06-02 15:18:59 +08:00
|
|
|
|
code: number;
|
2023-05-24 11:08:08 +08:00
|
|
|
|
type: 'success' | 'error' | 'warning';
|
|
|
|
|
message: string;
|
2023-06-02 15:18:59 +08:00
|
|
|
|
messageDetail?: string;
|
|
|
|
|
data: T;
|
2023-05-24 11:08:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// multipart/form-data: upload file
|
|
|
|
|
export interface UploadFileParams {
|
|
|
|
|
// Other parameters
|
|
|
|
|
data?: Recordable;
|
|
|
|
|
// File parameter interface field name
|
|
|
|
|
name?: string;
|
|
|
|
|
// file name
|
2023-07-21 18:44:18 +08:00
|
|
|
|
file?: File | Blob;
|
2023-05-24 11:08:08 +08:00
|
|
|
|
// file name
|
|
|
|
|
filename?: string;
|
|
|
|
|
[key: string]: any;
|
|
|
|
|
}
|