@moluoxixi/ajax-package 0.0.41 → 0.0.43

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.
Files changed (2) hide show
  1. package/es/index.mjs +19 -35
  2. package/package.json +1 -1
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("980e338e-d621-406b-8660-db906d5c2f50")) {
5
+ if (!document.getElementById("b98adb7e-1e48-4cc5-8e14-015f69a7d6cf")) {
6
6
  var elementStyle = document.createElement("style");
7
- elementStyle.id = "980e338e-d621-406b-8660-db906d5c2f50";
7
+ elementStyle.id = "b98adb7e-1e48-4cc5-8e14-015f69a7d6cf";
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
  }
@@ -7531,9 +7531,10 @@ const _BaseHttpClient = class _BaseHttpClient {
7531
7531
  return null;
7532
7532
  }
7533
7533
  if (!this.containerId) {
7534
- this.containerId = `ajaxPackage-container-${generateUUID()}`;
7535
- this.popoverContainerId = `ajaxPackage-popover-${generateUUID()}`;
7536
- this.messageContainerId = `ajaxPackage-message-${generateUUID()}`;
7534
+ const targetElementId = generateUUID();
7535
+ this.containerId = `ajaxPackage-container-${targetElementId}`;
7536
+ this.popoverContainerId = `ajaxPackage-popover-${targetElementId}`;
7537
+ this.messageContainerId = `ajaxPackage-message-${targetElementId}`;
7537
7538
  }
7538
7539
  let container = document.getElementById(this.containerId);
7539
7540
  if (!container) {
@@ -7634,41 +7635,19 @@ const _BaseHttpClient = class _BaseHttpClient {
7634
7635
  }
7635
7636
  }
7636
7637
  handleTimeoutError(error) {
7637
- var _a2;
7638
- if (error.code === "ECONNABORTED") {
7639
- if (error.message.includes("timeout")) {
7640
- this.onTimeout(this.messageInstance);
7641
- } else {
7642
- const errorMessage = "请求已取消";
7643
- const currentTime = Date.now();
7644
- const shouldShowError = !this.recentErrorCache || this.recentErrorCache.message !== errorMessage || currentTime - this.recentErrorCache.timestamp > this.errorDebounceTime;
7645
- if (shouldShowError) {
7646
- (_a2 = this.messageInstance) == null ? void 0 : _a2.call(this, {
7647
- type: "error",
7648
- message: errorMessage,
7649
- duration: 5 * 1e3
7650
- });
7651
- this.recentErrorCache = { message: errorMessage, timestamp: currentTime };
7652
- if (this.errorCacheTimer) {
7653
- clearTimeout(this.errorCacheTimer);
7654
- this.errorCacheTimer = null;
7655
- }
7656
- this.errorCacheTimer = setTimeout(() => {
7657
- if (this.recentErrorCache && this.recentErrorCache.message === errorMessage) {
7658
- this.recentErrorCache = null;
7659
- this.errorCacheTimer = null;
7660
- }
7661
- }, 5e3);
7662
- }
7663
- }
7638
+ if (error.code === "ECONNABORTED" && error.message.includes("timeout")) {
7639
+ this.onTimeout(this.messageInstance);
7664
7640
  }
7665
7641
  }
7666
7642
  handleNetworkError(error) {
7667
7643
  var _a2, _b, _c;
7668
7644
  if (((_a2 = error.response) == null ? void 0 : _a2.status) !== 401 && error.code !== "ECONNABORTED") {
7669
7645
  const fallbackError = error;
7670
- const errorMessage = ((_b = fallbackError.response) == null ? void 0 : _b.data) || fallbackError.message || "网络错误";
7646
+ let errorMessage = ((_b = fallbackError.response) == null ? void 0 : _b.data) || fallbackError.message || "网络错误";
7671
7647
  const currentTime = Date.now();
7648
+ if (error.code === "ERR_CANCELED") {
7649
+ errorMessage = "请求已取消";
7650
+ }
7672
7651
  const shouldShowError = !this.recentErrorCache || this.recentErrorCache.message !== errorMessage || currentTime - this.recentErrorCache.timestamp > this.errorDebounceTime;
7673
7652
  if (shouldShowError) {
7674
7653
  (_c = this.messageInstance) == null ? void 0 : _c.call(this, {
@@ -7677,9 +7656,13 @@ const _BaseHttpClient = class _BaseHttpClient {
7677
7656
  duration: 5 * 1e3
7678
7657
  });
7679
7658
  this.recentErrorCache = { message: errorMessage, timestamp: currentTime };
7680
- setTimeout(() => {
7659
+ if (this.errorCacheTimer) {
7660
+ clearTimeout(this.errorCacheTimer);
7661
+ }
7662
+ this.errorCacheTimer = setTimeout(() => {
7681
7663
  if (this.recentErrorCache && this.recentErrorCache.message === errorMessage) {
7682
7664
  this.recentErrorCache = null;
7665
+ this.errorCacheTimer = null;
7683
7666
  }
7684
7667
  }, 5e3);
7685
7668
  }
@@ -8569,8 +8552,9 @@ const SystemErrorDialog = defineComponent({
8569
8552
  }
8570
8553
  function showMessage(options) {
8571
8554
  const container = getAjaxPackageMessageContainer();
8555
+ const dialogContainer = container || document.querySelector(`.${cssModules.root}`);
8572
8556
  const { type = "info", message: message2 } = options;
8573
- const finalOptions = container ? { type, message: message2, appendTo: container } : { type, message: message2 };
8557
+ const finalOptions = dialogContainer ? { type, message: message2, appendTo: dialogContainer } : { type, message: message2 };
8574
8558
  ElMessage(finalOptions);
8575
8559
  }
8576
8560
  async function handleReport() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moluoxixi/ajax-package",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "description": "AjaxPackage 组件",
5
5
  "sideEffects": [
6
6
  "*.css",