@moluoxixi/ajax-package 0.0.53 → 0.0.55
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/BaseHttpClient.d.ts +5 -0
- package/es/index.mjs +45 -26
- package/package.json +2 -2
package/es/BaseHttpClient.d.ts
CHANGED
|
@@ -23,6 +23,11 @@ export default class BaseHttpClient {
|
|
|
23
23
|
protected errorDebounceTime: number;
|
|
24
24
|
protected errorCacheTimer: NodeJS.Timeout | null;
|
|
25
25
|
protected static readonly hasDocument: boolean;
|
|
26
|
+
private static sharedContainerId;
|
|
27
|
+
private static sharedPopoverContainerId;
|
|
28
|
+
private static sharedMessageContainerId;
|
|
29
|
+
private static sharedAppendTo?;
|
|
30
|
+
private static sharedAppendToFallback;
|
|
26
31
|
protected get hasDocument(): boolean;
|
|
27
32
|
protected resolveAppendToTarget(): HTMLElement | null;
|
|
28
33
|
protected getContainer(): HTMLElement | null;
|
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("f8f93b76-32f3-462e-81ba-ac1c757d561e")) {
|
|
6
6
|
var elementStyle = document.createElement("style");
|
|
7
|
-
elementStyle.id = "
|
|
7
|
+
elementStyle.id = "f8f93b76-32f3-462e-81ba-ac1c757d561e";
|
|
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
|
}
|
|
@@ -7478,6 +7478,12 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
7478
7478
|
this.timeout = timeout;
|
|
7479
7479
|
this.appendTo = appendTo;
|
|
7480
7480
|
this.appendToFallback = appendToFallback;
|
|
7481
|
+
if (appendTo && !_BaseHttpClient.sharedAppendTo) {
|
|
7482
|
+
_BaseHttpClient.sharedAppendTo = appendTo;
|
|
7483
|
+
}
|
|
7484
|
+
if (appendToFallback && !_BaseHttpClient.sharedAppendToFallback) {
|
|
7485
|
+
_BaseHttpClient.sharedAppendToFallback = appendToFallback;
|
|
7486
|
+
}
|
|
7481
7487
|
this.messageInstance = createMessageWrapper(this.hasDocument, () => this.getMessageContainer());
|
|
7482
7488
|
this.notificationInstance = createNotificationWrapper(this.hasDocument, () => this.getMessageContainer());
|
|
7483
7489
|
this.onTimeout = onTimeout;
|
|
@@ -7499,28 +7505,30 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
7499
7505
|
if (!this.hasDocument) {
|
|
7500
7506
|
return document.body;
|
|
7501
7507
|
}
|
|
7502
|
-
|
|
7508
|
+
const appendTo = _BaseHttpClient.sharedAppendTo ?? this.appendTo;
|
|
7509
|
+
if (!appendTo) {
|
|
7503
7510
|
return document.body;
|
|
7504
7511
|
}
|
|
7505
|
-
if (
|
|
7506
|
-
return
|
|
7512
|
+
if (appendTo instanceof HTMLElement) {
|
|
7513
|
+
return appendTo;
|
|
7507
7514
|
}
|
|
7508
|
-
if (typeof
|
|
7509
|
-
const element = document.querySelector(
|
|
7515
|
+
if (typeof appendTo === "string") {
|
|
7516
|
+
const element = document.querySelector(appendTo);
|
|
7510
7517
|
if (element) {
|
|
7511
7518
|
return element;
|
|
7512
7519
|
}
|
|
7513
|
-
|
|
7514
|
-
|
|
7520
|
+
const appendToFallback = _BaseHttpClient.sharedAppendToFallback ?? this.appendToFallback;
|
|
7521
|
+
if (appendToFallback === null) {
|
|
7522
|
+
console.warn(`appendTo 选择器 "${appendTo}" 未找到元素,appendToFallback 为 null,返回 null`);
|
|
7515
7523
|
return null;
|
|
7516
|
-
} else if (
|
|
7524
|
+
} else if (appendToFallback === "body") {
|
|
7517
7525
|
return document.body;
|
|
7518
|
-
} else if (typeof
|
|
7519
|
-
const fallbackElement = document.querySelector(
|
|
7526
|
+
} else if (typeof appendToFallback === "string") {
|
|
7527
|
+
const fallbackElement = document.querySelector(appendToFallback);
|
|
7520
7528
|
if (fallbackElement) {
|
|
7521
7529
|
return fallbackElement;
|
|
7522
7530
|
}
|
|
7523
|
-
console.warn(`appendTo 选择器 "${
|
|
7531
|
+
console.warn(`appendTo 选择器 "${appendTo}" 和 appendToFallback 选择器 "${appendToFallback}" 都未找到元素,返回 null`);
|
|
7524
7532
|
return null;
|
|
7525
7533
|
}
|
|
7526
7534
|
}
|
|
@@ -7530,16 +7538,19 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
7530
7538
|
if (!this.hasDocument) {
|
|
7531
7539
|
return null;
|
|
7532
7540
|
}
|
|
7533
|
-
if (!
|
|
7541
|
+
if (!_BaseHttpClient.sharedContainerId) {
|
|
7534
7542
|
const targetElementId = generateUUID();
|
|
7535
|
-
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
}
|
|
7539
|
-
|
|
7543
|
+
_BaseHttpClient.sharedContainerId = `ajaxPackage-container-${targetElementId}`;
|
|
7544
|
+
_BaseHttpClient.sharedPopoverContainerId = `ajaxPackage-popover-${targetElementId}`;
|
|
7545
|
+
_BaseHttpClient.sharedMessageContainerId = `ajaxPackage-message-${targetElementId}`;
|
|
7546
|
+
}
|
|
7547
|
+
this.containerId = _BaseHttpClient.sharedContainerId;
|
|
7548
|
+
this.popoverContainerId = _BaseHttpClient.sharedPopoverContainerId;
|
|
7549
|
+
this.messageContainerId = _BaseHttpClient.sharedMessageContainerId;
|
|
7550
|
+
let container = document.getElementById(_BaseHttpClient.sharedContainerId);
|
|
7540
7551
|
if (!container) {
|
|
7541
7552
|
container = document.createElement("div");
|
|
7542
|
-
container.id =
|
|
7553
|
+
container.id = _BaseHttpClient.sharedContainerId;
|
|
7543
7554
|
const targetElement = this.resolveAppendToTarget();
|
|
7544
7555
|
if (targetElement) {
|
|
7545
7556
|
targetElement.appendChild(container);
|
|
@@ -7547,12 +7558,12 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
7547
7558
|
return null;
|
|
7548
7559
|
}
|
|
7549
7560
|
const popoverContainer = document.createElement("div");
|
|
7550
|
-
popoverContainer.id =
|
|
7561
|
+
popoverContainer.id = _BaseHttpClient.sharedPopoverContainerId;
|
|
7551
7562
|
popoverContainer.style.position = "relative";
|
|
7552
7563
|
popoverContainer.style.zIndex = "999999";
|
|
7553
7564
|
container.appendChild(popoverContainer);
|
|
7554
7565
|
const messageContainer = document.createElement("div");
|
|
7555
|
-
messageContainer.id =
|
|
7566
|
+
messageContainer.id = _BaseHttpClient.sharedMessageContainerId;
|
|
7556
7567
|
messageContainer.style.position = "relative";
|
|
7557
7568
|
messageContainer.style.zIndex = "99999999";
|
|
7558
7569
|
container.appendChild(messageContainer);
|
|
@@ -7571,10 +7582,11 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
7571
7582
|
if (!container) {
|
|
7572
7583
|
return null;
|
|
7573
7584
|
}
|
|
7574
|
-
|
|
7585
|
+
const popoverContainerId = _BaseHttpClient.sharedPopoverContainerId || this.popoverContainerId;
|
|
7586
|
+
if (!popoverContainerId) {
|
|
7575
7587
|
return null;
|
|
7576
7588
|
}
|
|
7577
|
-
const popoverContainer = document.getElementById(
|
|
7589
|
+
const popoverContainer = document.getElementById(popoverContainerId);
|
|
7578
7590
|
if (popoverContainer && !popoverContainer.style.position) {
|
|
7579
7591
|
popoverContainer.style.position = "relative";
|
|
7580
7592
|
popoverContainer.style.zIndex = "999999";
|
|
@@ -7593,10 +7605,11 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
7593
7605
|
if (!container) {
|
|
7594
7606
|
return null;
|
|
7595
7607
|
}
|
|
7596
|
-
|
|
7608
|
+
const messageContainerId = _BaseHttpClient.sharedMessageContainerId || this.messageContainerId;
|
|
7609
|
+
if (!messageContainerId) {
|
|
7597
7610
|
return null;
|
|
7598
7611
|
}
|
|
7599
|
-
const messageContainer = document.getElementById(
|
|
7612
|
+
const messageContainer = document.getElementById(messageContainerId);
|
|
7600
7613
|
if (messageContainer && !messageContainer.style.position) {
|
|
7601
7614
|
messageContainer.style.position = "relative";
|
|
7602
7615
|
messageContainer.style.zIndex = "99999999";
|
|
@@ -7748,6 +7761,12 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
7748
7761
|
}
|
|
7749
7762
|
};
|
|
7750
7763
|
__publicField(_BaseHttpClient, "hasDocument", typeof document !== "undefined");
|
|
7764
|
+
// 静态共享容器配置 - 所有实例共享同一个容器
|
|
7765
|
+
__publicField(_BaseHttpClient, "sharedContainerId", "");
|
|
7766
|
+
__publicField(_BaseHttpClient, "sharedPopoverContainerId", "");
|
|
7767
|
+
__publicField(_BaseHttpClient, "sharedMessageContainerId", "");
|
|
7768
|
+
__publicField(_BaseHttpClient, "sharedAppendTo");
|
|
7769
|
+
__publicField(_BaseHttpClient, "sharedAppendToFallback", "body");
|
|
7751
7770
|
let BaseHttpClient = _BaseHttpClient;
|
|
7752
7771
|
async function copyToClipboard(text) {
|
|
7753
7772
|
if (!text) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moluoxixi/ajax-package",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.55",
|
|
4
4
|
"description": "AjaxPackage 组件",
|
|
5
5
|
"sideEffects": [
|
|
6
6
|
"*.css",
|
|
7
7
|
"*.scss"
|
|
8
8
|
],
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"vue": "3.5.27"
|
|
10
|
+
"vue": "^3.5.27"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {},
|
|
13
13
|
"publishConfig": {
|