mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
refactor(projects): axios封装完成
This commit is contained in:
15
src/interface/business/demo.ts
Normal file
15
src/interface/business/demo.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/** 数据字典 */
|
||||
export interface Dictionary {
|
||||
/** 字典名字 */
|
||||
label: string;
|
||||
/** 要素名字(一级指标) */
|
||||
charactorLabel: string;
|
||||
/** 要素下的指标key(二级指标) */
|
||||
indicatorKey: string;
|
||||
/** 要素下的指标名字(二级指标) */
|
||||
indicatorLabel: string;
|
||||
/** 备注 */
|
||||
remark: string;
|
||||
/** 指标公式 */
|
||||
formula: string;
|
||||
}
|
@ -1 +1,2 @@
|
||||
export * from './auth';
|
||||
export * from './demo';
|
||||
|
15
src/interface/common/api.ts
Normal file
15
src/interface/common/api.ts
Normal file
@ -0,0 +1,15 @@
|
||||
/** 数据字典 */
|
||||
export interface ResponseDictionary {
|
||||
/** 字典名字 */
|
||||
modelName: string;
|
||||
/** 要素名字(一级指标) */
|
||||
modelCharactorName: string;
|
||||
/** 要素下的指标key(二级指标) */
|
||||
modelIndicator: string;
|
||||
/** 要素下的指标名字(二级指标) */
|
||||
modelIndicatorName: string;
|
||||
/** 备注 */
|
||||
remarks: string;
|
||||
/** 指标公式 */
|
||||
formula: string;
|
||||
}
|
@ -1,2 +1,4 @@
|
||||
export * from './system';
|
||||
export * from './route';
|
||||
export * from './service';
|
||||
export * from './api';
|
||||
|
50
src/interface/common/service.ts
Normal file
50
src/interface/common/service.ts
Normal 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;
|
Reference in New Issue
Block a user