@moluoxixi/ajax-package 0.0.15 → 0.0.17

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 CHANGED
@@ -2,9 +2,9 @@
2
2
  "use strict";
3
3
  try {
4
4
  if (typeof document !== "undefined") {
5
- if (!document.getElementById("ffe3dd99-bf7e-4730-8936-fd7b509c3c02")) {
5
+ if (!document.getElementById("75b05bee-ad6e-4470-b902-2118b507f825")) {
6
6
  var elementStyle = document.createElement("style");
7
- elementStyle.id = "ffe3dd99-bf7e-4730-8936-fd7b509c3c02";
7
+ elementStyle.id = "75b05bee-ad6e-4470-b902-2118b507f825";
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,10 +12183,6 @@ 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
- */
12190
12186
  constructor(config) {
12191
12187
  __publicField(this, "baseURL", "");
12192
12188
  __publicField(this, "timeout", 5e3);
@@ -12216,86 +12212,42 @@ class BaseHttpClient {
12216
12212
  baseURL: this.baseURL,
12217
12213
  timeout: this.timeout,
12218
12214
  ...axiosConfig
12219
- // 将所有剩余参数传给axios.create
12220
12215
  });
12221
12216
  this.setupInterceptors();
12222
12217
  }
12223
- /**
12224
- * 处理请求配置,子类可重写此方法自定义请求配置
12225
- * @param config - 请求配置对象
12226
- * @returns 处理后的请求配置
12227
- */
12228
12218
  processRequestConfig(config) {
12229
12219
  return config;
12230
12220
  }
12231
- /**
12232
- * 处理响应配置,子类可重写此方法自定义响应处理
12233
- * 按照标准 HTTP 结构处理响应
12234
- * @param response - Axios 响应对象
12235
- * @returns 解析后的响应数据
12236
- */
12237
12221
  processResponseConfig(response) {
12238
12222
  this.handleHttpStatus(response);
12239
12223
  return this.handleSuccessResponse(response);
12240
12224
  }
12241
- /**
12242
- * 处理 HTTP 状态码
12243
- * 子类可重写此方法来自定义 HTTP 状态码处理逻辑
12244
- * @param response - Axios 响应对象
12245
- */
12246
12225
  handleHttpStatus(response) {
12247
12226
  var _a2;
12248
12227
  if (response.status !== 200) {
12249
12228
  throw new Error(((_a2 = response.data) == null ? void 0 : _a2.message) || `HTTP Error: ${response.status}`);
12250
12229
  }
12251
12230
  }
12252
- /**
12253
- * 处理成功响应
12254
- * 子类可重写此方法来自定义成功响应的处理逻辑
12255
- * @param response - Axios 响应对象
12256
- * @returns 解析后的响应数据
12257
- */
12258
12231
  handleSuccessResponse(response) {
12259
12232
  return response.data;
12260
12233
  }
12261
- /**
12262
- * 处理响应错误,子类可重写此方法自定义错误处理
12263
- * 按照标准 HTTP 错误结构处理错误
12264
- * @param error - Axios 错误对象
12265
- * @returns 处理后的错误对象
12266
- */
12267
12234
  async processResponseError(error) {
12268
12235
  this.handleAuthenticationError(error);
12269
12236
  this.handleTimeoutError(error);
12270
12237
  this.handleNetworkError(error);
12271
12238
  return error;
12272
12239
  }
12273
- /**
12274
- * 处理认证错误(401 - 未授权/登录失效)
12275
- * 子类可重写此方法来自定义认证错误处理逻辑
12276
- * @param error - Axios 错误对象
12277
- */
12278
12240
  handleAuthenticationError(error) {
12279
12241
  var _a2, _b;
12280
12242
  if (((_a2 = error.response) == null ? void 0 : _a2.status) === 401) {
12281
12243
  (_b = this.onLoginRequired) == null ? void 0 : _b.call(this, this.messageInstance);
12282
12244
  }
12283
12245
  }
12284
- /**
12285
- * 处理超时错误
12286
- * 子类可重写此方法来自定义超时错误处理逻辑
12287
- * @param error - Axios 错误对象
12288
- */
12289
12246
  handleTimeoutError(error) {
12290
12247
  if (error.code === "ECONNABORTED" && error.message.includes("timeout")) {
12291
12248
  this.onTimeout(this.messageInstance);
12292
12249
  }
12293
12250
  }
12294
- /**
12295
- * 处理网络错误(其他错误)
12296
- * 子类可重写此方法来自定义网络错误处理逻辑
12297
- * @param error - Axios 错误对象
12298
- */
12299
12251
  handleNetworkError(error) {
12300
12252
  var _a2, _b, _c;
12301
12253
  if (((_a2 = error.response) == null ? void 0 : _a2.status) !== 401 && error.code !== "ECONNABORTED") {
@@ -12306,11 +12258,6 @@ class BaseHttpClient {
12306
12258
  });
12307
12259
  }
12308
12260
  }
12309
- /**
12310
- * 设置请求和响应拦截器
12311
- * 请求拦截器:自动添加 Token
12312
- * 响应拦截器:处理成功响应和错误响应(401、超时等)
12313
- */
12314
12261
  setupInterceptors() {
12315
12262
  this.instance.interceptors.request.use(
12316
12263
  (config) => {
@@ -12337,59 +12284,21 @@ class BaseHttpClient {
12337
12284
  }
12338
12285
  );
12339
12286
  }
12340
- /**
12341
- * 发送 HTTP 请求,所有 HTTP 方法最终都调用此方法
12342
- * @param config - Axios 请求配置对象
12343
- * @returns 解析后的响应数据
12344
- */
12345
12287
  async request(config) {
12346
12288
  return this.instance.request(config);
12347
12289
  }
12348
- /**
12349
- * 发送 GET 请求
12350
- * @param url - 请求 URL 路径
12351
- * @param params - 查询参数对象
12352
- * @param config - 额外的请求配置
12353
- * @returns 解析后的响应数据
12354
- */
12355
12290
  async get(url, params, config) {
12356
12291
  return this.request({ ...config, url, method: "get", params });
12357
12292
  }
12358
- /**
12359
- * 发送 POST 请求
12360
- * @param url - 请求 URL 路径
12361
- * @param data - 请求体数据
12362
- * @param config - 额外的请求配置
12363
- * @returns 解析后的响应数据
12364
- */
12365
12293
  async post(url, data, config) {
12366
12294
  return this.request({ ...config, url, method: "post", data });
12367
12295
  }
12368
- /**
12369
- * 发送 DELETE 请求
12370
- * @param url - 请求 URL 路径
12371
- * @param params - 查询参数对象
12372
- * @param config - 额外的请求配置
12373
- * @returns 解析后的响应数据
12374
- */
12375
12296
  async delete(url, params, config) {
12376
12297
  return this.request({ ...config, url, method: "delete", params });
12377
12298
  }
12378
- /**
12379
- * 发送 PUT 请求
12380
- * @param url - 请求 URL 路径
12381
- * @param data - 请求体数据
12382
- * @param config - 额外的请求配置
12383
- * @returns 解析后的响应数据
12384
- */
12385
12299
  async put(url, data, config) {
12386
12300
  return this.request({ ...config, url, method: "put", data });
12387
12301
  }
12388
- /**
12389
- * 批量请求,并发发送多个请求
12390
- * @param requests - 请求配置数组或已发起的请求 Promise 数组
12391
- * @returns 所有请求的响应数据数组
12392
- */
12393
12302
  async all(requests) {
12394
12303
  if (!requests.length)
12395
12304
  return [];
@@ -12402,13 +12311,6 @@ class BaseHttpClient {
12402
12311
  const promises = requests.map((config) => this.request(config));
12403
12312
  return await Promise.all(promises);
12404
12313
  }
12405
- /**
12406
- * 文件上传,将文件包装为 FormData 发送
12407
- * @param url - 上传地址
12408
- * @param file - 文件对象
12409
- * @param config - 额外的请求配置
12410
- * @returns 解析后的响应数据
12411
- */
12412
12314
  async uploadFile(url, file, config) {
12413
12315
  const formData = new FormData();
12414
12316
  formData.append("file", file);
@@ -12420,11 +12322,6 @@ class BaseHttpClient {
12420
12322
  }
12421
12323
  });
12422
12324
  }
12423
- /**
12424
- * 下载文件,将 Blob 对象下载到本地
12425
- * @param blob - Blob 对象
12426
- * @param filename - 文件名,如果不提供则使用时间戳
12427
- */
12428
12325
  downloadFile(blob, filename) {
12429
12326
  if (typeof window === "undefined") {
12430
12327
  console.warn("downloadFile: 非浏览器环境,无法下载文件");
@@ -12540,12 +12437,10 @@ function createApiDialog(DialogComponent) {
12540
12437
  cleanup();
12541
12438
  }
12542
12439
  },
12543
- // 监听关闭事件
12544
12440
  onClose: () => {
12545
12441
  reject(new Error("对话框已关闭"));
12546
12442
  cleanup();
12547
12443
  },
12548
- // 监听确认事件(如有)
12549
12444
  onConfirm: (data) => {
12550
12445
  resolve(data);
12551
12446
  cleanup();
@@ -12596,10 +12491,6 @@ function createApiDialog(DialogComponent) {
12596
12491
  const hasDocument = typeof document !== "undefined";
12597
12492
  let systemErrorDialogInstance = null;
12598
12493
  class BaseApi extends BaseHttpClient {
12599
- /**
12600
- * 创建 BaseApi 实例
12601
- * @param config - API 配置对象
12602
- */
12603
12494
  constructor(config) {
12604
12495
  const {
12605
12496
  responseFields,
@@ -12613,125 +12504,68 @@ class BaseApi extends BaseHttpClient {
12613
12504
  code: "Code",
12614
12505
  message: "Message",
12615
12506
  data: "data",
12616
- errors: "errors",
12617
- tips: "tips",
12507
+ errors: "data.errors",
12508
+ tips: "data.tips",
12618
12509
  ...responseFields
12619
12510
  };
12620
12511
  this.enableSystemErrorDialog = enableSystemErrorDialog;
12621
12512
  }
12622
- /**
12623
- * 处理请求配置,子类可重写此方法自定义请求配置
12624
- * 显式声明以确保类型一致性,避免打包后的类型不兼容问题
12625
- * @param config - 请求配置对象
12626
- * @returns 处理后的请求配置
12627
- */
12628
12513
  processRequestConfig(config) {
12629
12514
  return super.processRequestConfig(config);
12630
12515
  }
12631
- /**
12632
- * 处理响应配置,子类可重写此方法自定义响应处理
12633
- * 显式声明以确保类型一致性,避免打包后的类型不兼容问题
12634
- * @param response - Axios 响应对象
12635
- * @returns 解析后的响应数据
12636
- */
12637
12516
  processResponseConfig(response) {
12638
12517
  return super.processResponseConfig(response);
12639
12518
  }
12640
- /**
12641
- * 处理响应错误,子类可重写此方法自定义错误处理
12642
- * 显式声明以确保类型一致性,避免打包后的类型不兼容问题
12643
- * @param error - Axios 错误对象
12644
- * @returns 处理后的错误对象
12645
- */
12646
12519
  async processResponseError(error) {
12647
12520
  return super.processResponseError(error);
12648
12521
  }
12649
- /**
12650
- * 处理 HTTP 状态码
12651
- * 重写父类方法,确保子类可以重写此方法
12652
- * @param response - Axios 响应对象
12653
- */
12654
12522
  handleHttpStatus(response) {
12655
12523
  return super.handleHttpStatus(response);
12656
12524
  }
12657
- /**
12658
- * 处理认证错误(401 - 未授权/登录失效)
12659
- * 重写父类方法,处理 HTTP 401 错误
12660
- * 子类可重写此方法来自定义 HTTP 认证错误处理逻辑
12661
- * @param error - Axios 错误对象
12662
- */
12663
12525
  handleAuthenticationError(error) {
12664
12526
  super.handleAuthenticationError(error);
12665
12527
  }
12666
- /**
12667
- * 处理超时错误
12668
- * 重写父类方法,确保子类可以重写此方法
12669
- * @param error - Axios 错误对象
12670
- */
12671
12528
  handleTimeoutError(error) {
12672
12529
  return super.handleTimeoutError(error);
12673
12530
  }
12674
- /**
12675
- * 处理网络错误(其他错误)
12676
- * 重写父类方法,确保子类可以重写此方法
12677
- * @param error - Axios 错误对象
12678
- */
12679
12531
  handleNetworkError(error) {
12680
12532
  return super.handleNetworkError(error);
12681
12533
  }
12682
- /**
12683
- * 处理成功响应
12684
- * 重写父类方法,在标准 HTTP 成功响应基础上,处理业务特定的响应结构
12685
- * 支持嵌套路径解析,自动处理业务层的登录失效、系统异常等错误
12686
- * 注意:HTTP 层的错误(如 HTTP 401、超时等)由父类 BaseHttpClient 处理
12687
- * @param response - Axios 响应对象
12688
- * @returns 解析后的响应数据
12689
- */
12690
12534
  handleSuccessResponse(response) {
12691
12535
  const httpData = super.handleSuccessResponse(response);
12692
12536
  const parsedFields = this.parseResponseFields(httpData);
12693
12537
  const { code, message: message2, responseData } = parsedFields;
12538
+ const config = response.config;
12539
+ const isCustomMessage = (config == null ? void 0 : config.isCustomMessage) ?? false;
12694
12540
  this.handleSystemError(response, code, message2, responseData);
12695
- this.handleBusinessError(code, message2);
12696
- this.handleErrorArray(responseData);
12697
- this.handleTips(responseData);
12541
+ if (!isCustomMessage) {
12542
+ this.handleBusinessError(code, message2, response);
12543
+ this.handleErrorArray(httpData, response);
12544
+ this.handleTips(httpData, response);
12545
+ }
12698
12546
  return responseData;
12699
12547
  }
12700
- /**
12701
- * 解析响应字段,支持嵌套路径解析
12702
- * 子类可重写此方法来自定义字段解析逻辑
12703
- * @param data - 响应数据对象
12704
- * @returns 解析后的字段值对象
12705
- */
12548
+ getValueByPath(obj, path) {
12549
+ if (!path)
12550
+ return obj;
12551
+ const keys = path.split(".");
12552
+ let result = obj;
12553
+ for (const key of keys) {
12554
+ if (result && typeof result === "object" && key in result) {
12555
+ result = result[key];
12556
+ } else {
12557
+ return void 0;
12558
+ }
12559
+ }
12560
+ return result;
12561
+ }
12706
12562
  parseResponseFields(data) {
12707
12563
  var _a2, _b, _c;
12708
- const getValueByPath = (obj, path) => {
12709
- if (!path)
12710
- return obj;
12711
- const keys = path.split(".");
12712
- let result = obj;
12713
- for (const key of keys) {
12714
- if (result && typeof result === "object" && key in result) {
12715
- result = result[key];
12716
- } else {
12717
- return void 0;
12718
- }
12719
- }
12720
- return result;
12721
- };
12722
- const code = getValueByPath(data, (_a2 = this.responseFields) == null ? void 0 : _a2.code);
12723
- const message2 = getValueByPath(data, (_b = this.responseFields) == null ? void 0 : _b.message);
12724
- const responseData = getValueByPath(data, (_c = this.responseFields) == null ? void 0 : _c.data);
12564
+ const code = this.getValueByPath(data, (_a2 = this.responseFields) == null ? void 0 : _a2.code);
12565
+ const message2 = this.getValueByPath(data, (_b = this.responseFields) == null ? void 0 : _b.message);
12566
+ const responseData = this.getValueByPath(data, (_c = this.responseFields) == null ? void 0 : _c.data);
12725
12567
  return { code, message: message2, responseData };
12726
12568
  }
12727
- /**
12728
- * 处理系统异常错误(-1 - 系统异常)
12729
- * 子类可重写此方法来自定义系统异常处理逻辑
12730
- * @param response - Axios 响应对象
12731
- * @param code - 响应状态码
12732
- * @param message - 错误消息
12733
- * @param responseData - 响应数据
12734
- */
12735
12569
  handleSystemError(response, code, message2, responseData) {
12736
12570
  if (code === -1) {
12737
12571
  if (this.enableSystemErrorDialog) {
@@ -12742,13 +12576,7 @@ class BaseApi extends BaseHttpClient {
12742
12576
  throw new Error(message2 || "系统异常");
12743
12577
  }
12744
12578
  }
12745
- /**
12746
- * 处理业务错误(其他非200错误码)
12747
- * 子类可重写此方法来自定义业务错误处理逻辑
12748
- * @param code - 响应状态码
12749
- * @param message - 错误消息
12750
- */
12751
- handleBusinessError(code, message2) {
12579
+ handleBusinessError(code, message2, response) {
12752
12580
  var _a2;
12753
12581
  if (code && code !== 200) {
12754
12582
  (_a2 = this.messageInstance) == null ? void 0 : _a2.error({
@@ -12758,90 +12586,79 @@ class BaseApi extends BaseHttpClient {
12758
12586
  throw new Error(message2 || "请求失败");
12759
12587
  }
12760
12588
  }
12761
- /**
12762
- * 处理错误数组 errors(如果有配置)
12763
- * 子类可重写此方法来自定义错误数组处理逻辑
12764
- * @param responseData - 响应数据
12765
- */
12766
- handleErrorArray(responseData) {
12589
+ handleErrorArray(httpData, response) {
12767
12590
  var _a2;
12768
12591
  const errorsField = (_a2 = this.responseFields) == null ? void 0 : _a2.errors;
12769
12592
  if (errorsField) {
12770
- const errors = responseData == null ? void 0 : responseData[errorsField];
12593
+ const errors = this.getValueByPath(httpData, errorsField);
12771
12594
  if (Array.isArray(errors) && errors.length) {
12772
- this.showErrorArrayNotification(errors);
12595
+ const config = response.config;
12596
+ const notificationOptions = config == null ? void 0 : config.errorNotificationOptions;
12597
+ this.showErrorArrayNotification(errors, notificationOptions);
12773
12598
  throw new Error("请求错误");
12774
12599
  }
12775
12600
  }
12776
12601
  }
12777
- /**
12778
- * 显示错误数组通知
12779
- * 子类可重写此方法来自定义错误数组通知显示方式
12780
- * @param errors - 错误数组
12781
- */
12782
- showErrorArrayNotification(errors) {
12602
+ showErrorArrayNotification(errors, notificationOptions) {
12783
12603
  var _a2, _b;
12784
12604
  const html = errors.map((item) => `<div style="font-size: 14px;color:red">${item.code}:${item.message}</div>`).join("");
12605
+ const defaultOptions = {
12606
+ title: "提示",
12607
+ type: "error"
12608
+ };
12785
12609
  if (hasDocument) {
12786
- (_a2 = this.notificationInstance) == null ? void 0 : _a2.call(this, {
12787
- title: "提示",
12788
- message: html,
12789
- type: "error"
12790
- });
12610
+ const finalOptions = {
12611
+ ...defaultOptions,
12612
+ ...notificationOptions,
12613
+ message: html
12614
+ };
12615
+ (_a2 = this.notificationInstance) == null ? void 0 : _a2.call(this, finalOptions);
12791
12616
  } else {
12792
12617
  const errorMessages = errors.map((item) => `${item.code}:${item.message}`).join("\n");
12793
- (_b = this.notificationInstance) == null ? void 0 : _b.call(this, {
12794
- title: "提示",
12795
- message: errorMessages,
12796
- type: "error"
12797
- });
12618
+ const finalOptions = {
12619
+ ...defaultOptions,
12620
+ ...notificationOptions,
12621
+ message: errorMessages
12622
+ };
12623
+ (_b = this.notificationInstance) == null ? void 0 : _b.call(this, finalOptions);
12798
12624
  }
12799
12625
  }
12800
- /**
12801
- * 处理提示信息 tips(如果有配置)
12802
- * 子类可重写此方法来自定义提示信息处理逻辑
12803
- * @param responseData - 响应数据
12804
- */
12805
- handleTips(responseData) {
12626
+ handleTips(httpData, response) {
12806
12627
  var _a2;
12807
12628
  const tipsField = (_a2 = this.responseFields) == null ? void 0 : _a2.tips;
12808
12629
  if (tipsField) {
12809
- const tips = responseData == null ? void 0 : responseData[tipsField];
12630
+ const tips = this.getValueByPath(httpData, tipsField);
12810
12631
  if (Array.isArray(tips) && tips.length) {
12811
- this.showTipsNotification(tips);
12632
+ const config = response.config;
12633
+ const notificationOptions = config == null ? void 0 : config.tipsNotificationOptions;
12634
+ this.showTipsNotification(tips, notificationOptions);
12812
12635
  }
12813
12636
  }
12814
12637
  }
12815
- /**
12816
- * 显示提示信息通知
12817
- * 子类可重写此方法来自定义提示信息通知显示方式
12818
- * @param tips - 提示信息数组
12819
- */
12820
- showTipsNotification(tips) {
12638
+ showTipsNotification(tips, notificationOptions) {
12821
12639
  var _a2, _b;
12822
12640
  const html = tips.map((item) => `<div style="font-size: 14px;color:#E6A23C">${item.code}:${item.message}</div>`).join("");
12641
+ const defaultOptions = {
12642
+ title: "提示",
12643
+ type: "warning"
12644
+ };
12823
12645
  if (hasDocument) {
12824
- (_a2 = this.notificationInstance) == null ? void 0 : _a2.call(this, {
12825
- title: "提示",
12826
- message: html,
12827
- type: "warning"
12828
- });
12646
+ const finalOptions = {
12647
+ ...defaultOptions,
12648
+ ...notificationOptions,
12649
+ message: html
12650
+ };
12651
+ (_a2 = this.notificationInstance) == null ? void 0 : _a2.call(this, finalOptions);
12829
12652
  } else {
12830
12653
  const tipMessages = tips.map((item) => `${item.code}:${item.message}`).join("\n");
12831
- (_b = this.notificationInstance) == null ? void 0 : _b.call(this, {
12832
- title: "提示",
12833
- message: tipMessages,
12834
- type: "warning"
12835
- });
12654
+ const finalOptions = {
12655
+ ...defaultOptions,
12656
+ ...notificationOptions,
12657
+ message: tipMessages
12658
+ };
12659
+ (_b = this.notificationInstance) == null ? void 0 : _b.call(this, finalOptions);
12836
12660
  }
12837
12661
  }
12838
- /**
12839
- * 显示系统异常对话框,当响应状态码为 -1 时调用
12840
- * @param response - Axios 响应对象
12841
- * @param responseData - 响应数据
12842
- * @param code - 错误状态码
12843
- * @param message - 错误消息
12844
- */
12845
12662
  async showSystemExceptionDialog(response, responseData, code, message2) {
12846
12663
  if (!hasDocument) {
12847
12664
  console.error("系统异常信息:", responseData);
@@ -12880,10 +12697,6 @@ class BaseApi extends BaseHttpClient {
12880
12697
  console.error("系统异常信息:", responseData);
12881
12698
  }
12882
12699
  }
12883
- /**
12884
- * 上报错误信息到服务器,默认实现仅显示提示,子类可重写实现真实上报
12885
- * @param errorInfo - 错误信息对象
12886
- */
12887
12700
  async reportError(errorInfo) {
12888
12701
  var _a2, _b;
12889
12702
  try {
@@ -12901,85 +12714,27 @@ class BaseApi extends BaseHttpClient {
12901
12714
  });
12902
12715
  }
12903
12716
  }
12904
- /**
12905
- * 发送 HTTP 请求,所有 HTTP 方法最终都调用此方法
12906
- * 显式声明以确保类型一致性,子类可重写此方法
12907
- * @param config - Axios 请求配置对象
12908
- * @returns 解析后的响应数据
12909
- */
12910
12717
  async request(config) {
12911
12718
  return super.request(config);
12912
12719
  }
12913
- /**
12914
- * 发送 GET 请求
12915
- * 显式声明以确保类型一致性,子类可重写此方法
12916
- * @param url - 请求 URL 路径
12917
- * @param params - 查询参数对象
12918
- * @param config - 额外的请求配置
12919
- * @returns 解析后的响应数据
12920
- */
12921
12720
  async get(url, params, config) {
12922
12721
  return super.get(url, params, config);
12923
12722
  }
12924
- /**
12925
- * 发送 POST 请求
12926
- * 显式声明以确保类型一致性,子类可重写此方法
12927
- * @param url - 请求 URL 路径
12928
- * @param data - 请求体数据
12929
- * @param config - 额外的请求配置
12930
- * @returns 解析后的响应数据
12931
- */
12932
12723
  async post(url, data, config) {
12933
12724
  return super.post(url, data, config);
12934
12725
  }
12935
- /**
12936
- * 发送 DELETE 请求
12937
- * 显式声明以确保类型一致性,子类可重写此方法
12938
- * @param url - 请求 URL 路径
12939
- * @param params - 查询参数对象
12940
- * @param config - 额外的请求配置
12941
- * @returns 解析后的响应数据
12942
- */
12943
12726
  async delete(url, params, config) {
12944
12727
  return super.delete(url, params, config);
12945
12728
  }
12946
- /**
12947
- * 发送 PUT 请求
12948
- * 显式声明以确保类型一致性,子类可重写此方法
12949
- * @param url - 请求 URL 路径
12950
- * @param data - 请求体数据
12951
- * @param config - 额外的请求配置
12952
- * @returns 解析后的响应数据
12953
- */
12954
12729
  async put(url, data, config) {
12955
12730
  return super.put(url, data, config);
12956
12731
  }
12957
- /**
12958
- * 批量请求,并发发送多个请求
12959
- * 显式声明以确保类型一致性,子类可重写此方法
12960
- * @param requests - 请求配置数组或已发起的请求 Promise 数组
12961
- * @returns 所有请求的响应数据数组
12962
- */
12963
12732
  async all(requests) {
12964
12733
  return super.all(requests);
12965
12734
  }
12966
- /**
12967
- * 文件上传,将文件包装为 FormData 发送
12968
- * 显式声明以确保类型一致性,子类可重写此方法
12969
- * @param url - 上传地址
12970
- * @param file - 文件对象
12971
- * @param config - 额外的请求配置
12972
- * @returns 解析后的响应数据
12973
- */
12974
12735
  async uploadFile(url, file, config) {
12975
12736
  return super.uploadFile(url, file, config);
12976
12737
  }
12977
- /**
12978
- * 下载文件,将 Blob 对象下载到本地
12979
- * 显式声明以确保类型一致性,子类可重写此方法
12980
- * @param blob - Blob 对象
12981
- * @param filename - 文件名,如果不提供则使用时间戳
12982
- */
12983
12738
  downloadFile(blob, filename) {
12984
12739
  return super.downloadFile(blob, filename);
12985
12740
  }
@@ -12988,11 +12743,6 @@ function createHttpService(options = {}) {
12988
12743
  return new BaseApi(options);
12989
12744
  }
12990
12745
  const VueAxiosPlugin = {
12991
- /**
12992
- * 安装插件
12993
- * @param app - Vue 应用实例
12994
- * @param options - 插件配置选项
12995
- */
12996
12746
  install(app, options = {}) {
12997
12747
  const httpService = createHttpService(options.default ?? {});
12998
12748
  app.config.globalProperties.$http = httpService;
@@ -13173,12 +12923,10 @@ const SystemErrorDialog = defineComponent({
13173
12923
  h("span", { style: { fontWeight: "bold", fontSize: "16px" } }, props.title || "系统异常信息")
13174
12924
  ]),
13175
12925
  default: () => h("div", { style: { padding: 0, maxHeight: "500px", overflowY: "auto" } }, [
13176
- // 第一块:无法完成您的请求
13177
12926
  h("div", { style: { padding: "20px", borderBottom: "1px solid #ebeef5" } }, [
13178
12927
  h("h3", { style: { margin: "0 0 12px 0", fontSize: "16px", fontWeight: "bold", color: "#303133" } }, "无法完成您的请求"),
13179
12928
  h("p", { style: { margin: 0, color: "#606266", lineHeight: 1.5 } }, "系统在处理您的请求时遇到了问题,可能是由于服务暂时不可用。")
13180
12929
  ]),
13181
- // 第二块:技术摘要(可展开)
13182
12930
  h("div", { style: { borderBottom: "1px solid #ebeef5" } }, [
13183
12931
  h(
13184
12932
  "div",
@@ -13240,7 +12988,6 @@ const SystemErrorDialog = defineComponent({
13240
12988
  )
13241
12989
  ) : null
13242
12990
  ]),
13243
- // SkyWalking 按钮
13244
12991
  h("div", { style: { padding: "16px 20px", borderBottom: "1px solid #ebeef5" } }, [
13245
12992
  h(
13246
12993
  ElButton,
@@ -13252,10 +12999,9 @@ const SystemErrorDialog = defineComponent({
13252
12999
  { default: () => "📊 在SkyWalking中查看详情" }
13253
13000
  )
13254
13001
  ]),
13255
- // 黑色错误信息区域
13256
13002
  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" } }, [
13257
13003
  h("div", { style: { marginBottom: "8px", color: "#ecf0f1" } }, `Trace ID: ${props.traceId || "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8"}`),
13258
- h("div", { style: { color: "#e74c3c", fontWeight: "bold" } }, `Error: ${props.errorMessage || "Connection timeout after 5000ms"}`)
13004
+ h("div", { style: { color: "#e74c3c", fontWeight: "bold", whiteSpace: "pre-wrap" } }, `Error: ${props.errorMessage || "Connection timeout after 5000ms"}`)
13259
13005
  ])
13260
13006
  ]),
13261
13007
  footer: () => h("div", { style: { display: "flex", justifyContent: "flex-end", alignItems: "center", paddingTop: "16px" } }, [
@@ -5,22 +5,8 @@ declare global {
5
5
  $http?: vueHttpServiceType;
6
6
  }
7
7
  }
8
- /**
9
- * 创建 HTTP 服务实例
10
- * @param options - API 配置对象
11
- * @returns BaseApi 实例
12
- */
13
8
  declare function createHttpService(options?: BaseApiConfig): BaseApi;
14
- /**
15
- * Vue Axios 插件,用于在 Vue 应用中全局注册 HTTP 服务
16
- * 提供 this.$http、inject('$http') 和 window.$http 三种使用方式
17
- */
18
9
  declare const VueAxiosPlugin: vueAxiosPluginType;
19
- /**
20
- * 获取 HTTP 服务实例,与 createHttpService 功能相同
21
- * @param options - API 配置对象
22
- * @returns BaseApi 实例
23
- */
24
10
  declare function getHttpService(options?: BaseApiConfig): BaseApi;
25
11
  export default VueAxiosPlugin;
26
12
  export { createHttpService, getHttpService };