refactor(projects): axios封装完成

This commit is contained in:
Soybean
2021-11-23 00:23:43 +08:00
parent 451c7547af
commit 03b398af2f
21 changed files with 332 additions and 145 deletions

View File

@ -0,0 +1,15 @@
/** 数据字典 */
export interface Dictionary {
/** 字典名字 */
label: string;
/** 要素名字(一级指标) */
charactorLabel: string;
/** 要素下的指标key(二级指标) */
indicatorKey: string;
/** 要素下的指标名字(二级指标) */
indicatorLabel: string;
/** 备注 */
remark: string;
/** 指标公式 */
formula: string;
}

View File

@ -1 +1,2 @@
export * from './auth';
export * from './demo';

View File

@ -0,0 +1,15 @@
/** 数据字典 */
export interface ResponseDictionary {
/** 字典名字 */
modelName: string;
/** 要素名字(一级指标) */
modelCharactorName: string;
/** 要素下的指标key(二级指标) */
modelIndicator: string;
/** 要素下的指标名字(二级指标) */
modelIndicatorName: string;
/** 备注 */
remarks: string;
/** 指标公式 */
formula: string;
}

View File

@ -1,2 +1,4 @@
export * from './system';
export * from './route';
export * from './service';
export * from './api';

View File

@ -0,0 +1,50 @@
/**
* 请求服务的错误类型:
* - axios: axios错误网络错误, 请求超时, 默认的兜底错误
* - http: 请求成功响应的状态码非200的错误
* - backend: 请求成功响应的状态码为200由后端定义的业务错误
*/
export type RequestServiceErrorType = 'axios' | 'http' | 'backend';
/** 请求服务的错误 */
export interface RequestServiceError {
/** 请求服务的错误类型 */
type: RequestServiceErrorType;
/** 错误码 */
code: string | number;
/** 错误信息 */
msg: string;
}
/** 后端接口返回的类型结构 */
export interface BackendServiceResult {
/** 状态码 */
code: number;
/** 接口数据 */
data: any;
/** 接口消息 */
message: string;
}
/** 自定义的请求成功结果 */
export interface CustomSuccessRequestResult<ResponseData> {
/** 请求错误 */
error: null;
/** 请求数据 */
data: ResponseData;
/** 网络状态 */
networkStatus: boolean;
}
/** 自定义的请求失败结果 */
export interface CustomFailRequestResult {
/** 请求错误 */
error: RequestServiceError;
/** 请求数据 */
data: null;
/** 网络状态 */
networkStatus: boolean;
}
/** 自定义的请求结果 */
export type CustomRequestResult<ResponseData> = CustomSuccessRequestResult<ResponseData> | CustomFailRequestResult;