@moluoxixi/ajax-package 0.0.17 → 0.0.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,15 @@
1
1
  import { AxiosError, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig, default as axios } from 'axios';
2
2
  import { BaseHttpClientConfig } from './_types/index.ts';
3
3
  import { MessageInstance, NotificationInstance } from './_utils/index.ts';
4
+ /**
5
+ * BaseHttpClient 基础类
6
+ * 提供最基础的 HTTP 请求功能,包括:
7
+ * - 创建 axios 实例
8
+ * - 自动添加 Token
9
+ * - 基础错误处理(401、超时等)
10
+ * - HTTP 方法(get、post、put、delete、all)
11
+ * - 文件上传
12
+ */
4
13
  export default class BaseHttpClient {
5
14
  protected baseURL: string;
6
15
  protected timeout: number;
@@ -10,22 +19,124 @@ export default class BaseHttpClient {
10
19
  instance: ReturnType<typeof axios.create>;
11
20
  protected messageInstance: MessageInstance;
12
21
  protected notificationInstance: NotificationInstance;
22
+ /**
23
+ * 创建 BaseHttpClient 实例
24
+ * @param config - HTTP 客户端配置对象
25
+ */
13
26
  constructor(config: BaseHttpClientConfig);
27
+ /**
28
+ * 处理请求配置,子类可重写此方法自定义请求配置
29
+ * @param config - 请求配置对象
30
+ * @returns 处理后的请求配置
31
+ */
14
32
  processRequestConfig(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig<any>;
33
+ /**
34
+ * 处理响应配置,子类可重写此方法自定义响应处理
35
+ * 按照标准 HTTP 结构处理响应
36
+ * @param response - Axios 响应对象
37
+ * @returns 解析后的响应数据
38
+ */
15
39
  processResponseConfig(response: AxiosResponse): AxiosResponse['data'];
40
+ /**
41
+ * 处理 HTTP 状态码
42
+ * 子类可重写此方法来自定义 HTTP 状态码处理逻辑
43
+ * @param response - Axios 响应对象
44
+ */
16
45
  protected handleHttpStatus(response: AxiosResponse): void;
46
+ /**
47
+ * 处理成功响应
48
+ * 子类可重写此方法来自定义成功响应的处理逻辑
49
+ * @param response - Axios 响应对象
50
+ * @returns 解析后的响应数据
51
+ */
17
52
  protected handleSuccessResponse(response: AxiosResponse): AxiosResponse['data'];
53
+ /**
54
+ * 处理响应错误,子类可重写此方法自定义错误处理
55
+ * 按照标准 HTTP 错误结构处理错误
56
+ * @param error - Axios 错误对象
57
+ * @returns 处理后的错误对象
58
+ */
18
59
  processResponseError(error: AxiosError): Promise<AxiosError>;
60
+ /**
61
+ * 处理认证错误(401 - 未授权/登录失效)
62
+ * 子类可重写此方法来自定义认证错误处理逻辑
63
+ * @param error - Axios 错误对象
64
+ */
19
65
  protected handleAuthenticationError(error: AxiosError): void;
66
+ /**
67
+ * 处理超时错误
68
+ * 子类可重写此方法来自定义超时错误处理逻辑
69
+ * @param error - Axios 错误对象
70
+ */
20
71
  protected handleTimeoutError(error: AxiosError): void;
72
+ /**
73
+ * 处理网络错误(其他错误)
74
+ * 子类可重写此方法来自定义网络错误处理逻辑
75
+ * @param error - Axios 错误对象
76
+ */
21
77
  protected handleNetworkError(error: AxiosError): void;
78
+ /**
79
+ * 设置请求和响应拦截器
80
+ * 请求拦截器:自动添加 Token
81
+ * 响应拦截器:处理成功响应和错误响应(401、超时等)
82
+ */
22
83
  private setupInterceptors;
84
+ /**
85
+ * 发送 HTTP 请求,所有 HTTP 方法最终都调用此方法
86
+ * @param config - Axios 请求配置对象
87
+ * @returns 解析后的响应数据
88
+ */
23
89
  protected request<R>(config: AxiosRequestConfig): Promise<AxiosResponse['data']>;
90
+ /**
91
+ * 发送 GET 请求
92
+ * @param url - 请求 URL 路径
93
+ * @param params - 查询参数对象
94
+ * @param config - 额外的请求配置
95
+ * @returns 解析后的响应数据
96
+ */
24
97
  get<R>(url: string, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
98
+ /**
99
+ * 发送 POST 请求
100
+ * @param url - 请求 URL 路径
101
+ * @param data - 请求体数据
102
+ * @param config - 额外的请求配置
103
+ * @returns 解析后的响应数据
104
+ */
25
105
  post<R>(url: string, data?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
106
+ /**
107
+ * 发送 DELETE 请求
108
+ * @param url - 请求 URL 路径
109
+ * @param params - 查询参数对象
110
+ * @param config - 额外的请求配置
111
+ * @returns 解析后的响应数据
112
+ */
26
113
  delete<R>(url: string, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
114
+ /**
115
+ * 发送 PUT 请求
116
+ * @param url - 请求 URL 路径
117
+ * @param data - 请求体数据
118
+ * @param config - 额外的请求配置
119
+ * @returns 解析后的响应数据
120
+ */
27
121
  put<R>(url: string, data?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
122
+ /**
123
+ * 批量请求,并发发送多个请求
124
+ * @param requests - 请求配置数组或已发起的请求 Promise 数组
125
+ * @returns 所有请求的响应数据数组
126
+ */
28
127
  all<R>(requests: Array<AxiosRequestConfig | Promise<AxiosResponse<R>>>): Promise<AxiosResponse['data'][]>;
128
+ /**
129
+ * 文件上传,将文件包装为 FormData 发送
130
+ * @param url - 上传地址
131
+ * @param file - 文件对象
132
+ * @param config - 额外的请求配置
133
+ * @returns 解析后的响应数据
134
+ */
29
135
  uploadFile<R>(url: string, file: File | Blob, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
136
+ /**
137
+ * 下载文件,将 Blob 对象下载到本地
138
+ * @param blob - Blob 对象
139
+ * @param filename - 文件名,如果不提供则使用时间戳
140
+ */
30
141
  downloadFile(blob: Blob, filename?: string): void;
31
142
  }
@@ -1,3 +1,7 @@
1
+ /**
2
+ * SystemErrorDialog 组件
3
+ * 使用 defineComponent 和 h 函数实现
4
+ */
1
5
  declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
2
6
  title: {
3
7
  type: StringConstructor;
@@ -2,30 +2,68 @@ import { AxiosRequestConfig } from 'axios';
2
2
  import { App } from 'vue';
3
3
  import { MessageInstance } from '../_utils/index.ts';
4
4
  import { default as BaseApi } from '../class.ts';
5
+ /**
6
+ * BaseHttpClient 基础配置接口,包含最基础的 HTTP 客户端配置
7
+ */
5
8
  export interface BaseHttpClientConfig {
9
+ /** API 基础地址 */
6
10
  baseURL?: string;
11
+ /** 请求超时时间(毫秒),默认 5000 */
7
12
  timeout?: number;
13
+ /** 请求超时回调函数,接收 messageInstance 用于显示消息提示 */
8
14
  onTimeout?: (messageInstance: MessageInstance) => void;
15
+ /** 获取 token 的函数,每次请求前自动调用 */
9
16
  getToken?: () => string | null;
17
+ /** 登录失效回调函数,当检测到 401 错误时调用,接收 messageInstance 用于显示消息提示 */
10
18
  onLoginRequired?: (messageInstance: MessageInstance) => void;
19
+ /** 允许其他任意配置项,会直接传递给 axios.create */
11
20
  [key: string]: any;
12
21
  }
22
+ /**
23
+ * BaseApi 配置接口,用于配置 BaseApi 实例的所有选项
24
+ * 继承 BaseHttpClientConfig,添加响应字段映射和系统异常弹窗配置
25
+ */
13
26
  export interface BaseApiConfig extends BaseHttpClientConfig {
27
+ /** 响应字段映射配置 */
14
28
  responseFields?: {
29
+ /** 响应状态码字段名,默认 'Code' */
15
30
  code?: string;
31
+ /** 响应消息字段名,默认 'Message' */
16
32
  message?: string;
33
+ /** 响应数据字段名,默认 'data' */
17
34
  data?: string;
35
+ /** 错误数组字段名 */
18
36
  errors?: string;
37
+ /** 提示信息字段名 */
19
38
  tips?: string;
20
39
  };
40
+ /** 是否启用 code === -1 的系统异常弹窗,默认为 true */
21
41
  enableSystemErrorDialog?: boolean;
42
+ /** 系统错误消息提示文本,默认为 '系统错误' */
43
+ systemErrorMessage?: string;
22
44
  }
45
+ /**
46
+ * Vue Axios 插件配置选项
47
+ */
23
48
  export interface vueAxiosPluginOptionsType {
49
+ /** 默认 HTTP 服务配置 */
24
50
  default?: BaseApiConfig;
51
+ /** 是否在所有组件中通过 mixin 注入 $http,默认为 true */
25
52
  globalMixin?: boolean;
26
53
  }
54
+ /**
55
+ * Vue HTTP 服务类型,在 Vue 应用中通过 this.$http 或 inject('$http') 获取
56
+ */
27
57
  export type vueHttpServiceType = BaseApi;
58
+ /**
59
+ * Vue Axios 插件类型,定义了 Vue 插件的标准接口
60
+ */
28
61
  export interface vueAxiosPluginType {
62
+ /**
63
+ * 安装插件
64
+ * @param app - Vue 应用实例
65
+ * @param options - 插件配置选项
66
+ */
29
67
  install: (app: App, options?: vueAxiosPluginOptionsType) => void;
30
68
  }
31
69
  /**
@@ -1,6 +1,13 @@
1
+ /**
2
+ * SystemErrorDialog 组件的 Emits 类型定义
3
+ */
1
4
  export interface SystemErrorDialogEmitsType {
5
+ /** v-model 更新事件 */
2
6
  'update:modelValue': [val: boolean];
7
+ /** 关闭事件 */
3
8
  'close': [];
9
+ /** 确认事件 */
4
10
  'confirm': [data: any];
11
+ /** 上报事件 */
5
12
  'report': [];
6
13
  }
@@ -1,13 +1,27 @@
1
+ /**
2
+ * SystemErrorDialog 组件的 Props 类型定义
3
+ */
1
4
  export interface SystemErrorDialogPropsType {
5
+ /** 对话框标题 */
2
6
  title?: string;
7
+ /** 对话框宽度 */
3
8
  width?: number | string;
9
+ /** 用户名 */
4
10
  userName?: string;
11
+ /** 用户ID */
5
12
  userId?: string;
13
+ /** 科室名称 */
6
14
  deptName?: string;
15
+ /** 科室ID */
7
16
  deptId?: string;
17
+ /** 客户端IP地址 */
8
18
  clientIp?: string;
19
+ /** 请求URL路径 */
9
20
  requestUrl?: string;
21
+ /** 链路追踪ID */
10
22
  traceId?: string;
23
+ /** 错误消息 */
11
24
  errorMessage?: string;
25
+ /** 错误代码 */
12
26
  errorCode?: number | string;
13
27
  }
@@ -1,3 +1,7 @@
1
+ /**
2
+ * 创建消息实例的包装函数
3
+ * @returns 消息实例,支持 success、error、warning、info 方法
4
+ */
1
5
  export declare function createMessageWrapper(): (import('element-plus').MessageFn & {
2
6
  primary: import('element-plus').MessageTypedFn;
3
7
  success: import('element-plus').MessageTypedFn;
@@ -1,3 +1,7 @@
1
+ /**
2
+ * 创建通知实例的包装函数(用于 errors / tips 展示)
3
+ * @returns 通知实例,支持 success、error、warning、info 方法
4
+ */
1
5
  export declare function createNotificationWrapper(): ((import('element-plus').Notify & import('vue').Plugin) & {
2
6
  _context: import('vue').AppContext | null;
3
7
  }) | ((options: string | {
@@ -1,6 +1,27 @@
1
1
  import { AxiosResponse } from 'axios';
2
2
  import { SystemErrorDialogPropsType } from '../_types/index.ts';
3
+ /**
4
+ * 规范化请求参数对象
5
+ * @param payload 请求参数
6
+ * @returns 规范化后的对象
7
+ */
3
8
  export declare function normalizePayload(payload: any): Record<string, any>;
9
+ /**
10
+ * 解析响应头中的 TraceId
11
+ * @param headers 响应头
12
+ * @returns TraceId 字符串
13
+ */
4
14
  export declare function resolveTraceId(headers: AxiosResponse['headers'] | undefined): string;
15
+ /**
16
+ * 从 localStorage 中读取 userInfo
17
+ * @returns userInfo 对象,如果不存在则返回空对象
18
+ */
5
19
  export declare function getUserInfoFromLocalStorage(): Record<string, any>;
20
+ /**
21
+ * 从 AxiosResponse 中提取系统错误信息
22
+ * @param response Axios 响应对象
23
+ * @param code 错误代码
24
+ * @param message 错误消息
25
+ * @returns 提取的错误信息
26
+ */
6
27
  export declare function extractSystemErrorInfo(response: AxiosResponse, code: number, message: string): Omit<SystemErrorDialogPropsType, 'title' | 'width'>;
package/es/class.d.ts CHANGED
@@ -1,44 +1,231 @@
1
- import { AxiosError, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
1
+ import { AxiosResponse } from 'axios';
2
2
  import { BaseApiConfig, ExtendedAxiosRequestConfig, NotificationOptions } from './_types/index.ts';
3
3
  import { default as BaseHttpClient } from './BaseHttpClient.ts';
4
+ /**
5
+ * BaseApi 类
6
+ * 继承 BaseHttpClient,提供增强的响应解析和错误处理功能
7
+ * 包括:响应字段映射、错误码处理、系统异常弹窗等
8
+ */
4
9
  export default class BaseApi extends BaseHttpClient {
5
10
  protected responseFields: Required<BaseApiConfig['responseFields']>;
6
11
  protected enableSystemErrorDialog: boolean;
12
+ protected systemErrorMessage: string;
13
+ /**
14
+ * 检查是否在浏览器环境(在类初始化时判断)
15
+ * 注意:这是静态属性,所有实例共享
16
+ */
17
+ private static readonly hasDocument;
18
+ /**
19
+ * SystemErrorDialog 实例
20
+ * 注意:这是实例属性,每个实例有自己的对话框实例
21
+ * 在构造函数中初始化(如果启用系统错误弹窗)
22
+ */
23
+ private systemErrorDialogInstance;
24
+ /**
25
+ * SystemErrorDialog 初始化 Promise
26
+ * 用于跟踪初始化状态,避免重复初始化
27
+ */
28
+ private systemErrorDialogInitPromise;
29
+ /**
30
+ * 系统错误信息存储,用于在点击 icon 时打开详细错误弹窗
31
+ * key: 错误ID,value: 错误信息对象
32
+ * 注意:这是静态属性,所有实例共享同一个错误信息存储
33
+ */
34
+ private static systemErrorInfoMap;
35
+ /**
36
+ * 获取是否在浏览器环境(实例 getter)
37
+ * @returns 是否在浏览器环境
38
+ */
39
+ protected get hasDocument(): boolean;
40
+ /**
41
+ * 获取系统错误信息存储(实例 getter)
42
+ * @returns 系统错误信息存储 Map
43
+ */
44
+ protected get systemErrorInfoMap(): Map<string, {
45
+ response: AxiosResponse;
46
+ responseData: AxiosResponse['data'];
47
+ code: number;
48
+ message: string;
49
+ }>;
50
+ /**
51
+ * 生成唯一错误ID(实例方法)
52
+ * @returns 唯一错误ID
53
+ */
54
+ protected generateErrorId(): string;
55
+ /**
56
+ * 打开系统错误详细弹窗(实例方法)
57
+ * @param errorId - 错误ID
58
+ */
59
+ private openSystemErrorDialog;
60
+ /**
61
+ * 创建 BaseApi 实例
62
+ * @param config - API 配置对象
63
+ */
7
64
  constructor(config: BaseApiConfig);
8
- processRequestConfig(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig;
9
- processResponseConfig(response: AxiosResponse): AxiosResponse['data'];
10
- processResponseError(error: AxiosError): Promise<AxiosError>;
11
- protected handleHttpStatus(response: AxiosResponse): void;
12
- protected handleAuthenticationError(error: AxiosError): void;
13
- protected handleTimeoutError(error: AxiosError): void;
14
- protected handleNetworkError(error: AxiosError): void;
65
+ /**
66
+ * 初始化 SystemErrorDialog 实例
67
+ * 在构造函数中调用,提前加载对话框组件
68
+ * @returns Promise,初始化完成后 resolve
69
+ */
70
+ private initSystemErrorDialog;
71
+ /**
72
+ * 处理成功响应
73
+ * 重写父类方法,在标准 HTTP 成功响应基础上,处理业务特定的响应结构
74
+ * 支持嵌套路径解析,自动处理业务层的登录失效、系统异常等错误
75
+ * 注意:HTTP 层的错误(如 HTTP 401、超时等)由父类 BaseHttpClient 处理
76
+ * @param response - Axios 响应对象
77
+ * @returns 解析后的响应数据
78
+ */
15
79
  protected handleSuccessResponse(response: AxiosResponse): AxiosResponse['data'];
80
+ /**
81
+ * 支持路径解析的辅助函数
82
+ * @param obj - 要解析的对象
83
+ * @param path - 路径字符串,支持点号分隔的嵌套路径,如 'data.errors'
84
+ * @returns 解析后的值,如果路径不存在则返回 undefined
85
+ */
16
86
  protected getValueByPath(obj: any, path: string | undefined): any;
87
+ /**
88
+ * 解析响应字段,支持嵌套路径解析
89
+ * 子类可重写此方法来自定义字段解析逻辑
90
+ * @param data - 响应数据对象
91
+ * @returns 解析后的字段值对象
92
+ */
17
93
  protected parseResponseFields(data: any): {
18
94
  code: any;
19
95
  message: any;
20
96
  responseData: any;
21
97
  };
98
+ /**
99
+ * 处理系统异常错误(-1 - 系统异常)
100
+ * 子类可重写此方法来自定义系统异常处理逻辑
101
+ * @param response - Axios 响应对象
102
+ * @param code - 响应状态码
103
+ * @param message - 错误消息
104
+ * @param responseData - 响应数据
105
+ */
22
106
  protected handleSystemError(response: AxiosResponse, code: any, message: any, responseData: any): void;
23
- protected handleBusinessError(code: any, message: any, response: AxiosResponse): void;
107
+ /**
108
+ * 显示系统错误消息(带可点击 icon)
109
+ * 使用 vNode 渲染,点击 icon 后打开详细错误弹窗
110
+ * @param response - Axios 响应对象
111
+ * @param responseData - 响应数据
112
+ * @param code - 错误状态码
113
+ * @param message - 错误消息
114
+ */
115
+ private showSystemErrorMessage;
116
+ /**
117
+ * 处理业务错误(其他非200错误码)
118
+ * 子类可重写此方法来自定义业务错误处理逻辑
119
+ * @param code - 响应状态码
120
+ * @param message - 错误消息
121
+ */
122
+ protected handleBusinessError(code: any, message: any): void;
123
+ /**
124
+ * 处理错误数组 errors(如果有配置)
125
+ * 子类可重写此方法来自定义错误数组处理逻辑
126
+ * @param httpData - HTTP 响应数据
127
+ * @param response - Axios 响应对象
128
+ */
24
129
  protected handleErrorArray(httpData: any, response: AxiosResponse): void;
130
+ /**
131
+ * 显示通知的通用方法
132
+ * @param items - 通知项数组
133
+ * @param type - 通知类型
134
+ * @param color - HTML 颜色
135
+ * @param notificationOptions - 通知配置选项
136
+ */
137
+ private showNotification;
138
+ /**
139
+ * 显示错误数组通知
140
+ * 子类可重写此方法来自定义错误数组通知显示方式
141
+ * @param errors - 错误数组
142
+ * @param notificationOptions - 通知配置选项
143
+ */
25
144
  protected showErrorArrayNotification(errors: Array<{
26
145
  code: string;
27
146
  message: string;
28
147
  }>, notificationOptions?: NotificationOptions): void;
148
+ /**
149
+ * 处理提示信息 tips(如果有配置)
150
+ * 子类可重写此方法来自定义提示信息处理逻辑
151
+ * @param httpData - HTTP 响应数据
152
+ * @param response - Axios 响应对象
153
+ */
29
154
  protected handleTips(httpData: any, response: AxiosResponse): void;
155
+ /**
156
+ * 显示提示信息通知
157
+ * 子类可重写此方法来自定义提示信息通知显示方式
158
+ * @param tips - 提示信息数组
159
+ * @param notificationOptions - 通知配置选项
160
+ */
30
161
  protected showTipsNotification(tips: Array<{
31
162
  code: string;
32
163
  message: string;
33
164
  }>, notificationOptions?: NotificationOptions): void;
34
- private showSystemExceptionDialog;
35
- protected reportError(errorInfo: any): Promise<void>;
165
+ /**
166
+ * 发送 HTTP 请求,所有 HTTP 方法最终都调用此方法
167
+ * 显式声明以确保类型一致性,子类可重写此方法
168
+ * @param config - Axios 请求配置对象
169
+ * @returns 解析后的响应数据
170
+ */
36
171
  protected request<R>(config: ExtendedAxiosRequestConfig): Promise<AxiosResponse['data']>;
172
+ /**
173
+ * 发送 GET 请求
174
+ * 显式声明以确保类型一致性,子类可重写此方法
175
+ * @param url - 请求 URL 路径
176
+ * @param params - 查询参数对象
177
+ * @param config - 额外的请求配置
178
+ * @returns 解析后的响应数据
179
+ */
37
180
  get<R>(url: string, params?: Record<string, any>, config?: ExtendedAxiosRequestConfig): Promise<AxiosResponse['data']>;
181
+ /**
182
+ * 发送 POST 请求
183
+ * 显式声明以确保类型一致性,子类可重写此方法
184
+ * @param url - 请求 URL 路径
185
+ * @param data - 请求体数据
186
+ * @param config - 额外的请求配置
187
+ * @returns 解析后的响应数据
188
+ */
38
189
  post<R>(url: string, data?: Record<string, any>, config?: ExtendedAxiosRequestConfig): Promise<AxiosResponse['data']>;
190
+ /**
191
+ * 发送 DELETE 请求
192
+ * 显式声明以确保类型一致性,子类可重写此方法
193
+ * @param url - 请求 URL 路径
194
+ * @param params - 查询参数对象
195
+ * @param config - 额外的请求配置
196
+ * @returns 解析后的响应数据
197
+ */
39
198
  delete<R>(url: string, params?: Record<string, any>, config?: ExtendedAxiosRequestConfig): Promise<AxiosResponse['data']>;
199
+ /**
200
+ * 发送 PUT 请求
201
+ * 显式声明以确保类型一致性,子类可重写此方法
202
+ * @param url - 请求 URL 路径
203
+ * @param data - 请求体数据
204
+ * @param config - 额外的请求配置
205
+ * @returns 解析后的响应数据
206
+ */
40
207
  put<R>(url: string, data?: Record<string, any>, config?: ExtendedAxiosRequestConfig): Promise<AxiosResponse['data']>;
208
+ /**
209
+ * 批量请求,并发发送多个请求
210
+ * 显式声明以确保类型一致性,子类可重写此方法
211
+ * @param requests - 请求配置数组或已发起的请求 Promise 数组
212
+ * @returns 所有请求的响应数据数组
213
+ */
41
214
  all<R>(requests: Array<ExtendedAxiosRequestConfig | Promise<AxiosResponse<R>>>): Promise<AxiosResponse['data'][]>;
215
+ /**
216
+ * 文件上传,将文件包装为 FormData 发送
217
+ * 显式声明以确保类型一致性,子类可重写此方法
218
+ * @param url - 上传地址
219
+ * @param file - 文件对象
220
+ * @param config - 额外的请求配置
221
+ * @returns 解析后的响应数据
222
+ */
42
223
  uploadFile<R>(url: string, file: File | Blob, config?: ExtendedAxiosRequestConfig): Promise<AxiosResponse['data']>;
224
+ /**
225
+ * 下载文件,将 Blob 对象下载到本地
226
+ * 显式声明以确保类型一致性,子类可重写此方法
227
+ * @param blob - Blob 对象
228
+ * @param filename - 文件名,如果不提供则使用时间戳
229
+ */
43
230
  downloadFile(blob: Blob, filename?: string): void;
44
231
  }