@moluoxixi/ajax-package 0.0.37 → 0.0.39
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 +7 -4
- package/es/index.mjs +39 -24
- package/package.json +1 -1
package/es/BaseHttpClient.d.ts
CHANGED
|
@@ -18,6 +18,9 @@ export default class BaseHttpClient {
|
|
|
18
18
|
protected onLoginRequired?: (messageInstance: MessageInstance) => void;
|
|
19
19
|
protected appendTo?: HTMLElement | string | null;
|
|
20
20
|
protected appendToFallback: string | null;
|
|
21
|
+
protected containerId: string;
|
|
22
|
+
protected popoverContainerId: string;
|
|
23
|
+
protected messageContainerId: string;
|
|
21
24
|
instance: ReturnType<typeof axios.create>;
|
|
22
25
|
protected messageInstance: MessageInstance;
|
|
23
26
|
protected notificationInstance: NotificationInstance;
|
|
@@ -43,15 +46,15 @@ export default class BaseHttpClient {
|
|
|
43
46
|
*/
|
|
44
47
|
protected getContainer(): HTMLElement | null;
|
|
45
48
|
/**
|
|
46
|
-
* 获取或创建
|
|
49
|
+
* 获取或创建 popover 容器元素(用于 Dialog)
|
|
47
50
|
* @returns 容器元素,如果不是浏览器环境则返回 null
|
|
48
51
|
*/
|
|
49
|
-
|
|
52
|
+
getPopoverContainer(): HTMLElement | null;
|
|
50
53
|
/**
|
|
51
|
-
* 获取或创建
|
|
54
|
+
* 获取或创建 message 容器元素(用于 Message 和 Notification)
|
|
52
55
|
* @returns 容器元素,如果不是浏览器环境则返回 null
|
|
53
56
|
*/
|
|
54
|
-
|
|
57
|
+
getMessageContainer(): HTMLElement | null;
|
|
55
58
|
/**
|
|
56
59
|
* 创建 BaseHttpClient 实例
|
|
57
60
|
* @param config - HTTP 客户端配置对象
|
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("a252d26b-5a74-4a63-995b-52b98c88f4e5")) {
|
|
6
6
|
var elementStyle = document.createElement("style");
|
|
7
|
-
elementStyle.id = "
|
|
7
|
+
elementStyle.id = "a252d26b-5a74-4a63-995b-52b98c88f4e5";
|
|
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
|
}
|
|
@@ -12208,6 +12208,16 @@ function defaultOnLoginRequired(messageInstance) {
|
|
|
12208
12208
|
function defaultGetToken() {
|
|
12209
12209
|
return typeof localStorage !== "undefined" ? localStorage.getItem("token") || "" : "";
|
|
12210
12210
|
}
|
|
12211
|
+
function generateUUID() {
|
|
12212
|
+
if (typeof crypto !== "undefined" && crypto.randomUUID) {
|
|
12213
|
+
return crypto.randomUUID();
|
|
12214
|
+
}
|
|
12215
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
12216
|
+
const r = Math.random() * 16 | 0;
|
|
12217
|
+
const v = c === "x" ? r : r & 3 | 8;
|
|
12218
|
+
return v.toString(16);
|
|
12219
|
+
});
|
|
12220
|
+
}
|
|
12211
12221
|
const _BaseHttpClient = class _BaseHttpClient {
|
|
12212
12222
|
/**
|
|
12213
12223
|
* 创建 BaseHttpClient 实例
|
|
@@ -12221,6 +12231,9 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
12221
12231
|
__publicField(this, "onLoginRequired");
|
|
12222
12232
|
__publicField(this, "appendTo");
|
|
12223
12233
|
__publicField(this, "appendToFallback", "body");
|
|
12234
|
+
__publicField(this, "containerId", "");
|
|
12235
|
+
__publicField(this, "popoverContainerId", "");
|
|
12236
|
+
__publicField(this, "messageContainerId", "");
|
|
12224
12237
|
__publicField(this, "instance");
|
|
12225
12238
|
__publicField(this, "messageInstance");
|
|
12226
12239
|
__publicField(this, "notificationInstance");
|
|
@@ -12295,7 +12308,7 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
12295
12308
|
return null;
|
|
12296
12309
|
}
|
|
12297
12310
|
}
|
|
12298
|
-
return
|
|
12311
|
+
return null;
|
|
12299
12312
|
}
|
|
12300
12313
|
/**
|
|
12301
12314
|
* 获取或创建 ajaxPackage-container 容器元素
|
|
@@ -12305,10 +12318,15 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
12305
12318
|
if (!this.hasDocument) {
|
|
12306
12319
|
return null;
|
|
12307
12320
|
}
|
|
12308
|
-
|
|
12321
|
+
if (!this.containerId) {
|
|
12322
|
+
this.containerId = `ajaxPackage-container-${generateUUID()}`;
|
|
12323
|
+
this.popoverContainerId = `ajaxPackage-popover-${generateUUID()}`;
|
|
12324
|
+
this.messageContainerId = `ajaxPackage-message-${generateUUID()}`;
|
|
12325
|
+
}
|
|
12326
|
+
let container = document.getElementById(this.containerId);
|
|
12309
12327
|
if (!container) {
|
|
12310
12328
|
container = document.createElement("div");
|
|
12311
|
-
container.id =
|
|
12329
|
+
container.id = this.containerId;
|
|
12312
12330
|
const targetElement = this.resolveAppendToTarget();
|
|
12313
12331
|
if (targetElement) {
|
|
12314
12332
|
targetElement.appendChild(container);
|
|
@@ -12316,12 +12334,12 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
12316
12334
|
return null;
|
|
12317
12335
|
}
|
|
12318
12336
|
const popoverContainer = document.createElement("div");
|
|
12319
|
-
popoverContainer.id =
|
|
12337
|
+
popoverContainer.id = this.popoverContainerId;
|
|
12320
12338
|
popoverContainer.style.position = "relative";
|
|
12321
12339
|
popoverContainer.style.zIndex = "999999";
|
|
12322
12340
|
container.appendChild(popoverContainer);
|
|
12323
12341
|
const messageContainer = document.createElement("div");
|
|
12324
|
-
messageContainer.id =
|
|
12342
|
+
messageContainer.id = this.messageContainerId;
|
|
12325
12343
|
messageContainer.style.position = "relative";
|
|
12326
12344
|
messageContainer.style.zIndex = "99999999";
|
|
12327
12345
|
container.appendChild(messageContainer);
|
|
@@ -12329,7 +12347,7 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
12329
12347
|
return container;
|
|
12330
12348
|
}
|
|
12331
12349
|
/**
|
|
12332
|
-
* 获取或创建
|
|
12350
|
+
* 获取或创建 popover 容器元素(用于 Dialog)
|
|
12333
12351
|
* @returns 容器元素,如果不是浏览器环境则返回 null
|
|
12334
12352
|
*/
|
|
12335
12353
|
getPopoverContainer() {
|
|
@@ -12340,7 +12358,10 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
12340
12358
|
if (!container) {
|
|
12341
12359
|
return null;
|
|
12342
12360
|
}
|
|
12343
|
-
|
|
12361
|
+
if (!this.popoverContainerId) {
|
|
12362
|
+
return null;
|
|
12363
|
+
}
|
|
12364
|
+
const popoverContainer = document.getElementById(this.popoverContainerId);
|
|
12344
12365
|
if (popoverContainer && !popoverContainer.style.position) {
|
|
12345
12366
|
popoverContainer.style.position = "relative";
|
|
12346
12367
|
popoverContainer.style.zIndex = "999999";
|
|
@@ -12348,7 +12369,7 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
12348
12369
|
return popoverContainer;
|
|
12349
12370
|
}
|
|
12350
12371
|
/**
|
|
12351
|
-
* 获取或创建
|
|
12372
|
+
* 获取或创建 message 容器元素(用于 Message 和 Notification)
|
|
12352
12373
|
* @returns 容器元素,如果不是浏览器环境则返回 null
|
|
12353
12374
|
*/
|
|
12354
12375
|
getMessageContainer() {
|
|
@@ -12359,7 +12380,10 @@ const _BaseHttpClient = class _BaseHttpClient {
|
|
|
12359
12380
|
if (!container) {
|
|
12360
12381
|
return null;
|
|
12361
12382
|
}
|
|
12362
|
-
|
|
12383
|
+
if (!this.messageContainerId) {
|
|
12384
|
+
return null;
|
|
12385
|
+
}
|
|
12386
|
+
const messageContainer = document.getElementById(this.messageContainerId);
|
|
12363
12387
|
if (messageContainer && !messageContainer.style.position) {
|
|
12364
12388
|
messageContainer.style.position = "relative";
|
|
12365
12389
|
messageContainer.style.zIndex = "99999999";
|
|
@@ -12613,13 +12637,8 @@ async function copyToClipboard(text) {
|
|
|
12613
12637
|
textArea.style.top = "-999999px";
|
|
12614
12638
|
document.body.appendChild(textArea);
|
|
12615
12639
|
textArea.select();
|
|
12616
|
-
|
|
12617
|
-
|
|
12618
|
-
return true;
|
|
12619
|
-
} else {
|
|
12620
|
-
document.body.removeChild(textArea);
|
|
12621
|
-
return false;
|
|
12622
|
-
}
|
|
12640
|
+
textArea.remove();
|
|
12641
|
+
return true;
|
|
12623
12642
|
}
|
|
12624
12643
|
} catch (error) {
|
|
12625
12644
|
console.error("复制到剪贴板失败:", error);
|
|
@@ -13393,14 +13412,10 @@ const SystemErrorDialog = defineComponent({
|
|
|
13393
13412
|
emit("update:modelValue", val);
|
|
13394
13413
|
}
|
|
13395
13414
|
function getAjaxPackageMessageContainer() {
|
|
13396
|
-
|
|
13397
|
-
return null;
|
|
13398
|
-
return document.getElementById("ajaxPackage-message");
|
|
13415
|
+
return baseApi.getMessageContainer();
|
|
13399
13416
|
}
|
|
13400
13417
|
function getAjaxPackagePopoverContainer() {
|
|
13401
|
-
|
|
13402
|
-
return null;
|
|
13403
|
-
return document.getElementById("ajaxPackage-popover");
|
|
13418
|
+
return baseApi.getPopoverContainer();
|
|
13404
13419
|
}
|
|
13405
13420
|
function showMessage(options) {
|
|
13406
13421
|
const container = getAjaxPackageMessageContainer();
|