@moluoxixi/ajax-package 0.0.41 → 0.0.42
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 +13 -31
- 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("
|
|
5
|
+
if (!document.getElementById("39882c3a-da2f-4d32-b842-fa25e28f73f4")) {
|
|
6
6
|
var elementStyle = document.createElement("style");
|
|
7
|
-
elementStyle.id = "
|
|
7
|
+
elementStyle.id = "39882c3a-da2f-4d32-b842-fa25e28f73f4";
|
|
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
|
}
|
|
@@ -7634,41 +7634,19 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
7634
7634
|
}
|
|
7635
7635
|
}
|
|
7636
7636
|
handleTimeoutError(error) {
|
|
7637
|
-
|
|
7638
|
-
|
|
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
|
-
}
|
|
7637
|
+
if (error.code === "ECONNABORTED" && error.message.includes("timeout")) {
|
|
7638
|
+
this.onTimeout(this.messageInstance);
|
|
7664
7639
|
}
|
|
7665
7640
|
}
|
|
7666
7641
|
handleNetworkError(error) {
|
|
7667
7642
|
var _a2, _b, _c;
|
|
7668
7643
|
if (((_a2 = error.response) == null ? void 0 : _a2.status) !== 401 && error.code !== "ECONNABORTED") {
|
|
7669
7644
|
const fallbackError = error;
|
|
7670
|
-
|
|
7645
|
+
let errorMessage = ((_b = fallbackError.response) == null ? void 0 : _b.data) || fallbackError.message || "网络错误";
|
|
7671
7646
|
const currentTime = Date.now();
|
|
7647
|
+
if (error.code === "ERR_CANCELED") {
|
|
7648
|
+
errorMessage = "请求已取消";
|
|
7649
|
+
}
|
|
7672
7650
|
const shouldShowError = !this.recentErrorCache || this.recentErrorCache.message !== errorMessage || currentTime - this.recentErrorCache.timestamp > this.errorDebounceTime;
|
|
7673
7651
|
if (shouldShowError) {
|
|
7674
7652
|
(_c = this.messageInstance) == null ? void 0 : _c.call(this, {
|
|
@@ -7677,9 +7655,13 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
7677
7655
|
duration: 5 * 1e3
|
|
7678
7656
|
});
|
|
7679
7657
|
this.recentErrorCache = { message: errorMessage, timestamp: currentTime };
|
|
7680
|
-
|
|
7658
|
+
if (this.errorCacheTimer) {
|
|
7659
|
+
clearTimeout(this.errorCacheTimer);
|
|
7660
|
+
}
|
|
7661
|
+
this.errorCacheTimer = setTimeout(() => {
|
|
7681
7662
|
if (this.recentErrorCache && this.recentErrorCache.message === errorMessage) {
|
|
7682
7663
|
this.recentErrorCache = null;
|
|
7664
|
+
this.errorCacheTimer = null;
|
|
7683
7665
|
}
|
|
7684
7666
|
}, 5e3);
|
|
7685
7667
|
}
|