@moluoxixi/ajax-package 0.0.37 → 0.0.38

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.
@@ -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
- * 获取或创建 ajaxPackage-popover 容器元素(用于 Dialog)
49
+ * 获取或创建 popover 容器元素(用于 Dialog)
47
50
  * @returns 容器元素,如果不是浏览器环境则返回 null
48
51
  */
49
- protected getPopoverContainer(): HTMLElement | null;
52
+ getPopoverContainer(): HTMLElement | null;
50
53
  /**
51
- * 获取或创建 ajaxPackage-message 容器元素(用于 Message 和 Notification)
54
+ * 获取或创建 message 容器元素(用于 Message 和 Notification)
52
55
  * @returns 容器元素,如果不是浏览器环境则返回 null
53
56
  */
54
- protected getMessageContainer(): HTMLElement | null;
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("d90637ed-57fd-4f94-b0c2-d8acbe328d03")) {
5
+ if (!document.getElementById("631710a0-260c-438a-9571-db68806a8879")) {
6
6
  var elementStyle = document.createElement("style");
7
- elementStyle.id = "d90637ed-57fd-4f94-b0c2-d8acbe328d03";
7
+ elementStyle.id = "631710a0-260c-438a-9571-db68806a8879";
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");
@@ -12305,10 +12318,15 @@ const _BaseHttpClient = class _BaseHttpClient {
12305
12318
  if (!this.hasDocument) {
12306
12319
  return null;
12307
12320
  }
12308
- let container = document.getElementById("ajaxPackage-container");
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 = "ajaxPackage-container";
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 = "ajaxPackage-popover";
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 = "ajaxPackage-message";
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
- * 获取或创建 ajaxPackage-popover 容器元素(用于 Dialog)
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
- const popoverContainer = document.getElementById("ajaxPackage-popover");
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
- * 获取或创建 ajaxPackage-message 容器元素(用于 Message 和 Notification)
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
- const messageContainer = document.getElementById("ajaxPackage-message");
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";
@@ -13393,14 +13417,10 @@ const SystemErrorDialog = defineComponent({
13393
13417
  emit("update:modelValue", val);
13394
13418
  }
13395
13419
  function getAjaxPackageMessageContainer() {
13396
- if (typeof document === "undefined")
13397
- return null;
13398
- return document.getElementById("ajaxPackage-message");
13420
+ return baseApi.getMessageContainer();
13399
13421
  }
13400
13422
  function getAjaxPackagePopoverContainer() {
13401
- if (typeof document === "undefined")
13402
- return null;
13403
- return document.getElementById("ajaxPackage-popover");
13423
+ return baseApi.getPopoverContainer();
13404
13424
  }
13405
13425
  function showMessage(options) {
13406
13426
  const container = getAjaxPackageMessageContainer();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moluoxixi/ajax-package",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
4
4
  "description": "AjaxPackage 组件",
5
5
  "sideEffects": [
6
6
  "*.css",