@moluoxixi/ajax-package 0.0.14 → 0.0.16
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.
- package/es/index.mjs +278 -4
- package/package.json +1 -1
- package/es/BaseHttpClient.d.ts +0 -31
- package/es/SystemErrorDialog.d.ts +0 -125
- package/es/_types/api.d.ts +0 -29
- package/es/_types/emits.d.ts +0 -6
- package/es/_types/index.d.ts +0 -4
- package/es/_types/props.d.ts +0 -13
- package/es/_utils/index.d.ts +0 -3
- package/es/_utils/messageWrapper.d.ts +0 -35
- package/es/_utils/notificationWrapper.d.ts +0 -8
- package/es/_utils/systemErrorInfo.d.ts +0 -6
- package/es/class.d.ts +0 -43
- package/es/index.d.ts +0 -6
- package/es/netseriver.d.ts +0 -12
- package/es/test/utils/BaseRequestApi.d.ts +0 -9
- package/es/test/utils/DownloadApi.d.ts +0 -21
- package/es/test/utils/RoleApi.d.ts +0 -4
- package/es/test/utils/UserApi.d.ts +0 -4
- package/es/test/utils/index.d.ts +0 -9
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("
|
|
5
|
+
if (!document.getElementById("14c6052f-e4ae-4502-9336-1f25c81ac076")) {
|
|
6
6
|
var elementStyle = document.createElement("style");
|
|
7
|
-
elementStyle.id = "
|
|
7
|
+
elementStyle.id = "14c6052f-e4ae-4502-9336-1f25c81ac076";
|
|
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: 非浏览器环境,无法下载文件");
|
|
@@ -12333,7 +12436,7 @@ class BaseHttpClient {
|
|
|
12333
12436
|
link.download = filename || `download-${Date.now()}`;
|
|
12334
12437
|
document.body.appendChild(link);
|
|
12335
12438
|
link.click();
|
|
12336
|
-
|
|
12439
|
+
link.remove();
|
|
12337
12440
|
window.URL.revokeObjectURL(url);
|
|
12338
12441
|
}
|
|
12339
12442
|
}
|
|
@@ -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);
|
|
@@ -12541,6 +12697,12 @@ class BaseApi extends BaseHttpClient {
|
|
|
12541
12697
|
this.handleTips(responseData);
|
|
12542
12698
|
return responseData;
|
|
12543
12699
|
}
|
|
12700
|
+
/**
|
|
12701
|
+
* 解析响应字段,支持嵌套路径解析
|
|
12702
|
+
* 子类可重写此方法来自定义字段解析逻辑
|
|
12703
|
+
* @param data - 响应数据对象
|
|
12704
|
+
* @returns 解析后的字段值对象
|
|
12705
|
+
*/
|
|
12544
12706
|
parseResponseFields(data) {
|
|
12545
12707
|
var _a2, _b, _c;
|
|
12546
12708
|
const getValueByPath = (obj, path) => {
|
|
@@ -12562,6 +12724,14 @@ class BaseApi extends BaseHttpClient {
|
|
|
12562
12724
|
const responseData = getValueByPath(data, (_c = this.responseFields) == null ? void 0 : _c.data);
|
|
12563
12725
|
return { code, message: message2, responseData };
|
|
12564
12726
|
}
|
|
12727
|
+
/**
|
|
12728
|
+
* 处理系统异常错误(-1 - 系统异常)
|
|
12729
|
+
* 子类可重写此方法来自定义系统异常处理逻辑
|
|
12730
|
+
* @param response - Axios 响应对象
|
|
12731
|
+
* @param code - 响应状态码
|
|
12732
|
+
* @param message - 错误消息
|
|
12733
|
+
* @param responseData - 响应数据
|
|
12734
|
+
*/
|
|
12565
12735
|
handleSystemError(response, code, message2, responseData) {
|
|
12566
12736
|
if (code === -1) {
|
|
12567
12737
|
if (this.enableSystemErrorDialog) {
|
|
@@ -12572,6 +12742,12 @@ class BaseApi extends BaseHttpClient {
|
|
|
12572
12742
|
throw new Error(message2 || "系统异常");
|
|
12573
12743
|
}
|
|
12574
12744
|
}
|
|
12745
|
+
/**
|
|
12746
|
+
* 处理业务错误(其他非200错误码)
|
|
12747
|
+
* 子类可重写此方法来自定义业务错误处理逻辑
|
|
12748
|
+
* @param code - 响应状态码
|
|
12749
|
+
* @param message - 错误消息
|
|
12750
|
+
*/
|
|
12575
12751
|
handleBusinessError(code, message2) {
|
|
12576
12752
|
var _a2;
|
|
12577
12753
|
if (code && code !== 200) {
|
|
@@ -12582,6 +12758,11 @@ class BaseApi extends BaseHttpClient {
|
|
|
12582
12758
|
throw new Error(message2 || "请求失败");
|
|
12583
12759
|
}
|
|
12584
12760
|
}
|
|
12761
|
+
/**
|
|
12762
|
+
* 处理错误数组 errors(如果有配置)
|
|
12763
|
+
* 子类可重写此方法来自定义错误数组处理逻辑
|
|
12764
|
+
* @param responseData - 响应数据
|
|
12765
|
+
*/
|
|
12585
12766
|
handleErrorArray(responseData) {
|
|
12586
12767
|
var _a2;
|
|
12587
12768
|
const errorsField = (_a2 = this.responseFields) == null ? void 0 : _a2.errors;
|
|
@@ -12593,6 +12774,11 @@ class BaseApi extends BaseHttpClient {
|
|
|
12593
12774
|
}
|
|
12594
12775
|
}
|
|
12595
12776
|
}
|
|
12777
|
+
/**
|
|
12778
|
+
* 显示错误数组通知
|
|
12779
|
+
* 子类可重写此方法来自定义错误数组通知显示方式
|
|
12780
|
+
* @param errors - 错误数组
|
|
12781
|
+
*/
|
|
12596
12782
|
showErrorArrayNotification(errors) {
|
|
12597
12783
|
var _a2, _b;
|
|
12598
12784
|
const html = errors.map((item) => `<div style="font-size: 14px;color:red">${item.code}:${item.message}</div>`).join("");
|
|
@@ -12611,6 +12797,11 @@ class BaseApi extends BaseHttpClient {
|
|
|
12611
12797
|
});
|
|
12612
12798
|
}
|
|
12613
12799
|
}
|
|
12800
|
+
/**
|
|
12801
|
+
* 处理提示信息 tips(如果有配置)
|
|
12802
|
+
* 子类可重写此方法来自定义提示信息处理逻辑
|
|
12803
|
+
* @param responseData - 响应数据
|
|
12804
|
+
*/
|
|
12614
12805
|
handleTips(responseData) {
|
|
12615
12806
|
var _a2;
|
|
12616
12807
|
const tipsField = (_a2 = this.responseFields) == null ? void 0 : _a2.tips;
|
|
@@ -12621,6 +12812,11 @@ class BaseApi extends BaseHttpClient {
|
|
|
12621
12812
|
}
|
|
12622
12813
|
}
|
|
12623
12814
|
}
|
|
12815
|
+
/**
|
|
12816
|
+
* 显示提示信息通知
|
|
12817
|
+
* 子类可重写此方法来自定义提示信息通知显示方式
|
|
12818
|
+
* @param tips - 提示信息数组
|
|
12819
|
+
*/
|
|
12624
12820
|
showTipsNotification(tips) {
|
|
12625
12821
|
var _a2, _b;
|
|
12626
12822
|
const html = tips.map((item) => `<div style="font-size: 14px;color:#E6A23C">${item.code}:${item.message}</div>`).join("");
|
|
@@ -12639,6 +12835,13 @@ class BaseApi extends BaseHttpClient {
|
|
|
12639
12835
|
});
|
|
12640
12836
|
}
|
|
12641
12837
|
}
|
|
12838
|
+
/**
|
|
12839
|
+
* 显示系统异常对话框,当响应状态码为 -1 时调用
|
|
12840
|
+
* @param response - Axios 响应对象
|
|
12841
|
+
* @param responseData - 响应数据
|
|
12842
|
+
* @param code - 错误状态码
|
|
12843
|
+
* @param message - 错误消息
|
|
12844
|
+
*/
|
|
12642
12845
|
async showSystemExceptionDialog(response, responseData, code, message2) {
|
|
12643
12846
|
if (!hasDocument) {
|
|
12644
12847
|
console.error("系统异常信息:", responseData);
|
|
@@ -12677,6 +12880,10 @@ class BaseApi extends BaseHttpClient {
|
|
|
12677
12880
|
console.error("系统异常信息:", responseData);
|
|
12678
12881
|
}
|
|
12679
12882
|
}
|
|
12883
|
+
/**
|
|
12884
|
+
* 上报错误信息到服务器,默认实现仅显示提示,子类可重写实现真实上报
|
|
12885
|
+
* @param errorInfo - 错误信息对象
|
|
12886
|
+
*/
|
|
12680
12887
|
async reportError(errorInfo) {
|
|
12681
12888
|
var _a2, _b;
|
|
12682
12889
|
try {
|
|
@@ -12694,27 +12901,85 @@ class BaseApi extends BaseHttpClient {
|
|
|
12694
12901
|
});
|
|
12695
12902
|
}
|
|
12696
12903
|
}
|
|
12904
|
+
/**
|
|
12905
|
+
* 发送 HTTP 请求,所有 HTTP 方法最终都调用此方法
|
|
12906
|
+
* 显式声明以确保类型一致性,子类可重写此方法
|
|
12907
|
+
* @param config - Axios 请求配置对象
|
|
12908
|
+
* @returns 解析后的响应数据
|
|
12909
|
+
*/
|
|
12697
12910
|
async request(config) {
|
|
12698
12911
|
return super.request(config);
|
|
12699
12912
|
}
|
|
12913
|
+
/**
|
|
12914
|
+
* 发送 GET 请求
|
|
12915
|
+
* 显式声明以确保类型一致性,子类可重写此方法
|
|
12916
|
+
* @param url - 请求 URL 路径
|
|
12917
|
+
* @param params - 查询参数对象
|
|
12918
|
+
* @param config - 额外的请求配置
|
|
12919
|
+
* @returns 解析后的响应数据
|
|
12920
|
+
*/
|
|
12700
12921
|
async get(url, params, config) {
|
|
12701
12922
|
return super.get(url, params, config);
|
|
12702
12923
|
}
|
|
12924
|
+
/**
|
|
12925
|
+
* 发送 POST 请求
|
|
12926
|
+
* 显式声明以确保类型一致性,子类可重写此方法
|
|
12927
|
+
* @param url - 请求 URL 路径
|
|
12928
|
+
* @param data - 请求体数据
|
|
12929
|
+
* @param config - 额外的请求配置
|
|
12930
|
+
* @returns 解析后的响应数据
|
|
12931
|
+
*/
|
|
12703
12932
|
async post(url, data, config) {
|
|
12704
12933
|
return super.post(url, data, config);
|
|
12705
12934
|
}
|
|
12935
|
+
/**
|
|
12936
|
+
* 发送 DELETE 请求
|
|
12937
|
+
* 显式声明以确保类型一致性,子类可重写此方法
|
|
12938
|
+
* @param url - 请求 URL 路径
|
|
12939
|
+
* @param params - 查询参数对象
|
|
12940
|
+
* @param config - 额外的请求配置
|
|
12941
|
+
* @returns 解析后的响应数据
|
|
12942
|
+
*/
|
|
12706
12943
|
async delete(url, params, config) {
|
|
12707
12944
|
return super.delete(url, params, config);
|
|
12708
12945
|
}
|
|
12946
|
+
/**
|
|
12947
|
+
* 发送 PUT 请求
|
|
12948
|
+
* 显式声明以确保类型一致性,子类可重写此方法
|
|
12949
|
+
* @param url - 请求 URL 路径
|
|
12950
|
+
* @param data - 请求体数据
|
|
12951
|
+
* @param config - 额外的请求配置
|
|
12952
|
+
* @returns 解析后的响应数据
|
|
12953
|
+
*/
|
|
12709
12954
|
async put(url, data, config) {
|
|
12710
12955
|
return super.put(url, data, config);
|
|
12711
12956
|
}
|
|
12957
|
+
/**
|
|
12958
|
+
* 批量请求,并发发送多个请求
|
|
12959
|
+
* 显式声明以确保类型一致性,子类可重写此方法
|
|
12960
|
+
* @param requests - 请求配置数组或已发起的请求 Promise 数组
|
|
12961
|
+
* @returns 所有请求的响应数据数组
|
|
12962
|
+
*/
|
|
12712
12963
|
async all(requests) {
|
|
12713
12964
|
return super.all(requests);
|
|
12714
12965
|
}
|
|
12966
|
+
/**
|
|
12967
|
+
* 文件上传,将文件包装为 FormData 发送
|
|
12968
|
+
* 显式声明以确保类型一致性,子类可重写此方法
|
|
12969
|
+
* @param url - 上传地址
|
|
12970
|
+
* @param file - 文件对象
|
|
12971
|
+
* @param config - 额外的请求配置
|
|
12972
|
+
* @returns 解析后的响应数据
|
|
12973
|
+
*/
|
|
12715
12974
|
async uploadFile(url, file, config) {
|
|
12716
12975
|
return super.uploadFile(url, file, config);
|
|
12717
12976
|
}
|
|
12977
|
+
/**
|
|
12978
|
+
* 下载文件,将 Blob 对象下载到本地
|
|
12979
|
+
* 显式声明以确保类型一致性,子类可重写此方法
|
|
12980
|
+
* @param blob - Blob 对象
|
|
12981
|
+
* @param filename - 文件名,如果不提供则使用时间戳
|
|
12982
|
+
*/
|
|
12718
12983
|
downloadFile(blob, filename) {
|
|
12719
12984
|
return super.downloadFile(blob, filename);
|
|
12720
12985
|
}
|
|
@@ -12723,6 +12988,11 @@ function createHttpService(options = {}) {
|
|
|
12723
12988
|
return new BaseApi(options);
|
|
12724
12989
|
}
|
|
12725
12990
|
const VueAxiosPlugin = {
|
|
12991
|
+
/**
|
|
12992
|
+
* 安装插件
|
|
12993
|
+
* @param app - Vue 应用实例
|
|
12994
|
+
* @param options - 插件配置选项
|
|
12995
|
+
*/
|
|
12726
12996
|
install(app, options = {}) {
|
|
12727
12997
|
const httpService = createHttpService(options.default ?? {});
|
|
12728
12998
|
app.config.globalProperties.$http = httpService;
|
|
@@ -12903,10 +13173,12 @@ const SystemErrorDialog = defineComponent({
|
|
|
12903
13173
|
h("span", { style: { fontWeight: "bold", fontSize: "16px" } }, props.title || "系统异常信息")
|
|
12904
13174
|
]),
|
|
12905
13175
|
default: () => h("div", { style: { padding: 0, maxHeight: "500px", overflowY: "auto" } }, [
|
|
13176
|
+
// 第一块:无法完成您的请求
|
|
12906
13177
|
h("div", { style: { padding: "20px", borderBottom: "1px solid #ebeef5" } }, [
|
|
12907
13178
|
h("h3", { style: { margin: "0 0 12px 0", fontSize: "16px", fontWeight: "bold", color: "#303133" } }, "无法完成您的请求"),
|
|
12908
13179
|
h("p", { style: { margin: 0, color: "#606266", lineHeight: 1.5 } }, "系统在处理您的请求时遇到了问题,可能是由于服务暂时不可用。")
|
|
12909
13180
|
]),
|
|
13181
|
+
// 第二块:技术摘要(可展开)
|
|
12910
13182
|
h("div", { style: { borderBottom: "1px solid #ebeef5" } }, [
|
|
12911
13183
|
h(
|
|
12912
13184
|
"div",
|
|
@@ -12968,6 +13240,7 @@ const SystemErrorDialog = defineComponent({
|
|
|
12968
13240
|
)
|
|
12969
13241
|
) : null
|
|
12970
13242
|
]),
|
|
13243
|
+
// SkyWalking 按钮
|
|
12971
13244
|
h("div", { style: { padding: "16px 20px", borderBottom: "1px solid #ebeef5" } }, [
|
|
12972
13245
|
h(
|
|
12973
13246
|
ElButton,
|
|
@@ -12979,9 +13252,10 @@ const SystemErrorDialog = defineComponent({
|
|
|
12979
13252
|
{ default: () => "📊 在SkyWalking中查看详情" }
|
|
12980
13253
|
)
|
|
12981
13254
|
]),
|
|
13255
|
+
// 黑色错误信息区域
|
|
12982
13256
|
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" } }, [
|
|
12983
13257
|
h("div", { style: { marginBottom: "8px", color: "#ecf0f1" } }, `Trace ID: ${props.traceId || "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8"}`),
|
|
12984
|
-
h("div", { style: { color: "#e74c3c", fontWeight: "bold" } }, `Error: ${props.errorMessage || "Connection timeout after 5000ms"}`)
|
|
13258
|
+
h("div", { style: { color: "#e74c3c", fontWeight: "bold", whiteSpace: "pre-wrap" } }, `Error: ${props.errorMessage || "Connection timeout after 5000ms"}`)
|
|
12985
13259
|
])
|
|
12986
13260
|
]),
|
|
12987
13261
|
footer: () => h("div", { style: { display: "flex", justifyContent: "flex-end", alignItems: "center", paddingTop: "16px" } }, [
|
package/package.json
CHANGED
package/es/BaseHttpClient.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AxiosError, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig, default as axios } from 'axios';
|
|
2
|
-
import { BaseHttpClientConfig } from './_types/index.ts';
|
|
3
|
-
import { MessageInstance, NotificationInstance } from './_utils/index.ts';
|
|
4
|
-
export default class BaseHttpClient {
|
|
5
|
-
protected baseURL: string;
|
|
6
|
-
protected timeout: number;
|
|
7
|
-
protected onTimeout: (messageInstance: MessageInstance) => void;
|
|
8
|
-
protected getToken?: () => string | null;
|
|
9
|
-
protected onLoginRequired?: (messageInstance: MessageInstance) => void;
|
|
10
|
-
instance: ReturnType<typeof axios.create>;
|
|
11
|
-
protected messageInstance: MessageInstance;
|
|
12
|
-
protected notificationInstance: NotificationInstance;
|
|
13
|
-
constructor(config: BaseHttpClientConfig);
|
|
14
|
-
processRequestConfig(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig<any>;
|
|
15
|
-
processResponseConfig(response: AxiosResponse): AxiosResponse['data'];
|
|
16
|
-
protected handleHttpStatus(response: AxiosResponse): void;
|
|
17
|
-
protected handleSuccessResponse(response: AxiosResponse): AxiosResponse['data'];
|
|
18
|
-
processResponseError(error: AxiosError): Promise<AxiosError>;
|
|
19
|
-
protected handleAuthenticationError(error: AxiosError): void;
|
|
20
|
-
protected handleTimeoutError(error: AxiosError): void;
|
|
21
|
-
protected handleNetworkError(error: AxiosError): void;
|
|
22
|
-
private setupInterceptors;
|
|
23
|
-
protected request<R>(config: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
24
|
-
get<R>(url: string, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
25
|
-
post<R>(url: string, data?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
26
|
-
delete<R>(url: string, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
27
|
-
put<R>(url: string, data?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
28
|
-
all<R>(requests: Array<AxiosRequestConfig | Promise<AxiosResponse<R>>>): Promise<AxiosResponse['data'][]>;
|
|
29
|
-
uploadFile<R>(url: string, file: File | Blob, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
30
|
-
downloadFile(blob: Blob, filename?: string): void;
|
|
31
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
2
|
-
title: {
|
|
3
|
-
type: StringConstructor;
|
|
4
|
-
default: string;
|
|
5
|
-
};
|
|
6
|
-
width: {
|
|
7
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
8
|
-
default: number;
|
|
9
|
-
};
|
|
10
|
-
userName: {
|
|
11
|
-
type: StringConstructor;
|
|
12
|
-
default: undefined;
|
|
13
|
-
};
|
|
14
|
-
userId: {
|
|
15
|
-
type: StringConstructor;
|
|
16
|
-
default: undefined;
|
|
17
|
-
};
|
|
18
|
-
deptName: {
|
|
19
|
-
type: StringConstructor;
|
|
20
|
-
default: undefined;
|
|
21
|
-
};
|
|
22
|
-
deptId: {
|
|
23
|
-
type: StringConstructor;
|
|
24
|
-
default: undefined;
|
|
25
|
-
};
|
|
26
|
-
clientIp: {
|
|
27
|
-
type: StringConstructor;
|
|
28
|
-
default: undefined;
|
|
29
|
-
};
|
|
30
|
-
requestUrl: {
|
|
31
|
-
type: StringConstructor;
|
|
32
|
-
default: undefined;
|
|
33
|
-
};
|
|
34
|
-
traceId: {
|
|
35
|
-
type: StringConstructor;
|
|
36
|
-
default: undefined;
|
|
37
|
-
};
|
|
38
|
-
errorMessage: {
|
|
39
|
-
type: StringConstructor;
|
|
40
|
-
default: undefined;
|
|
41
|
-
};
|
|
42
|
-
errorCode: {
|
|
43
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
44
|
-
default: undefined;
|
|
45
|
-
};
|
|
46
|
-
modelValue: {
|
|
47
|
-
type: BooleanConstructor;
|
|
48
|
-
default: boolean;
|
|
49
|
-
};
|
|
50
|
-
}>, () => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
51
|
-
[key: string]: any;
|
|
52
|
-
}>, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
53
|
-
'update:modelValue': (val: boolean) => true;
|
|
54
|
-
close: () => true;
|
|
55
|
-
confirm: (data: any) => true;
|
|
56
|
-
report: () => true;
|
|
57
|
-
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
58
|
-
title: {
|
|
59
|
-
type: StringConstructor;
|
|
60
|
-
default: string;
|
|
61
|
-
};
|
|
62
|
-
width: {
|
|
63
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
64
|
-
default: number;
|
|
65
|
-
};
|
|
66
|
-
userName: {
|
|
67
|
-
type: StringConstructor;
|
|
68
|
-
default: undefined;
|
|
69
|
-
};
|
|
70
|
-
userId: {
|
|
71
|
-
type: StringConstructor;
|
|
72
|
-
default: undefined;
|
|
73
|
-
};
|
|
74
|
-
deptName: {
|
|
75
|
-
type: StringConstructor;
|
|
76
|
-
default: undefined;
|
|
77
|
-
};
|
|
78
|
-
deptId: {
|
|
79
|
-
type: StringConstructor;
|
|
80
|
-
default: undefined;
|
|
81
|
-
};
|
|
82
|
-
clientIp: {
|
|
83
|
-
type: StringConstructor;
|
|
84
|
-
default: undefined;
|
|
85
|
-
};
|
|
86
|
-
requestUrl: {
|
|
87
|
-
type: StringConstructor;
|
|
88
|
-
default: undefined;
|
|
89
|
-
};
|
|
90
|
-
traceId: {
|
|
91
|
-
type: StringConstructor;
|
|
92
|
-
default: undefined;
|
|
93
|
-
};
|
|
94
|
-
errorMessage: {
|
|
95
|
-
type: StringConstructor;
|
|
96
|
-
default: undefined;
|
|
97
|
-
};
|
|
98
|
-
errorCode: {
|
|
99
|
-
type: (StringConstructor | NumberConstructor)[];
|
|
100
|
-
default: undefined;
|
|
101
|
-
};
|
|
102
|
-
modelValue: {
|
|
103
|
-
type: BooleanConstructor;
|
|
104
|
-
default: boolean;
|
|
105
|
-
};
|
|
106
|
-
}>> & Readonly<{
|
|
107
|
-
onClose?: (() => any) | undefined;
|
|
108
|
-
onConfirm?: ((data: any) => any) | undefined;
|
|
109
|
-
"onUpdate:modelValue"?: ((val: boolean) => any) | undefined;
|
|
110
|
-
onReport?: (() => any) | undefined;
|
|
111
|
-
}>, {
|
|
112
|
-
title: string;
|
|
113
|
-
width: string | number;
|
|
114
|
-
userName: string;
|
|
115
|
-
userId: string;
|
|
116
|
-
deptName: string;
|
|
117
|
-
deptId: string;
|
|
118
|
-
clientIp: string;
|
|
119
|
-
requestUrl: string;
|
|
120
|
-
traceId: string;
|
|
121
|
-
errorMessage: string;
|
|
122
|
-
errorCode: string | number;
|
|
123
|
-
modelValue: boolean;
|
|
124
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
125
|
-
export default _default;
|
package/es/_types/api.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { App } from 'vue';
|
|
2
|
-
import { MessageInstance } from '../_utils/index.ts';
|
|
3
|
-
import { default as BaseApi } from '../class.ts';
|
|
4
|
-
export interface BaseHttpClientConfig {
|
|
5
|
-
baseURL?: string;
|
|
6
|
-
timeout?: number;
|
|
7
|
-
onTimeout?: (messageInstance: MessageInstance) => void;
|
|
8
|
-
getToken?: () => string | null;
|
|
9
|
-
onLoginRequired?: (messageInstance: MessageInstance) => void;
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
}
|
|
12
|
-
export interface BaseApiConfig extends BaseHttpClientConfig {
|
|
13
|
-
responseFields?: {
|
|
14
|
-
code?: string;
|
|
15
|
-
message?: string;
|
|
16
|
-
data?: string;
|
|
17
|
-
errors?: string;
|
|
18
|
-
tips?: string;
|
|
19
|
-
};
|
|
20
|
-
enableSystemErrorDialog?: boolean;
|
|
21
|
-
}
|
|
22
|
-
export interface vueAxiosPluginOptionsType {
|
|
23
|
-
default?: BaseApiConfig;
|
|
24
|
-
globalMixin?: boolean;
|
|
25
|
-
}
|
|
26
|
-
export type vueHttpServiceType = BaseApi;
|
|
27
|
-
export interface vueAxiosPluginType {
|
|
28
|
-
install: (app: App, options?: vueAxiosPluginOptionsType) => void;
|
|
29
|
-
}
|
package/es/_types/emits.d.ts
DELETED
package/es/_types/index.d.ts
DELETED
package/es/_types/props.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface SystemErrorDialogPropsType {
|
|
2
|
-
title?: string;
|
|
3
|
-
width?: number | string;
|
|
4
|
-
userName?: string;
|
|
5
|
-
userId?: string;
|
|
6
|
-
deptName?: string;
|
|
7
|
-
deptId?: string;
|
|
8
|
-
clientIp?: string;
|
|
9
|
-
requestUrl?: string;
|
|
10
|
-
traceId?: string;
|
|
11
|
-
errorMessage?: string;
|
|
12
|
-
errorCode?: number | string;
|
|
13
|
-
}
|
package/es/_utils/index.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export declare function createMessageWrapper(): (import('element-plus').MessageFn & {
|
|
2
|
-
primary: import('element-plus').MessageTypedFn;
|
|
3
|
-
success: import('element-plus').MessageTypedFn;
|
|
4
|
-
warning: import('element-plus').MessageTypedFn;
|
|
5
|
-
info: import('element-plus').MessageTypedFn;
|
|
6
|
-
error: import('element-plus').MessageTypedFn;
|
|
7
|
-
} & import('vue').ObjectPlugin<any[]> & {
|
|
8
|
-
_context: import('vue').AppContext | null;
|
|
9
|
-
}) | (import('element-plus').MessageFn & {
|
|
10
|
-
primary: import('element-plus').MessageTypedFn;
|
|
11
|
-
success: import('element-plus').MessageTypedFn;
|
|
12
|
-
warning: import('element-plus').MessageTypedFn;
|
|
13
|
-
info: import('element-plus').MessageTypedFn;
|
|
14
|
-
error: import('element-plus').MessageTypedFn;
|
|
15
|
-
} & ((app: import('vue').App, ...options: any[]) => any) & Partial<import('vue').ObjectPlugin<any[]>> & {
|
|
16
|
-
_context: import('vue').AppContext | null;
|
|
17
|
-
}) | {
|
|
18
|
-
success: (options: string | {
|
|
19
|
-
message?: string;
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
}) => void;
|
|
22
|
-
error: (options: string | {
|
|
23
|
-
message?: string;
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
}) => void;
|
|
26
|
-
warning: (options: string | {
|
|
27
|
-
message?: string;
|
|
28
|
-
[key: string]: any;
|
|
29
|
-
}) => void;
|
|
30
|
-
info: (options: string | {
|
|
31
|
-
message?: string;
|
|
32
|
-
[key: string]: any;
|
|
33
|
-
}) => void;
|
|
34
|
-
};
|
|
35
|
-
export type MessageInstance = ReturnType<typeof createMessageWrapper>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function createNotificationWrapper(): ((import('element-plus').Notify & import('vue').Plugin) & {
|
|
2
|
-
_context: import('vue').AppContext | null;
|
|
3
|
-
}) | ((options: string | {
|
|
4
|
-
message?: string;
|
|
5
|
-
title?: string;
|
|
6
|
-
type?: "success" | "error" | "warning" | "info";
|
|
7
|
-
}) => void);
|
|
8
|
-
export type NotificationInstance = ReturnType<typeof createNotificationWrapper>;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse } from 'axios';
|
|
2
|
-
import { SystemErrorDialogPropsType } from '../_types/index.ts';
|
|
3
|
-
export declare function normalizePayload(payload: any): Record<string, any>;
|
|
4
|
-
export declare function resolveTraceId(headers: AxiosResponse['headers'] | undefined): string;
|
|
5
|
-
export declare function getUserInfoFromLocalStorage(): Record<string, any>;
|
|
6
|
-
export declare function extractSystemErrorInfo(response: AxiosResponse, code: number, message: string): Omit<SystemErrorDialogPropsType, 'title' | 'width'>;
|
package/es/class.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { AxiosError, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import { BaseApiConfig } from './_types/index.ts';
|
|
3
|
-
import { default as BaseHttpClient } from './BaseHttpClient.ts';
|
|
4
|
-
export default class BaseApi extends BaseHttpClient {
|
|
5
|
-
protected responseFields: Required<BaseApiConfig['responseFields']>;
|
|
6
|
-
protected enableSystemErrorDialog: boolean;
|
|
7
|
-
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;
|
|
15
|
-
protected handleSuccessResponse(response: AxiosResponse): AxiosResponse['data'];
|
|
16
|
-
protected parseResponseFields(data: any): {
|
|
17
|
-
code: any;
|
|
18
|
-
message: any;
|
|
19
|
-
responseData: any;
|
|
20
|
-
};
|
|
21
|
-
protected handleSystemError(response: AxiosResponse, code: any, message: any, responseData: any): void;
|
|
22
|
-
protected handleBusinessError(code: any, message: any): void;
|
|
23
|
-
protected handleErrorArray(responseData: any): void;
|
|
24
|
-
protected showErrorArrayNotification(errors: Array<{
|
|
25
|
-
code: string;
|
|
26
|
-
message: string;
|
|
27
|
-
}>): void;
|
|
28
|
-
protected handleTips(responseData: any): void;
|
|
29
|
-
protected showTipsNotification(tips: Array<{
|
|
30
|
-
code: string;
|
|
31
|
-
message: string;
|
|
32
|
-
}>): void;
|
|
33
|
-
private showSystemExceptionDialog;
|
|
34
|
-
protected reportError(errorInfo: any): Promise<void>;
|
|
35
|
-
protected request<R>(config: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
36
|
-
get<R>(url: string, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
37
|
-
post<R>(url: string, data?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
38
|
-
delete<R>(url: string, params?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
39
|
-
put<R>(url: string, data?: Record<string, any>, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
40
|
-
all<R>(requests: Array<AxiosRequestConfig | Promise<AxiosResponse<R>>>): Promise<AxiosResponse['data'][]>;
|
|
41
|
-
uploadFile<R>(url: string, file: File | Blob, config?: AxiosRequestConfig): Promise<AxiosResponse['data']>;
|
|
42
|
-
downloadFile(blob: Blob, filename?: string): void;
|
|
43
|
-
}
|
package/es/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { default as BaseHttpClient } from './BaseHttpClient.ts';
|
|
2
|
-
import { default as BaseApi } from './class.ts';
|
|
3
|
-
import { default as VueAxiosPlugin, createHttpService, getHttpService } from './netseriver.ts';
|
|
4
|
-
export { BaseApi, BaseHttpClient, createHttpService, getHttpService, VueAxiosPlugin, };
|
|
5
|
-
export type { BaseApiConfig, BaseHttpClientConfig, vueAxiosPluginOptionsType, vueAxiosPluginType, vueHttpServiceType, } from './_types/index.ts';
|
|
6
|
-
export default getHttpService;
|
package/es/netseriver.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseApiConfig, vueAxiosPluginType, vueHttpServiceType } from './_types/index.ts';
|
|
2
|
-
import { default as BaseApi } from './class.ts';
|
|
3
|
-
declare global {
|
|
4
|
-
interface Window {
|
|
5
|
-
$http?: vueHttpServiceType;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
declare function createHttpService(options?: BaseApiConfig): BaseApi;
|
|
9
|
-
declare const VueAxiosPlugin: vueAxiosPluginType;
|
|
10
|
-
declare function getHttpService(options?: BaseApiConfig): BaseApi;
|
|
11
|
-
export default VueAxiosPlugin;
|
|
12
|
-
export { createHttpService, getHttpService };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import { BaseApi, BaseApiConfig } from '@moluoxixi/ajax-package';
|
|
3
|
-
export default class BaseRequestApi extends BaseApi {
|
|
4
|
-
constructor(config?: Partial<BaseApiConfig>);
|
|
5
|
-
processRequestConfig(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig;
|
|
6
|
-
protected handleSuccessResponse(response: AxiosResponse): AxiosResponse['data'];
|
|
7
|
-
protected handleHttpStatus(response: AxiosResponse): void;
|
|
8
|
-
protected handleBusinessError(code: any, message: any): void;
|
|
9
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AxiosError, AxiosRequestConfig, AxiosResponse, InternalAxiosRequestConfig } from 'axios';
|
|
2
|
-
import { default as BaseRequestApi } from './BaseRequestApi.ts';
|
|
3
|
-
export default class DownloadApi extends BaseRequestApi {
|
|
4
|
-
private downloadingFiles;
|
|
5
|
-
constructor();
|
|
6
|
-
processRequestConfig(config: InternalAxiosRequestConfig): InternalAxiosRequestConfig;
|
|
7
|
-
processResponseError(error: AxiosError): Promise<AxiosError>;
|
|
8
|
-
protected handleSuccessResponse(response: AxiosResponse): AxiosResponse['data'];
|
|
9
|
-
downloadFileFromUrl(url: string, filename?: string, params?: Record<string, any>, data?: Record<string, any>, method?: 'get' | 'post', config?: AxiosRequestConfig): Promise<boolean>;
|
|
10
|
-
private getFilenameFromUrl;
|
|
11
|
-
downloadMultipleFiles(files: Array<{
|
|
12
|
-
url: string;
|
|
13
|
-
filename?: string;
|
|
14
|
-
params?: Record<string, any>;
|
|
15
|
-
data?: Record<string, any>;
|
|
16
|
-
method?: 'get' | 'post';
|
|
17
|
-
}>, onProgress?: (progress: number, currentFile: string) => void): Promise<{
|
|
18
|
-
success: number;
|
|
19
|
-
total: number;
|
|
20
|
-
}>;
|
|
21
|
-
}
|
package/es/test/utils/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { default as DownloadApi } from './DownloadApi.ts';
|
|
2
|
-
import { default as BaseRequestApi } from './BaseRequestApi.ts';
|
|
3
|
-
import { default as UserApi } from './UserApi.ts';
|
|
4
|
-
import { default as RoleApi } from './RoleApi.ts';
|
|
5
|
-
export declare const downloadRequest: DownloadApi;
|
|
6
|
-
export declare const userRequest: any;
|
|
7
|
-
export declare const baseRequest: any;
|
|
8
|
-
export declare const roleRequest: any;
|
|
9
|
-
export { DownloadApi, BaseRequestApi, UserApi, RoleApi, };
|