chore: 脚手架

This commit is contained in:
dap
2024-08-07 08:57:56 +08:00
parent 4bd4f7490b
commit c31259598b
83 changed files with 2127 additions and 225 deletions

View File

@@ -99,7 +99,8 @@ class RequestClient {
const authorization = this.makeAuthorization?.(config);
if (authorization) {
const { token } = authorization.tokenHandler?.() ?? {};
config.headers[authorization.key || 'Authorization'] = token;
config.headers[authorization.key || 'Authorization'] =
`Bearer ${token}`;
}
const requestHeader = this.makeRequestHeaders?.(config);

View File

@@ -43,13 +43,9 @@ interface RequestClientOptions extends CreateAxiosDefaults {
}
interface HttpResponse<T = any> {
/**
* 0 表示成功 其他表示失败
* 0 means success, others means fail
*/
code: number;
data: T;
message: string;
msg: string;
}
export type {
@@ -60,3 +56,44 @@ export type {
RequestClientOptions,
RequestContentType,
};
export type ErrorMessageMode = 'message' | 'modal' | 'none' | undefined;
export type SuccessMessageMode = ErrorMessageMode;
/**
* 拓展axios的请求配置
*/
declare module 'axios' {
interface AxiosRequestConfig {
/** 是否加密请求参数 */
encrypt?: boolean;
/**
* 错误弹窗类型
*/
errorMessageMode?: ErrorMessageMode;
/**
* 是否格式化日期
*/
formatDate?: boolean;
/**
* 是否返回原生axios响应
*/
isReturnNativeResponse?: boolean;
/**
* 是否需要转换响应 即只获取{code, msg, data}中的data
*/
isTransformResponse?: boolean;
/**
* param添加到url后
*/
joinParamsToUrl?: boolean;
/**
* 加入时间戳
*/
joinTime?: boolean;
/**
* 成功弹窗类型
*/
successMessageMode?: SuccessMessageMode;
}
}