@moluoxixi/ajax-package 0.0.17 → 0.0.18

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,66 @@ 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;
22
42
  }
43
+ /**
44
+ * Vue Axios 插件配置选项
45
+ */
23
46
  export interface vueAxiosPluginOptionsType {
47
+ /** 默认 HTTP 服务配置 */
24
48
  default?: BaseApiConfig;
49
+ /** 是否在所有组件中通过 mixin 注入 $http,默认为 true */
25
50
  globalMixin?: boolean;
26
51
  }
52
+ /**
53
+ * Vue HTTP 服务类型,在 Vue 应用中通过 this.$http 或 inject('$http') 获取
54
+ */
27
55
  export type vueHttpServiceType = BaseApi;
56
+ /**
57
+ * Vue Axios 插件类型,定义了 Vue 插件的标准接口
58
+ */
28
59
  export interface vueAxiosPluginType {
60
+ /**
61
+ * 安装插件
62
+ * @param app - Vue 应用实例
63
+ * @param options - 插件配置选项
64
+ */
29
65
  install: (app: App, options?: vueAxiosPluginOptionsType) => void;
30
66
  }
31
67
  /**
@@ -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,219 @@
1
1
  import { AxiosError, AxiosResponse, InternalAxiosRequestConfig } 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
+ /**
13
+ * 创建 BaseApi 实例
14
+ * @param config - API 配置对象
15
+ */
7
16
  constructor(config: BaseApiConfig);
17
+ /**
18
+ * 处理请求配置,子类可重写此方法自定义请求配置
19
+ * 显式声明以确保类型一致性,避免打包后的类型不兼容问题
20
+ * @param config - 请求配置对象
21
+ * @returns 处理后的请求配置
22
+ */
8
23
  processRequestConfig(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig;
24
+ /**
25
+ * 处理响应配置,子类可重写此方法自定义响应处理
26
+ * 显式声明以确保类型一致性,避免打包后的类型不兼容问题
27
+ * @param response - Axios 响应对象
28
+ * @returns 解析后的响应数据
29
+ */
9
30
  processResponseConfig(response: AxiosResponse): AxiosResponse['data'];
31
+ /**
32
+ * 处理响应错误,子类可重写此方法自定义错误处理
33
+ * 显式声明以确保类型一致性,避免打包后的类型不兼容问题
34
+ * @param error - Axios 错误对象
35
+ * @returns 处理后的错误对象
36
+ */
10
37
  processResponseError(error: AxiosError): Promise<AxiosError>;
38
+ /**
39
+ * 处理 HTTP 状态码
40
+ * 重写父类方法,确保子类可以重写此方法
41
+ * @param response - Axios 响应对象
42
+ */
11
43
  protected handleHttpStatus(response: AxiosResponse): void;
44
+ /**
45
+ * 处理认证错误(401 - 未授权/登录失效)
46
+ * 重写父类方法,处理 HTTP 401 错误
47
+ * 子类可重写此方法来自定义 HTTP 认证错误处理逻辑
48
+ * @param error - Axios 错误对象
49
+ */
12
50
  protected handleAuthenticationError(error: AxiosError): void;
51
+ /**
52
+ * 处理超时错误
53
+ * 重写父类方法,确保子类可以重写此方法
54
+ * @param error - Axios 错误对象
55
+ */
13
56
  protected handleTimeoutError(error: AxiosError): void;
57
+ /**
58
+ * 处理网络错误(其他错误)
59
+ * 重写父类方法,确保子类可以重写此方法
60
+ * @param error - Axios 错误对象
61
+ */
14
62
  protected handleNetworkError(error: AxiosError): void;
63
+ /**
64
+ * 处理成功响应
65
+ * 重写父类方法,在标准 HTTP 成功响应基础上,处理业务特定的响应结构
66
+ * 支持嵌套路径解析,自动处理业务层的登录失效、系统异常等错误
67
+ * 注意:HTTP 层的错误(如 HTTP 401、超时等)由父类 BaseHttpClient 处理
68
+ * @param response - Axios 响应对象
69
+ * @returns 解析后的响应数据
70
+ */
15
71
  protected handleSuccessResponse(response: AxiosResponse): AxiosResponse['data'];
72
+ /**
73
+ * 支持路径解析的辅助函数
74
+ * @param obj
75
+ * @param path
76
+ * @protected
77
+ */
16
78
  protected getValueByPath(obj: any, path: string | undefined): any;
79
+ /**
80
+ * 解析响应字段,支持嵌套路径解析
81
+ * 子类可重写此方法来自定义字段解析逻辑
82
+ * @param data - 响应数据对象
83
+ * @returns 解析后的字段值对象
84
+ */
17
85
  protected parseResponseFields(data: any): {
18
86
  code: any;
19
87
  message: any;
20
88
  responseData: any;
21
89
  };
90
+ /**
91
+ * 处理系统异常错误(-1 - 系统异常)
92
+ * 子类可重写此方法来自定义系统异常处理逻辑
93
+ * @param response - Axios 响应对象
94
+ * @param code - 响应状态码
95
+ * @param message - 错误消息
96
+ * @param responseData - 响应数据
97
+ */
22
98
  protected handleSystemError(response: AxiosResponse, code: any, message: any, responseData: any): void;
23
- protected handleBusinessError(code: any, message: any, response: AxiosResponse): void;
99
+ /**
100
+ * 处理业务错误(其他非200错误码)
101
+ * 子类可重写此方法来自定义业务错误处理逻辑
102
+ * @param code - 响应状态码
103
+ * @param message - 错误消息
104
+ */
105
+ protected handleBusinessError(code: any, message: any): void;
106
+ /**
107
+ * 处理错误数组 errors(如果有配置)
108
+ * 子类可重写此方法来自定义错误数组处理逻辑
109
+ * @param httpData
110
+ * @param response
111
+ */
24
112
  protected handleErrorArray(httpData: any, response: AxiosResponse): void;
113
+ /**
114
+ * 显示错误数组通知
115
+ * 子类可重写此方法来自定义错误数组通知显示方式
116
+ * @param errors - 错误数组
117
+ * @param notificationOptions
118
+ */
25
119
  protected showErrorArrayNotification(errors: Array<{
26
120
  code: string;
27
121
  message: string;
28
122
  }>, notificationOptions?: NotificationOptions): void;
123
+ /**
124
+ * 处理提示信息 tips(如果有配置)
125
+ * 子类可重写此方法来自定义提示信息处理逻辑
126
+ * @param httpData
127
+ * @param response
128
+ */
29
129
  protected handleTips(httpData: any, response: AxiosResponse): void;
130
+ /**
131
+ * 显示提示信息通知
132
+ * 子类可重写此方法来自定义提示信息通知显示方式
133
+ * @param tips - 提示信息数组
134
+ * @param notificationOptions
135
+ */
30
136
  protected showTipsNotification(tips: Array<{
31
137
  code: string;
32
138
  message: string;
33
139
  }>, notificationOptions?: NotificationOptions): void;
140
+ /**
141
+ * 显示系统异常对话框,当响应状态码为 -1 时调用
142
+ * @param response - Axios 响应对象
143
+ * @param responseData - 响应数据
144
+ * @param code - 错误状态码
145
+ * @param message - 错误消息
146
+ */
34
147
  private showSystemExceptionDialog;
148
+ /**
149
+ * 上报错误信息到服务器,默认实现仅显示提示,子类可重写实现真实上报
150
+ * @param errorInfo - 错误信息对象
151
+ */
35
152
  protected reportError(errorInfo: any): Promise<void>;
153
+ /**
154
+ * 发送 HTTP 请求,所有 HTTP 方法最终都调用此方法
155
+ * 显式声明以确保类型一致性,子类可重写此方法
156
+ * @param config - Axios 请求配置对象
157
+ * @returns 解析后的响应数据
158
+ */
36
159
  protected request<R>(config: ExtendedAxiosRequestConfig): Promise<AxiosResponse['data']>;
160
+ /**
161
+ * 发送 GET 请求
162
+ * 显式声明以确保类型一致性,子类可重写此方法
163
+ * @param url - 请求 URL 路径
164
+ * @param params - 查询参数对象
165
+ * @param config - 额外的请求配置
166
+ * @returns 解析后的响应数据
167
+ */
37
168
  get<R>(url: string, params?: Record<string, any>, config?: ExtendedAxiosRequestConfig): Promise<AxiosResponse['data']>;
169
+ /**
170
+ * 发送 POST 请求
171
+ * 显式声明以确保类型一致性,子类可重写此方法
172
+ * @param url - 请求 URL 路径
173
+ * @param data - 请求体数据
174
+ * @param config - 额外的请求配置
175
+ * @returns 解析后的响应数据
176
+ */
38
177
  post<R>(url: string, data?: Record<string, any>, config?: ExtendedAxiosRequestConfig): Promise<AxiosResponse['data']>;
178
+ /**
179
+ * 发送 DELETE 请求
180
+ * 显式声明以确保类型一致性,子类可重写此方法
181
+ * @param url - 请求 URL 路径
182
+ * @param params - 查询参数对象
183
+ * @param config - 额外的请求配置
184
+ * @returns 解析后的响应数据
185
+ */
39
186
  delete<R>(url: string, params?: Record<string, any>, config?: ExtendedAxiosRequestConfig): Promise<AxiosResponse['data']>;
187
+ /**
188
+ * 发送 PUT 请求
189
+ * 显式声明以确保类型一致性,子类可重写此方法
190
+ * @param url - 请求 URL 路径
191
+ * @param data - 请求体数据
192
+ * @param config - 额外的请求配置
193
+ * @returns 解析后的响应数据
194
+ */
40
195
  put<R>(url: string, data?: Record<string, any>, config?: ExtendedAxiosRequestConfig): Promise<AxiosResponse['data']>;
196
+ /**
197
+ * 批量请求,并发发送多个请求
198
+ * 显式声明以确保类型一致性,子类可重写此方法
199
+ * @param requests - 请求配置数组或已发起的请求 Promise 数组
200
+ * @returns 所有请求的响应数据数组
201
+ */
41
202
  all<R>(requests: Array<ExtendedAxiosRequestConfig | Promise<AxiosResponse<R>>>): Promise<AxiosResponse['data'][]>;
203
+ /**
204
+ * 文件上传,将文件包装为 FormData 发送
205
+ * 显式声明以确保类型一致性,子类可重写此方法
206
+ * @param url - 上传地址
207
+ * @param file - 文件对象
208
+ * @param config - 额外的请求配置
209
+ * @returns 解析后的响应数据
210
+ */
42
211
  uploadFile<R>(url: string, file: File | Blob, config?: ExtendedAxiosRequestConfig): Promise<AxiosResponse['data']>;
212
+ /**
213
+ * 下载文件,将 Blob 对象下载到本地
214
+ * 显式声明以确保类型一致性,子类可重写此方法
215
+ * @param blob - Blob 对象
216
+ * @param filename - 文件名,如果不提供则使用时间戳
217
+ */
43
218
  downloadFile(blob: Blob, filename?: string): void;
44
219
  }
package/es/index.mjs CHANGED
@@ -2,9 +2,9 @@
2
2
  "use strict";
3
3
  try {
4
4
  if (typeof document !== "undefined") {
5
- if (!document.getElementById("75b05bee-ad6e-4470-b902-2118b507f825")) {
5
+ if (!document.getElementById("fff2b744-05a5-42b2-a548-d0942177ace6")) {
6
6
  var elementStyle = document.createElement("style");
7
- elementStyle.id = "75b05bee-ad6e-4470-b902-2118b507f825";
7
+ elementStyle.id = "fff2b744-05a5-42b2-a548-d0942177ace6";
8
8
  elementStyle.appendChild(document.createTextNode("._root_11p33_1 .el-dialog__header {\n padding: 0 12px 12px;\n}\n\n._root_11p33_1 .el-dialog__body {\n border-top: 1px solid #e5e7eb;\n border-bottom: 1px solid #e5e7eb;\n padding: 0 12px;\n}\n\n._root_11p33_1 .el-dialog__footer {\n padding: 0 12px;\n}"));
9
9
  document.head.appendChild(elementStyle);
10
10
  }
@@ -12183,6 +12183,10 @@ function defaultGetToken() {
12183
12183
  return typeof localStorage !== "undefined" ? localStorage.getItem("token") || "" : "";
12184
12184
  }
12185
12185
  class BaseHttpClient {
12186
+ /**
12187
+ * 创建 BaseHttpClient 实例
12188
+ * @param config - HTTP 客户端配置对象
12189
+ */
12186
12190
  constructor(config) {
12187
12191
  __publicField(this, "baseURL", "");
12188
12192
  __publicField(this, "timeout", 5e3);
@@ -12212,42 +12216,86 @@ class BaseHttpClient {
12212
12216
  baseURL: this.baseURL,
12213
12217
  timeout: this.timeout,
12214
12218
  ...axiosConfig
12219
+ // 将所有剩余参数传给axios.create
12215
12220
  });
12216
12221
  this.setupInterceptors();
12217
12222
  }
12223
+ /**
12224
+ * 处理请求配置,子类可重写此方法自定义请求配置
12225
+ * @param config - 请求配置对象
12226
+ * @returns 处理后的请求配置
12227
+ */
12218
12228
  processRequestConfig(config) {
12219
12229
  return config;
12220
12230
  }
12231
+ /**
12232
+ * 处理响应配置,子类可重写此方法自定义响应处理
12233
+ * 按照标准 HTTP 结构处理响应
12234
+ * @param response - Axios 响应对象
12235
+ * @returns 解析后的响应数据
12236
+ */
12221
12237
  processResponseConfig(response) {
12222
12238
  this.handleHttpStatus(response);
12223
12239
  return this.handleSuccessResponse(response);
12224
12240
  }
12241
+ /**
12242
+ * 处理 HTTP 状态码
12243
+ * 子类可重写此方法来自定义 HTTP 状态码处理逻辑
12244
+ * @param response - Axios 响应对象
12245
+ */
12225
12246
  handleHttpStatus(response) {
12226
12247
  var _a2;
12227
12248
  if (response.status !== 200) {
12228
12249
  throw new Error(((_a2 = response.data) == null ? void 0 : _a2.message) || `HTTP Error: ${response.status}`);
12229
12250
  }
12230
12251
  }
12252
+ /**
12253
+ * 处理成功响应
12254
+ * 子类可重写此方法来自定义成功响应的处理逻辑
12255
+ * @param response - Axios 响应对象
12256
+ * @returns 解析后的响应数据
12257
+ */
12231
12258
  handleSuccessResponse(response) {
12232
12259
  return response.data;
12233
12260
  }
12261
+ /**
12262
+ * 处理响应错误,子类可重写此方法自定义错误处理
12263
+ * 按照标准 HTTP 错误结构处理错误
12264
+ * @param error - Axios 错误对象
12265
+ * @returns 处理后的错误对象
12266
+ */
12234
12267
  async processResponseError(error) {
12235
12268
  this.handleAuthenticationError(error);
12236
12269
  this.handleTimeoutError(error);
12237
12270
  this.handleNetworkError(error);
12238
12271
  return error;
12239
12272
  }
12273
+ /**
12274
+ * 处理认证错误(401 - 未授权/登录失效)
12275
+ * 子类可重写此方法来自定义认证错误处理逻辑
12276
+ * @param error - Axios 错误对象
12277
+ */
12240
12278
  handleAuthenticationError(error) {
12241
12279
  var _a2, _b;
12242
12280
  if (((_a2 = error.response) == null ? void 0 : _a2.status) === 401) {
12243
12281
  (_b = this.onLoginRequired) == null ? void 0 : _b.call(this, this.messageInstance);
12244
12282
  }
12245
12283
  }
12284
+ /**
12285
+ * 处理超时错误
12286
+ * 子类可重写此方法来自定义超时错误处理逻辑
12287
+ * @param error - Axios 错误对象
12288
+ */
12246
12289
  handleTimeoutError(error) {
12247
12290
  if (error.code === "ECONNABORTED" && error.message.includes("timeout")) {
12248
12291
  this.onTimeout(this.messageInstance);
12249
12292
  }
12250
12293
  }
12294
+ /**
12295
+ * 处理网络错误(其他错误)
12296
+ * 子类可重写此方法来自定义网络错误处理逻辑
12297
+ * @param error - Axios 错误对象
12298
+ */
12251
12299
  handleNetworkError(error) {
12252
12300
  var _a2, _b, _c;
12253
12301
  if (((_a2 = error.response) == null ? void 0 : _a2.status) !== 401 && error.code !== "ECONNABORTED") {
@@ -12258,6 +12306,11 @@ class BaseHttpClient {
12258
12306
  });
12259
12307
  }
12260
12308
  }
12309
+ /**
12310
+ * 设置请求和响应拦截器
12311
+ * 请求拦截器:自动添加 Token
12312
+ * 响应拦截器:处理成功响应和错误响应(401、超时等)
12313
+ */
12261
12314
  setupInterceptors() {
12262
12315
  this.instance.interceptors.request.use(
12263
12316
  (config) => {
@@ -12284,21 +12337,59 @@ class BaseHttpClient {
12284
12337
  }
12285
12338
  );
12286
12339
  }
12340
+ /**
12341
+ * 发送 HTTP 请求,所有 HTTP 方法最终都调用此方法
12342
+ * @param config - Axios 请求配置对象
12343
+ * @returns 解析后的响应数据
12344
+ */
12287
12345
  async request(config) {
12288
12346
  return this.instance.request(config);
12289
12347
  }
12348
+ /**
12349
+ * 发送 GET 请求
12350
+ * @param url - 请求 URL 路径
12351
+ * @param params - 查询参数对象
12352
+ * @param config - 额外的请求配置
12353
+ * @returns 解析后的响应数据
12354
+ */
12290
12355
  async get(url, params, config) {
12291
12356
  return this.request({ ...config, url, method: "get", params });
12292
12357
  }
12358
+ /**
12359
+ * 发送 POST 请求
12360
+ * @param url - 请求 URL 路径
12361
+ * @param data - 请求体数据
12362
+ * @param config - 额外的请求配置
12363
+ * @returns 解析后的响应数据
12364
+ */
12293
12365
  async post(url, data, config) {
12294
12366
  return this.request({ ...config, url, method: "post", data });
12295
12367
  }
12368
+ /**
12369
+ * 发送 DELETE 请求
12370
+ * @param url - 请求 URL 路径
12371
+ * @param params - 查询参数对象
12372
+ * @param config - 额外的请求配置
12373
+ * @returns 解析后的响应数据
12374
+ */
12296
12375
  async delete(url, params, config) {
12297
12376
  return this.request({ ...config, url, method: "delete", params });
12298
12377
  }
12378
+ /**
12379
+ * 发送 PUT 请求
12380
+ * @param url - 请求 URL 路径
12381
+ * @param data - 请求体数据
12382
+ * @param config - 额外的请求配置
12383
+ * @returns 解析后的响应数据
12384
+ */
12299
12385
  async put(url, data, config) {
12300
12386
  return this.request({ ...config, url, method: "put", data });
12301
12387
  }
12388
+ /**
12389
+ * 批量请求,并发发送多个请求
12390
+ * @param requests - 请求配置数组或已发起的请求 Promise 数组
12391
+ * @returns 所有请求的响应数据数组
12392
+ */
12302
12393
  async all(requests) {
12303
12394
  if (!requests.length)
12304
12395
  return [];
@@ -12311,6 +12402,13 @@ class BaseHttpClient {
12311
12402
  const promises = requests.map((config) => this.request(config));
12312
12403
  return await Promise.all(promises);
12313
12404
  }
12405
+ /**
12406
+ * 文件上传,将文件包装为 FormData 发送
12407
+ * @param url - 上传地址
12408
+ * @param file - 文件对象
12409
+ * @param config - 额外的请求配置
12410
+ * @returns 解析后的响应数据
12411
+ */
12314
12412
  async uploadFile(url, file, config) {
12315
12413
  const formData = new FormData();
12316
12414
  formData.append("file", file);
@@ -12322,6 +12420,11 @@ class BaseHttpClient {
12322
12420
  }
12323
12421
  });
12324
12422
  }
12423
+ /**
12424
+ * 下载文件,将 Blob 对象下载到本地
12425
+ * @param blob - Blob 对象
12426
+ * @param filename - 文件名,如果不提供则使用时间戳
12427
+ */
12325
12428
  downloadFile(blob, filename) {
12326
12429
  if (typeof window === "undefined") {
12327
12430
  console.warn("downloadFile: 非浏览器环境,无法下载文件");
@@ -12437,10 +12540,12 @@ function createApiDialog(DialogComponent) {
12437
12540
  cleanup();
12438
12541
  }
12439
12542
  },
12543
+ // 监听关闭事件
12440
12544
  onClose: () => {
12441
12545
  reject(new Error("对话框已关闭"));
12442
12546
  cleanup();
12443
12547
  },
12548
+ // 监听确认事件(如有)
12444
12549
  onConfirm: (data) => {
12445
12550
  resolve(data);
12446
12551
  cleanup();
@@ -12491,6 +12596,10 @@ function createApiDialog(DialogComponent) {
12491
12596
  const hasDocument = typeof document !== "undefined";
12492
12597
  let systemErrorDialogInstance = null;
12493
12598
  class BaseApi extends BaseHttpClient {
12599
+ /**
12600
+ * 创建 BaseApi 实例
12601
+ * @param config - API 配置对象
12602
+ */
12494
12603
  constructor(config) {
12495
12604
  const {
12496
12605
  responseFields,
@@ -12510,27 +12619,74 @@ class BaseApi extends BaseHttpClient {
12510
12619
  };
12511
12620
  this.enableSystemErrorDialog = enableSystemErrorDialog;
12512
12621
  }
12622
+ /**
12623
+ * 处理请求配置,子类可重写此方法自定义请求配置
12624
+ * 显式声明以确保类型一致性,避免打包后的类型不兼容问题
12625
+ * @param config - 请求配置对象
12626
+ * @returns 处理后的请求配置
12627
+ */
12513
12628
  processRequestConfig(config) {
12514
12629
  return super.processRequestConfig(config);
12515
12630
  }
12631
+ /**
12632
+ * 处理响应配置,子类可重写此方法自定义响应处理
12633
+ * 显式声明以确保类型一致性,避免打包后的类型不兼容问题
12634
+ * @param response - Axios 响应对象
12635
+ * @returns 解析后的响应数据
12636
+ */
12516
12637
  processResponseConfig(response) {
12517
12638
  return super.processResponseConfig(response);
12518
12639
  }
12640
+ /**
12641
+ * 处理响应错误,子类可重写此方法自定义错误处理
12642
+ * 显式声明以确保类型一致性,避免打包后的类型不兼容问题
12643
+ * @param error - Axios 错误对象
12644
+ * @returns 处理后的错误对象
12645
+ */
12519
12646
  async processResponseError(error) {
12520
12647
  return super.processResponseError(error);
12521
12648
  }
12649
+ /**
12650
+ * 处理 HTTP 状态码
12651
+ * 重写父类方法,确保子类可以重写此方法
12652
+ * @param response - Axios 响应对象
12653
+ */
12522
12654
  handleHttpStatus(response) {
12523
12655
  return super.handleHttpStatus(response);
12524
12656
  }
12657
+ /**
12658
+ * 处理认证错误(401 - 未授权/登录失效)
12659
+ * 重写父类方法,处理 HTTP 401 错误
12660
+ * 子类可重写此方法来自定义 HTTP 认证错误处理逻辑
12661
+ * @param error - Axios 错误对象
12662
+ */
12525
12663
  handleAuthenticationError(error) {
12526
12664
  super.handleAuthenticationError(error);
12527
12665
  }
12666
+ /**
12667
+ * 处理超时错误
12668
+ * 重写父类方法,确保子类可以重写此方法
12669
+ * @param error - Axios 错误对象
12670
+ */
12528
12671
  handleTimeoutError(error) {
12529
12672
  return super.handleTimeoutError(error);
12530
12673
  }
12674
+ /**
12675
+ * 处理网络错误(其他错误)
12676
+ * 重写父类方法,确保子类可以重写此方法
12677
+ * @param error - Axios 错误对象
12678
+ */
12531
12679
  handleNetworkError(error) {
12532
12680
  return super.handleNetworkError(error);
12533
12681
  }
12682
+ /**
12683
+ * 处理成功响应
12684
+ * 重写父类方法,在标准 HTTP 成功响应基础上,处理业务特定的响应结构
12685
+ * 支持嵌套路径解析,自动处理业务层的登录失效、系统异常等错误
12686
+ * 注意:HTTP 层的错误(如 HTTP 401、超时等)由父类 BaseHttpClient 处理
12687
+ * @param response - Axios 响应对象
12688
+ * @returns 解析后的响应数据
12689
+ */
12534
12690
  handleSuccessResponse(response) {
12535
12691
  const httpData = super.handleSuccessResponse(response);
12536
12692
  const parsedFields = this.parseResponseFields(httpData);
@@ -12545,6 +12701,12 @@ class BaseApi extends BaseHttpClient {
12545
12701
  }
12546
12702
  return responseData;
12547
12703
  }
12704
+ /**
12705
+ * 支持路径解析的辅助函数
12706
+ * @param obj
12707
+ * @param path
12708
+ * @protected
12709
+ */
12548
12710
  getValueByPath(obj, path) {
12549
12711
  if (!path)
12550
12712
  return obj;
@@ -12559,6 +12721,12 @@ class BaseApi extends BaseHttpClient {
12559
12721
  }
12560
12722
  return result;
12561
12723
  }
12724
+ /**
12725
+ * 解析响应字段,支持嵌套路径解析
12726
+ * 子类可重写此方法来自定义字段解析逻辑
12727
+ * @param data - 响应数据对象
12728
+ * @returns 解析后的字段值对象
12729
+ */
12562
12730
  parseResponseFields(data) {
12563
12731
  var _a2, _b, _c;
12564
12732
  const code = this.getValueByPath(data, (_a2 = this.responseFields) == null ? void 0 : _a2.code);
@@ -12566,6 +12734,14 @@ class BaseApi extends BaseHttpClient {
12566
12734
  const responseData = this.getValueByPath(data, (_c = this.responseFields) == null ? void 0 : _c.data);
12567
12735
  return { code, message: message2, responseData };
12568
12736
  }
12737
+ /**
12738
+ * 处理系统异常错误(-1 - 系统异常)
12739
+ * 子类可重写此方法来自定义系统异常处理逻辑
12740
+ * @param response - Axios 响应对象
12741
+ * @param code - 响应状态码
12742
+ * @param message - 错误消息
12743
+ * @param responseData - 响应数据
12744
+ */
12569
12745
  handleSystemError(response, code, message2, responseData) {
12570
12746
  if (code === -1) {
12571
12747
  if (this.enableSystemErrorDialog) {
@@ -12576,7 +12752,13 @@ class BaseApi extends BaseHttpClient {
12576
12752
  throw new Error(message2 || "系统异常");
12577
12753
  }
12578
12754
  }
12579
- handleBusinessError(code, message2, response) {
12755
+ /**
12756
+ * 处理业务错误(其他非200错误码)
12757
+ * 子类可重写此方法来自定义业务错误处理逻辑
12758
+ * @param code - 响应状态码
12759
+ * @param message - 错误消息
12760
+ */
12761
+ handleBusinessError(code, message2) {
12580
12762
  var _a2;
12581
12763
  if (code && code !== 200) {
12582
12764
  (_a2 = this.messageInstance) == null ? void 0 : _a2.error({
@@ -12586,6 +12768,12 @@ class BaseApi extends BaseHttpClient {
12586
12768
  throw new Error(message2 || "请求失败");
12587
12769
  }
12588
12770
  }
12771
+ /**
12772
+ * 处理错误数组 errors(如果有配置)
12773
+ * 子类可重写此方法来自定义错误数组处理逻辑
12774
+ * @param httpData
12775
+ * @param response
12776
+ */
12589
12777
  handleErrorArray(httpData, response) {
12590
12778
  var _a2;
12591
12779
  const errorsField = (_a2 = this.responseFields) == null ? void 0 : _a2.errors;
@@ -12599,6 +12787,12 @@ class BaseApi extends BaseHttpClient {
12599
12787
  }
12600
12788
  }
12601
12789
  }
12790
+ /**
12791
+ * 显示错误数组通知
12792
+ * 子类可重写此方法来自定义错误数组通知显示方式
12793
+ * @param errors - 错误数组
12794
+ * @param notificationOptions
12795
+ */
12602
12796
  showErrorArrayNotification(errors, notificationOptions) {
12603
12797
  var _a2, _b;
12604
12798
  const html = errors.map((item) => `<div style="font-size: 14px;color:red">${item.code}:${item.message}</div>`).join("");
@@ -12623,6 +12817,12 @@ class BaseApi extends BaseHttpClient {
12623
12817
  (_b = this.notificationInstance) == null ? void 0 : _b.call(this, finalOptions);
12624
12818
  }
12625
12819
  }
12820
+ /**
12821
+ * 处理提示信息 tips(如果有配置)
12822
+ * 子类可重写此方法来自定义提示信息处理逻辑
12823
+ * @param httpData
12824
+ * @param response
12825
+ */
12626
12826
  handleTips(httpData, response) {
12627
12827
  var _a2;
12628
12828
  const tipsField = (_a2 = this.responseFields) == null ? void 0 : _a2.tips;
@@ -12635,6 +12835,12 @@ class BaseApi extends BaseHttpClient {
12635
12835
  }
12636
12836
  }
12637
12837
  }
12838
+ /**
12839
+ * 显示提示信息通知
12840
+ * 子类可重写此方法来自定义提示信息通知显示方式
12841
+ * @param tips - 提示信息数组
12842
+ * @param notificationOptions
12843
+ */
12638
12844
  showTipsNotification(tips, notificationOptions) {
12639
12845
  var _a2, _b;
12640
12846
  const html = tips.map((item) => `<div style="font-size: 14px;color:#E6A23C">${item.code}:${item.message}</div>`).join("");
@@ -12659,6 +12865,13 @@ class BaseApi extends BaseHttpClient {
12659
12865
  (_b = this.notificationInstance) == null ? void 0 : _b.call(this, finalOptions);
12660
12866
  }
12661
12867
  }
12868
+ /**
12869
+ * 显示系统异常对话框,当响应状态码为 -1 时调用
12870
+ * @param response - Axios 响应对象
12871
+ * @param responseData - 响应数据
12872
+ * @param code - 错误状态码
12873
+ * @param message - 错误消息
12874
+ */
12662
12875
  async showSystemExceptionDialog(response, responseData, code, message2) {
12663
12876
  if (!hasDocument) {
12664
12877
  console.error("系统异常信息:", responseData);
@@ -12697,6 +12910,10 @@ class BaseApi extends BaseHttpClient {
12697
12910
  console.error("系统异常信息:", responseData);
12698
12911
  }
12699
12912
  }
12913
+ /**
12914
+ * 上报错误信息到服务器,默认实现仅显示提示,子类可重写实现真实上报
12915
+ * @param errorInfo - 错误信息对象
12916
+ */
12700
12917
  async reportError(errorInfo) {
12701
12918
  var _a2, _b;
12702
12919
  try {
@@ -12714,27 +12931,85 @@ class BaseApi extends BaseHttpClient {
12714
12931
  });
12715
12932
  }
12716
12933
  }
12934
+ /**
12935
+ * 发送 HTTP 请求,所有 HTTP 方法最终都调用此方法
12936
+ * 显式声明以确保类型一致性,子类可重写此方法
12937
+ * @param config - Axios 请求配置对象
12938
+ * @returns 解析后的响应数据
12939
+ */
12717
12940
  async request(config) {
12718
12941
  return super.request(config);
12719
12942
  }
12943
+ /**
12944
+ * 发送 GET 请求
12945
+ * 显式声明以确保类型一致性,子类可重写此方法
12946
+ * @param url - 请求 URL 路径
12947
+ * @param params - 查询参数对象
12948
+ * @param config - 额外的请求配置
12949
+ * @returns 解析后的响应数据
12950
+ */
12720
12951
  async get(url, params, config) {
12721
12952
  return super.get(url, params, config);
12722
12953
  }
12954
+ /**
12955
+ * 发送 POST 请求
12956
+ * 显式声明以确保类型一致性,子类可重写此方法
12957
+ * @param url - 请求 URL 路径
12958
+ * @param data - 请求体数据
12959
+ * @param config - 额外的请求配置
12960
+ * @returns 解析后的响应数据
12961
+ */
12723
12962
  async post(url, data, config) {
12724
12963
  return super.post(url, data, config);
12725
12964
  }
12965
+ /**
12966
+ * 发送 DELETE 请求
12967
+ * 显式声明以确保类型一致性,子类可重写此方法
12968
+ * @param url - 请求 URL 路径
12969
+ * @param params - 查询参数对象
12970
+ * @param config - 额外的请求配置
12971
+ * @returns 解析后的响应数据
12972
+ */
12726
12973
  async delete(url, params, config) {
12727
12974
  return super.delete(url, params, config);
12728
12975
  }
12976
+ /**
12977
+ * 发送 PUT 请求
12978
+ * 显式声明以确保类型一致性,子类可重写此方法
12979
+ * @param url - 请求 URL 路径
12980
+ * @param data - 请求体数据
12981
+ * @param config - 额外的请求配置
12982
+ * @returns 解析后的响应数据
12983
+ */
12729
12984
  async put(url, data, config) {
12730
12985
  return super.put(url, data, config);
12731
12986
  }
12987
+ /**
12988
+ * 批量请求,并发发送多个请求
12989
+ * 显式声明以确保类型一致性,子类可重写此方法
12990
+ * @param requests - 请求配置数组或已发起的请求 Promise 数组
12991
+ * @returns 所有请求的响应数据数组
12992
+ */
12732
12993
  async all(requests) {
12733
12994
  return super.all(requests);
12734
12995
  }
12996
+ /**
12997
+ * 文件上传,将文件包装为 FormData 发送
12998
+ * 显式声明以确保类型一致性,子类可重写此方法
12999
+ * @param url - 上传地址
13000
+ * @param file - 文件对象
13001
+ * @param config - 额外的请求配置
13002
+ * @returns 解析后的响应数据
13003
+ */
12735
13004
  async uploadFile(url, file, config) {
12736
13005
  return super.uploadFile(url, file, config);
12737
13006
  }
13007
+ /**
13008
+ * 下载文件,将 Blob 对象下载到本地
13009
+ * 显式声明以确保类型一致性,子类可重写此方法
13010
+ * @param blob - Blob 对象
13011
+ * @param filename - 文件名,如果不提供则使用时间戳
13012
+ */
12738
13013
  downloadFile(blob, filename) {
12739
13014
  return super.downloadFile(blob, filename);
12740
13015
  }
@@ -12743,6 +13018,11 @@ function createHttpService(options = {}) {
12743
13018
  return new BaseApi(options);
12744
13019
  }
12745
13020
  const VueAxiosPlugin = {
13021
+ /**
13022
+ * 安装插件
13023
+ * @param app - Vue 应用实例
13024
+ * @param options - 插件配置选项
13025
+ */
12746
13026
  install(app, options = {}) {
12747
13027
  const httpService = createHttpService(options.default ?? {});
12748
13028
  app.config.globalProperties.$http = httpService;
@@ -12923,10 +13203,12 @@ const SystemErrorDialog = defineComponent({
12923
13203
  h("span", { style: { fontWeight: "bold", fontSize: "16px" } }, props.title || "系统异常信息")
12924
13204
  ]),
12925
13205
  default: () => h("div", { style: { padding: 0, maxHeight: "500px", overflowY: "auto" } }, [
13206
+ // 第一块:无法完成您的请求
12926
13207
  h("div", { style: { padding: "20px", borderBottom: "1px solid #ebeef5" } }, [
12927
13208
  h("h3", { style: { margin: "0 0 12px 0", fontSize: "16px", fontWeight: "bold", color: "#303133" } }, "无法完成您的请求"),
12928
13209
  h("p", { style: { margin: 0, color: "#606266", lineHeight: 1.5 } }, "系统在处理您的请求时遇到了问题,可能是由于服务暂时不可用。")
12929
13210
  ]),
13211
+ // 第二块:技术摘要(可展开)
12930
13212
  h("div", { style: { borderBottom: "1px solid #ebeef5" } }, [
12931
13213
  h(
12932
13214
  "div",
@@ -12988,6 +13270,7 @@ const SystemErrorDialog = defineComponent({
12988
13270
  )
12989
13271
  ) : null
12990
13272
  ]),
13273
+ // SkyWalking 按钮
12991
13274
  h("div", { style: { padding: "16px 20px", borderBottom: "1px solid #ebeef5" } }, [
12992
13275
  h(
12993
13276
  ElButton,
@@ -12999,6 +13282,7 @@ const SystemErrorDialog = defineComponent({
12999
13282
  { default: () => "📊 在SkyWalking中查看详情" }
13000
13283
  )
13001
13284
  ]),
13285
+ // 黑色错误信息区域
13002
13286
  h("div", { style: { backgroundColor: "#2c3e50", color: "#fff", padding: "16px 20px", fontFamily: 'Monaco, Consolas, "Courier New", monospace', fontSize: "12px", lineHeight: 1.5, maxHeight: "200px", overflowY: "auto" } }, [
13003
13287
  h("div", { style: { marginBottom: "8px", color: "#ecf0f1" } }, `Trace ID: ${props.traceId || "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8"}`),
13004
13288
  h("div", { style: { color: "#e74c3c", fontWeight: "bold", whiteSpace: "pre-wrap" } }, `Error: ${props.errorMessage || "Connection timeout after 5000ms"}`)
@@ -5,8 +5,22 @@ declare global {
5
5
  $http?: vueHttpServiceType;
6
6
  }
7
7
  }
8
+ /**
9
+ * 创建 HTTP 服务实例
10
+ * @param options - API 配置对象
11
+ * @returns BaseApi 实例
12
+ */
8
13
  declare function createHttpService(options?: BaseApiConfig): BaseApi;
14
+ /**
15
+ * Vue Axios 插件,用于在 Vue 应用中全局注册 HTTP 服务
16
+ * 提供 this.$http、inject('$http') 和 window.$http 三种使用方式
17
+ */
9
18
  declare const VueAxiosPlugin: vueAxiosPluginType;
19
+ /**
20
+ * 获取 HTTP 服务实例,与 createHttpService 功能相同
21
+ * @param options - API 配置对象
22
+ * @returns BaseApi 实例
23
+ */
10
24
  declare function getHttpService(options?: BaseApiConfig): BaseApi;
11
25
  export default VueAxiosPlugin;
12
26
  export { createHttpService, getHttpService };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moluoxixi/ajax-package",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "AjaxPackage 组件",
5
5
  "sideEffects": [
6
6
  "*.css",