@moluoxixi/ajax-package 0.0.34 → 0.0.35

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.
@@ -20,6 +20,31 @@ export default class BaseHttpClient {
20
20
  protected messageInstance: MessageInstance;
21
21
  protected notificationInstance: NotificationInstance;
22
22
  protected addSign?: (config: AxiosRequestConfig) => void;
23
+ /**
24
+ * 检查是否在浏览器环境(在类初始化时判断)
25
+ * 注意:这是静态属性,所有实例共享
26
+ */
27
+ protected static readonly hasDocument: boolean;
28
+ /**
29
+ * 获取是否在浏览器环境(实例 getter)
30
+ * @returns 是否在浏览器环境
31
+ */
32
+ protected get hasDocument(): boolean;
33
+ /**
34
+ * 获取或创建 ajaxPackage-container 容器元素
35
+ * @returns 容器元素,如果不是浏览器环境则返回 null
36
+ */
37
+ protected getContainer(): HTMLElement | null;
38
+ /**
39
+ * 获取或创建 ajaxPackage-popover 容器元素(用于 Dialog)
40
+ * @returns 容器元素,如果不是浏览器环境则返回 null
41
+ */
42
+ protected getPopoverContainer(): HTMLElement | null;
43
+ /**
44
+ * 获取或创建 ajaxPackage-message 容器元素(用于 Message 和 Notification)
45
+ * @returns 容器元素,如果不是浏览器环境则返回 null
46
+ */
47
+ protected getMessageContainer(): HTMLElement | null;
23
48
  /**
24
49
  * 创建 BaseHttpClient 实例
25
50
  * @param config - HTTP 客户端配置对象
@@ -1,39 +1,12 @@
1
1
  /**
2
2
  * 创建消息实例的包装函数
3
- * @returns 消息实例,支持 success、error、warning、info 方法
3
+ * @param hasDocument - 是否在浏览器环境
4
+ * @param container - 容器元素,如果提供则消息将挂载到该容器中
5
+ * @returns 消息函数实例,直接调用即可,支持传入 type: 'success' | 'error' | 'warning' | 'info'
4
6
  */
5
- export declare function createMessageWrapper(): (import('element-plus').MessageFn & {
6
- primary: import('element-plus').MessageTypedFn;
7
- success: import('element-plus').MessageTypedFn;
8
- warning: import('element-plus').MessageTypedFn;
9
- info: import('element-plus').MessageTypedFn;
10
- error: import('element-plus').MessageTypedFn;
11
- } & import('vue').ObjectPlugin<any[]> & {
12
- _context: import('vue').AppContext | null;
13
- }) | (import('element-plus').MessageFn & {
14
- primary: import('element-plus').MessageTypedFn;
15
- success: import('element-plus').MessageTypedFn;
16
- warning: import('element-plus').MessageTypedFn;
17
- info: import('element-plus').MessageTypedFn;
18
- error: import('element-plus').MessageTypedFn;
19
- } & ((app: import('vue').App, ...options: any[]) => any) & Partial<import('vue').ObjectPlugin<any[]>> & {
20
- _context: import('vue').AppContext | null;
21
- }) | {
22
- success: (options: string | {
23
- message?: string;
24
- [key: string]: any;
25
- }) => void;
26
- error: (options: string | {
27
- message?: string;
28
- [key: string]: any;
29
- }) => void;
30
- warning: (options: string | {
31
- message?: string;
32
- [key: string]: any;
33
- }) => void;
34
- info: (options: string | {
35
- message?: string;
36
- [key: string]: any;
37
- }) => void;
38
- };
7
+ export declare function createMessageWrapper(hasDocument: boolean, container?: HTMLElement | null): (options: string | {
8
+ message?: string;
9
+ type?: "success" | "error" | "warning" | "info";
10
+ [key: string]: any;
11
+ }) => void;
39
12
  export type MessageInstance = ReturnType<typeof createMessageWrapper>;
@@ -1,10 +1,15 @@
1
1
  /**
2
2
  * 创建通知实例的包装函数(用于 errors / tips 展示)
3
- * @returns 通知实例,支持 success、error、warning、info 方法
3
+ * @param hasDocument - 是否在浏览器环境
4
+ * @param container - 容器元素,如果提供则通知将挂载到该容器中
5
+ * @returns 通知函数实例,直接调用即可,支持传入 type: 'success' | 'error' | 'warning' | 'info'
4
6
  */
5
- export declare function createNotificationWrapper(): ((import('element-plus').Notify & import('vue').Plugin) & {
6
- _context: import('vue').AppContext | null;
7
- }) | ((options: string | {
7
+ export declare function createNotificationWrapper(hasDocument: boolean, container?: HTMLElement | null): ((options: string | {
8
+ message?: string;
9
+ title?: string;
10
+ type?: "success" | "error" | "warning" | "info";
11
+ [key: string]: any;
12
+ }) => import('element-plus').NotificationHandle) | ((options: string | {
8
13
  message?: string;
9
14
  title?: string;
10
15
  type?: "success" | "error" | "warning" | "info";
package/es/class.d.ts CHANGED
@@ -10,11 +10,6 @@ export default class BaseApi extends BaseHttpClient {
10
10
  protected responseFields: Required<BaseApiConfig['responseFields']>;
11
11
  protected enableSystemErrorDialog: boolean;
12
12
  protected systemErrorMessage: string;
13
- /**
14
- * 检查是否在浏览器环境(在类初始化时判断)
15
- * 注意:这是静态属性,所有实例共享
16
- */
17
- private static readonly hasDocument;
18
13
  /**
19
14
  * SystemErrorDialog 实例
20
15
  * 注意:这是实例属性,每个实例有自己的对话框实例
@@ -32,11 +27,6 @@ export default class BaseApi extends BaseHttpClient {
32
27
  * 注意:这是静态属性,所有实例共享同一个错误信息存储
33
28
  */
34
29
  private static systemErrorInfoMap;
35
- /**
36
- * 获取是否在浏览器环境(实例 getter)
37
- * @returns 是否在浏览器环境
38
- */
39
- protected get hasDocument(): boolean;
40
30
  /**
41
31
  * 获取系统错误信息存储(实例 getter)
42
32
  * @returns 系统错误信息存储 Map
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("b2882460-4b80-4dc1-b28b-fc865ae04458")) {
5
+ if (!document.getElementById("59b794d1-a3ef-4b37-9b28-cc9399203b57")) {
6
6
  var elementStyle = document.createElement("style");
7
- elementStyle.id = "b2882460-4b80-4dc1-b28b-fc865ae04458";
7
+ elementStyle.id = "59b794d1-a3ef-4b37-9b28-cc9399203b57";
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
  }
@@ -12049,32 +12049,38 @@ notify.closeAll = closeAll;
12049
12049
  notify.updateOffsets = updateOffsets;
12050
12050
  notify._context = null;
12051
12051
  const ElNotification = withInstallFunction(notify, "$notify");
12052
- const hasDocument$1 = typeof document !== "undefined";
12053
- function createMessageWrapper() {
12054
- if (hasDocument$1) {
12055
- return ElMessage;
12052
+ function createMessageWrapper(hasDocument, container) {
12053
+ if (hasDocument) {
12054
+ return (options) => {
12055
+ const opts = typeof options === "string" ? { message: options } : options;
12056
+ const finalOptions = container ? { ...opts, appendTo: container } : opts;
12057
+ return ElMessage(finalOptions);
12058
+ };
12056
12059
  }
12057
- return {
12058
- success: (options) => {
12059
- typeof options === "string" ? options : (options == null ? void 0 : options.message) || "";
12060
- },
12061
- error: (options) => {
12062
- const message2 = typeof options === "string" ? options : (options == null ? void 0 : options.message) || "";
12063
- console.error(`[Message Error] ${message2}`);
12064
- },
12065
- warning: (options) => {
12066
- const message2 = typeof options === "string" ? options : (options == null ? void 0 : options.message) || "";
12067
- console.warn(`[Message Warning] ${message2}`);
12068
- },
12069
- info: (options) => {
12070
- typeof options === "string" ? options : (options == null ? void 0 : options.message) || "";
12060
+ return (options) => {
12061
+ const opts = typeof options === "string" ? { message: options } : options;
12062
+ const message2 = (opts == null ? void 0 : opts.message) || "";
12063
+ const type = (opts == null ? void 0 : opts.type) || "info";
12064
+ const logMessage = `[Message ${type}] ${message2}`;
12065
+ switch (type) {
12066
+ case "success":
12067
+ break;
12068
+ case "error":
12069
+ console.error(logMessage);
12070
+ break;
12071
+ case "warning":
12072
+ console.warn(logMessage);
12073
+ break;
12071
12074
  }
12072
12075
  };
12073
12076
  }
12074
- const hasDocument = typeof document !== "undefined";
12075
- function createNotificationWrapper() {
12077
+ function createNotificationWrapper(hasDocument, container) {
12076
12078
  if (hasDocument) {
12077
- return ElNotification;
12079
+ return (options) => {
12080
+ const opts = typeof options === "string" ? { message: options } : options;
12081
+ const finalOptions = container ? { ...opts, appendTo: container } : opts;
12082
+ return ElNotification(finalOptions);
12083
+ };
12078
12084
  }
12079
12085
  const consoleNotification = (options, level = "info") => {
12080
12086
  const opts = typeof options === "string" ? { message: options } : options;
@@ -12188,7 +12194,8 @@ function extractSystemErrorInfo(response, code, message2) {
12188
12194
  };
12189
12195
  }
12190
12196
  function defaultOnLoginRequired(messageInstance) {
12191
- messageInstance == null ? void 0 : messageInstance.error({
12197
+ messageInstance == null ? void 0 : messageInstance({
12198
+ type: "error",
12192
12199
  message: "登录已过期,请重新登录",
12193
12200
  duration: 5 * 1e3
12194
12201
  });
@@ -12199,7 +12206,7 @@ function defaultOnLoginRequired(messageInstance) {
12199
12206
  function defaultGetToken() {
12200
12207
  return typeof localStorage !== "undefined" ? localStorage.getItem("token") || "" : "";
12201
12208
  }
12202
- class BaseHttpClient {
12209
+ const _BaseHttpClient = class _BaseHttpClient {
12203
12210
  /**
12204
12211
  * 创建 BaseHttpClient 实例
12205
12212
  * @param config - HTTP 客户端配置对象
@@ -12226,8 +12233,10 @@ class BaseHttpClient {
12226
12233
  } = config;
12227
12234
  this.baseURL = baseURL;
12228
12235
  this.timeout = timeout;
12229
- this.messageInstance = createMessageWrapper();
12230
- this.notificationInstance = createNotificationWrapper();
12236
+ this.getContainer();
12237
+ const messageContainer = this.getMessageContainer();
12238
+ this.messageInstance = createMessageWrapper(this.hasDocument, messageContainer);
12239
+ this.notificationInstance = createNotificationWrapper(this.hasDocument, messageContainer);
12231
12240
  this.onTimeout = onTimeout;
12232
12241
  this.getToken = getToken;
12233
12242
  this.onLoginRequired = onLoginRequired;
@@ -12240,6 +12249,58 @@ class BaseHttpClient {
12240
12249
  });
12241
12250
  this.setupInterceptors();
12242
12251
  }
12252
+ /**
12253
+ * 获取是否在浏览器环境(实例 getter)
12254
+ * @returns 是否在浏览器环境
12255
+ */
12256
+ get hasDocument() {
12257
+ return _BaseHttpClient.hasDocument;
12258
+ }
12259
+ /**
12260
+ * 获取或创建 ajaxPackage-container 容器元素
12261
+ * @returns 容器元素,如果不是浏览器环境则返回 null
12262
+ */
12263
+ getContainer() {
12264
+ if (!this.hasDocument) {
12265
+ return null;
12266
+ }
12267
+ let container = document.getElementById("ajaxPackage-container");
12268
+ if (!container) {
12269
+ container = document.createElement("div");
12270
+ container.id = "ajaxPackage-container";
12271
+ document.body.appendChild(container);
12272
+ const popoverContainer = document.createElement("div");
12273
+ popoverContainer.id = "ajaxPackage-popover";
12274
+ container.appendChild(popoverContainer);
12275
+ const messageContainer = document.createElement("div");
12276
+ messageContainer.id = "ajaxPackage-message";
12277
+ messageContainer.style.zIndex = "99999999";
12278
+ container.appendChild(messageContainer);
12279
+ }
12280
+ return container;
12281
+ }
12282
+ /**
12283
+ * 获取或创建 ajaxPackage-popover 容器元素(用于 Dialog)
12284
+ * @returns 容器元素,如果不是浏览器环境则返回 null
12285
+ */
12286
+ getPopoverContainer() {
12287
+ if (!this.hasDocument) {
12288
+ return null;
12289
+ }
12290
+ this.getContainer();
12291
+ return document.getElementById("ajaxPackage-popover");
12292
+ }
12293
+ /**
12294
+ * 获取或创建 ajaxPackage-message 容器元素(用于 Message 和 Notification)
12295
+ * @returns 容器元素,如果不是浏览器环境则返回 null
12296
+ */
12297
+ getMessageContainer() {
12298
+ if (!this.hasDocument) {
12299
+ return null;
12300
+ }
12301
+ this.getContainer();
12302
+ return document.getElementById("ajaxPackage-message");
12303
+ }
12243
12304
  /**
12244
12305
  * 处理请求配置,子类可重写此方法自定义请求配置
12245
12306
  * @param config - 请求配置对象
@@ -12323,7 +12384,8 @@ class BaseHttpClient {
12323
12384
  var _a2, _b, _c;
12324
12385
  if (((_a2 = error.response) == null ? void 0 : _a2.status) !== 401 && error.code !== "ECONNABORTED") {
12325
12386
  const fallbackError = error;
12326
- (_c = this.messageInstance) == null ? void 0 : _c.error({
12387
+ (_c = this.messageInstance) == null ? void 0 : _c.call(this, {
12388
+ type: "error",
12327
12389
  message: ((_b = fallbackError.response) == null ? void 0 : _b.data) || fallbackError.message || "网络错误",
12328
12390
  duration: 5 * 1e3
12329
12391
  });
@@ -12462,6 +12524,42 @@ class BaseHttpClient {
12462
12524
  link.remove();
12463
12525
  window.URL.revokeObjectURL(url);
12464
12526
  }
12527
+ };
12528
+ /**
12529
+ * 检查是否在浏览器环境(在类初始化时判断)
12530
+ * 注意:这是静态属性,所有实例共享
12531
+ */
12532
+ __publicField(_BaseHttpClient, "hasDocument", typeof document !== "undefined");
12533
+ let BaseHttpClient = _BaseHttpClient;
12534
+ async function copyToClipboard(text) {
12535
+ if (!text) {
12536
+ console.warn("复制文本为空");
12537
+ return false;
12538
+ }
12539
+ try {
12540
+ if (navigator.clipboard && navigator.clipboard.writeText) {
12541
+ await navigator.clipboard.writeText(text);
12542
+ return true;
12543
+ } else {
12544
+ const textArea = document.createElement("textarea");
12545
+ textArea.value = text;
12546
+ textArea.style.position = "fixed";
12547
+ textArea.style.left = "-999999px";
12548
+ textArea.style.top = "-999999px";
12549
+ document.body.appendChild(textArea);
12550
+ textArea.select();
12551
+ if (document.execCommand("copy")) {
12552
+ document.body.removeChild(textArea);
12553
+ return true;
12554
+ } else {
12555
+ document.body.removeChild(textArea);
12556
+ return false;
12557
+ }
12558
+ }
12559
+ } catch (error) {
12560
+ console.error("复制到剪贴板失败:", error);
12561
+ return false;
12562
+ }
12465
12563
  }
12466
12564
  async function dynamicImport(modulePromise, exportName = "default") {
12467
12565
  const module = await modulePromise;
@@ -12483,7 +12581,7 @@ async function dynamicImports(modulePromise, exportNames) {
12483
12581
  }
12484
12582
  return result;
12485
12583
  }
12486
- function createApiDialog(DialogComponent) {
12584
+ function createApiDialog(DialogComponent, parentContainer) {
12487
12585
  let container = null;
12488
12586
  let vnode = null;
12489
12587
  let isOpen = false;
@@ -12518,6 +12616,8 @@ function createApiDialog(DialogComponent) {
12518
12616
  "modelValue": props.modelValue,
12519
12617
  "title": props.title,
12520
12618
  "width": props.width,
12619
+ // 如果提供了父容器,则挂载到父容器中
12620
+ "appendTo": parentContainer || void 0,
12521
12621
  "onUpdate:modelValue": (val) => {
12522
12622
  emit("update:modelValue", val);
12523
12623
  if (!val) {
@@ -12545,7 +12645,8 @@ function createApiDialog(DialogComponent) {
12545
12645
  const FinalDialogComponent = DialogComponent || DefaultDialog;
12546
12646
  function createContainer() {
12547
12647
  const el = document.createElement("div");
12548
- document.body.appendChild(el);
12648
+ const mountTarget = parentContainer || document.body;
12649
+ mountTarget.appendChild(el);
12549
12650
  return el;
12550
12651
  }
12551
12652
  function show(options = {}) {
@@ -12629,7 +12730,7 @@ const _BaseApi = class _BaseApi extends BaseHttpClient {
12629
12730
  const {
12630
12731
  responseFields,
12631
12732
  enableSystemErrorDialog = true,
12632
- systemErrorMessage = "系统异常",
12733
+ systemErrorMessage = "系统异常,点击看详情",
12633
12734
  ...baseConfig
12634
12735
  } = config;
12635
12736
  super(baseConfig);
@@ -12661,13 +12762,6 @@ const _BaseApi = class _BaseApi extends BaseHttpClient {
12661
12762
  this.systemErrorDialogInitPromise = this.initSystemErrorDialog();
12662
12763
  }
12663
12764
  }
12664
- /**
12665
- * 获取是否在浏览器环境(实例 getter)
12666
- * @returns 是否在浏览器环境
12667
- */
12668
- get hasDocument() {
12669
- return _BaseApi.hasDocument;
12670
- }
12671
12765
  /**
12672
12766
  * 获取系统错误信息存储(实例 getter)
12673
12767
  * @returns 系统错误信息存储 Map
@@ -12748,7 +12842,8 @@ const _BaseApi = class _BaseApi extends BaseHttpClient {
12748
12842
  async initSystemErrorDialog() {
12749
12843
  try {
12750
12844
  const { default: SystemErrorDialog2 } = await dynamicImports(Promise.resolve().then(() => SystemErrorDialog$1), ["default"]);
12751
- this.systemErrorDialogInstance = createApiDialog(SystemErrorDialog2);
12845
+ const popoverContainer = this.getPopoverContainer();
12846
+ this.systemErrorDialogInstance = createApiDialog(SystemErrorDialog2, popoverContainer);
12752
12847
  } catch (error) {
12753
12848
  console.warn("Failed to load SystemErrorDialog:", error);
12754
12849
  throw error;
@@ -12888,25 +12983,13 @@ const _BaseApi = class _BaseApi extends BaseHttpClient {
12888
12983
  })
12889
12984
  ])
12890
12985
  ]);
12891
- (_a2 = this.messageInstance) == null ? void 0 : _a2.error({
12986
+ (_a2 = this.messageInstance) == null ? void 0 : _a2.call(this, {
12987
+ type: "error",
12892
12988
  message: messageVNode,
12893
12989
  duration: 5 * 1e3,
12894
12990
  customClass: "system-error-message"
12895
12991
  // 添加自定义类名
12896
12992
  });
12897
- if (typeof document !== "undefined") {
12898
- let styleElement = document.getElementById("system-error-message-style");
12899
- if (!styleElement) {
12900
- styleElement = document.createElement("style");
12901
- styleElement.id = "system-error-message-style";
12902
- document.head.appendChild(styleElement);
12903
- }
12904
- styleElement.textContent = `
12905
- .system-error-message {
12906
- z-index: 99999998 !important;
12907
- }
12908
- `;
12909
- }
12910
12993
  }
12911
12994
  /**
12912
12995
  * 处理业务错误(其他非200错误码)
@@ -12917,7 +13000,8 @@ const _BaseApi = class _BaseApi extends BaseHttpClient {
12917
13000
  handleBusinessError(code, message2) {
12918
13001
  var _a2;
12919
13002
  if (code && code !== 200) {
12920
- (_a2 = this.messageInstance) == null ? void 0 : _a2.error({
13003
+ (_a2 = this.messageInstance) == null ? void 0 : _a2.call(this, {
13004
+ type: "error",
12921
13005
  message: message2 || "请求失败",
12922
13006
  duration: 5 * 1e3
12923
13007
  });
@@ -13013,24 +13097,10 @@ const _BaseApi = class _BaseApi extends BaseHttpClient {
13013
13097
  ...messageOptions,
13014
13098
  message: (messageOptions == null ? void 0 : messageOptions.message) ?? tipsMessage
13015
13099
  };
13016
- const messageType = finalOptions.type || "success";
13017
13100
  const messageInstance = this.messageInstance;
13018
13101
  if (!messageInstance)
13019
13102
  return;
13020
- switch (messageType) {
13021
- case "success":
13022
- messageInstance.success(finalOptions);
13023
- break;
13024
- case "error":
13025
- messageInstance.error(finalOptions);
13026
- break;
13027
- case "warning":
13028
- messageInstance.warning(finalOptions);
13029
- break;
13030
- case "info":
13031
- messageInstance.info(finalOptions);
13032
- break;
13033
- }
13103
+ messageInstance(finalOptions);
13034
13104
  }
13035
13105
  /**
13036
13106
  * 发送 HTTP 请求,所有 HTTP 方法最终都调用此方法
@@ -13115,11 +13185,6 @@ const _BaseApi = class _BaseApi extends BaseHttpClient {
13115
13185
  return super.downloadFile(blob, filename);
13116
13186
  }
13117
13187
  };
13118
- /**
13119
- * 检查是否在浏览器环境(在类初始化时判断)
13120
- * 注意:这是静态属性,所有实例共享
13121
- */
13122
- __publicField(_BaseApi, "hasDocument", typeof document !== "undefined");
13123
13188
  /**
13124
13189
  * 系统错误信息存储,用于在点击 icon 时打开详细错误弹窗
13125
13190
  * key: 错误ID,value: 错误信息对象
@@ -13262,6 +13327,22 @@ const SystemErrorDialog = defineComponent({
13262
13327
  function handleModelValueChange(val) {
13263
13328
  emit("update:modelValue", val);
13264
13329
  }
13330
+ function getAjaxPackageMessageContainer() {
13331
+ if (typeof document === "undefined")
13332
+ return null;
13333
+ return document.getElementById("ajaxPackage-message");
13334
+ }
13335
+ function getAjaxPackagePopoverContainer() {
13336
+ if (typeof document === "undefined")
13337
+ return null;
13338
+ return document.getElementById("ajaxPackage-popover");
13339
+ }
13340
+ function showMessage(options) {
13341
+ const container = getAjaxPackageMessageContainer();
13342
+ const { type = "info", message: message2 } = options;
13343
+ const finalOptions = container ? { type, message: message2, appendTo: container } : { type, message: message2 };
13344
+ ElMessage(finalOptions);
13345
+ }
13265
13346
  async function handleReport() {
13266
13347
  await baseApi.post("/upgGlobalExceptionReports", {
13267
13348
  username: userInfo.value.userName,
@@ -13275,7 +13356,7 @@ const SystemErrorDialog = defineComponent({
13275
13356
  menuUrl: currentUrl,
13276
13357
  errorMessage: props.errorMessage
13277
13358
  });
13278
- ElMessage.success("上报成功");
13359
+ showMessage({ type: "success", message: "上报成功" });
13279
13360
  handleClose();
13280
13361
  }
13281
13362
  function toggleTechSummary() {
@@ -13294,6 +13375,19 @@ const SystemErrorDialog = defineComponent({
13294
13375
  const skyWalkingUrl = `${origin2}/middle/skywalking/trace/Trace?traceId=${encodeURIComponent(props.traceId)}`;
13295
13376
  window.open(skyWalkingUrl, "_blank");
13296
13377
  }
13378
+ async function handleCopyTraceId() {
13379
+ const traceId = props.traceId;
13380
+ if (!traceId) {
13381
+ showMessage({ type: "warning", message: "TraceId 不存在" });
13382
+ return;
13383
+ }
13384
+ const success = await copyToClipboard(traceId);
13385
+ if (success) {
13386
+ showMessage({ type: "success", message: "复制 traceId 成功" });
13387
+ } else {
13388
+ showMessage({ type: "error", message: "复制 traceId 失败" });
13389
+ }
13390
+ }
13297
13391
  function close2() {
13298
13392
  handleClose();
13299
13393
  }
@@ -13304,6 +13398,7 @@ const SystemErrorDialog = defineComponent({
13304
13398
  return typeof props.width === "number" ? `${props.width}px` : props.width;
13305
13399
  });
13306
13400
  return () => {
13401
+ const popoverContainer = getAjaxPackagePopoverContainer();
13307
13402
  return h(
13308
13403
  ElDialog,
13309
13404
  {
@@ -13313,8 +13408,8 @@ const SystemErrorDialog = defineComponent({
13313
13408
  "showClose": true,
13314
13409
  "closeOnClickModal": false,
13315
13410
  "closeOnPressEscape": false,
13316
- "zIndex": 99999999,
13317
13411
  "style": { padding: "16px 0" },
13412
+ "appendTo": popoverContainer || void 0,
13318
13413
  "onUpdate:modelValue": handleModelValueChange
13319
13414
  },
13320
13415
  {
@@ -13403,7 +13498,20 @@ const SystemErrorDialog = defineComponent({
13403
13498
  )
13404
13499
  ]),
13405
13500
  // 黑色错误信息区域
13406
- h("div", { style: { backgroundColor: "#2c3e50", color: "#fff", padding: "16px 20px", fontFamily: 'Monaco, Consolas, "Courier New", monospace', fontSize: "12px", lineHeight: 1.5, maxHeight: "200px", overflowY: "auto" } }, [
13501
+ h("div", {
13502
+ style: {
13503
+ backgroundColor: "#2c3e50",
13504
+ color: "#fff",
13505
+ padding: "16px 20px",
13506
+ fontFamily: 'Monaco, Consolas, "Courier New", monospace',
13507
+ fontSize: "12px",
13508
+ lineHeight: 1.5,
13509
+ maxHeight: "200px",
13510
+ overflowY: "auto",
13511
+ cursor: "pointer"
13512
+ },
13513
+ onClick: handleCopyTraceId
13514
+ }, [
13407
13515
  h("div", { style: { marginBottom: "8px", color: "#ecf0f1" } }, `Trace ID: ${props.traceId || "a1b2c3d4-e5f6-7890-g1h2-i3j4k5l6m7n8"}`),
13408
13516
  h("div", { style: { color: "#e74c3c", fontWeight: "bold", whiteSpace: "pre-wrap" } }, `Error: ${props.errorMessage || "Connection timeout after 5000ms"}`)
13409
13517
  ])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moluoxixi/ajax-package",
3
- "version": "0.0.34",
3
+ "version": "0.0.35",
4
4
  "description": "AjaxPackage 组件",
5
5
  "sideEffects": [
6
6
  "*.css",