Initial commit of akmon project
This commit is contained in:
48
uni_modules/ak-req/interface.uts
Normal file
48
uni_modules/ak-req/interface.uts
Normal file
@@ -0,0 +1,48 @@
|
||||
// ak-req 类型定义
|
||||
export type AkReqOptions = {
|
||||
url: string;
|
||||
method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' |'HEAD';
|
||||
data?: UTSJSONObject | Array<UTSJSONObject>;
|
||||
headers?: UTSJSONObject;
|
||||
timeout?: number;
|
||||
contentType?: string; // 新增,支持顶级 contentType
|
||||
// 可选:重试设置(仅网络错误/超时触发)。默认重试 0 次
|
||||
retryCount?: number; // 最大重试次数,默认 0
|
||||
retryDelayMs?: number; // 首次重试延迟,默认 300ms,指数退避
|
||||
};
|
||||
// 上传参数类型定义
|
||||
export type AkReqUploadOptions = {
|
||||
url: string,
|
||||
filePath: string,
|
||||
name: string,
|
||||
formData?: UTSJSONObject,
|
||||
headers?: UTSJSONObject,
|
||||
apikey?: string,
|
||||
timeout?: number,
|
||||
// 进度回调,0-100(注意:H5/APP 平台支持不同)
|
||||
onProgress?: (progress: number, transferredBytes?: number, totalBytes?: number) => void,
|
||||
// 可选:重试设置(仅网络错误/超时触发)。默认 0
|
||||
retryCount?: number,
|
||||
retryDelayMs?: number
|
||||
};
|
||||
|
||||
export type AkReqResponse<T = any> = {
|
||||
status: number;
|
||||
data: T | Array<T> | null; // 支持 null
|
||||
headers: UTSJSONObject;
|
||||
error: UniError | null;
|
||||
total:number |null;
|
||||
page: number |null;
|
||||
limit: number |null;
|
||||
hasmore:boolean |null;
|
||||
origin: any | null;
|
||||
};
|
||||
|
||||
export class AkReqError extends Error {
|
||||
code: number;
|
||||
constructor(message: string, code: number = 0) {
|
||||
super(message);
|
||||
this.code = code;
|
||||
this.name = 'AkReqError';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user