@moluoxixi/ajax-package 0.0.27 → 0.0.29

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.
@@ -6,6 +6,8 @@ export interface SystemErrorDialogPropsType {
6
6
  deptName?: string;
7
7
  deptId?: string;
8
8
  clientIp?: string;
9
+ isStart?: boolean;
10
+ menuName?: string;
9
11
  requestUrl?: string;
10
12
  traceId?: string;
11
13
  errorMessage?: string;
@@ -3,4 +3,5 @@ import { SystemErrorDialogPropsType } from '../_types/index.ts';
3
3
  export declare function normalizePayload(payload: any): Record<string, any>;
4
4
  export declare function resolveTraceId(headers: AxiosResponse['headers'] | undefined): string;
5
5
  export declare function getUserInfoFromLocalStorage(): Record<string, any>;
6
+ export declare function getCurrentMenuLocalStorage(): Record<string, any>;
6
7
  export declare function extractSystemErrorInfo(response: AxiosResponse, code: number, message: string): Omit<SystemErrorDialogPropsType, 'title' | 'width'>;
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("3fee00ce-04a4-4e27-a631-432b297808e9")) {
5
+ if (!document.getElementById("d511844d-9a24-4e81-830d-dc2af40a6fec")) {
6
6
  var elementStyle = document.createElement("style");
7
- elementStyle.id = "3fee00ce-04a4-4e27-a631-432b297808e9";
7
+ elementStyle.id = "d511844d-9a24-4e81-830d-dc2af40a6fec";
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
  }
@@ -7364,6 +7364,20 @@ function getUserInfoFromLocalStorage() {
7364
7364
  return {};
7365
7365
  }
7366
7366
  }
7367
+ function getCurrentMenuLocalStorage() {
7368
+ if (typeof window === "undefined" || typeof localStorage === "undefined")
7369
+ return {};
7370
+ try {
7371
+ const userInfoStr = localStorage.getItem("currentMenu");
7372
+ if (!userInfoStr)
7373
+ return {};
7374
+ const currentMenu = JSON.parse(userInfoStr);
7375
+ return currentMenu || {};
7376
+ } catch (error) {
7377
+ console.warn("Failed to parse currentMenu from localStorage:", error);
7378
+ return {};
7379
+ }
7380
+ }
7367
7381
  function extractSystemErrorInfo(response, code, message2) {
7368
7382
  var _a2, _b;
7369
7383
  const mergedRequestPayload = {
@@ -7380,12 +7394,15 @@ function extractSystemErrorInfo(response, code, message2) {
7380
7394
  return baseURL.endsWith("/") && url.startsWith("/") ? baseURL + url.slice(1) : baseURL.endsWith("/") || url.startsWith("/") || !url ? baseURL + url : `${baseURL}/${url}`;
7381
7395
  }
7382
7396
  const userInfo = getUserInfoFromLocalStorage();
7397
+ const currentMenu = getCurrentMenuLocalStorage();
7383
7398
  return {
7384
7399
  userName: userInfo.username ?? mergedRequestPayload.userName ?? mergedRequestPayload.username,
7385
7400
  userId: userInfo.id ?? mergedRequestPayload.userId ?? mergedRequestPayload.userid,
7386
7401
  deptName: userInfo.workDeptName ?? mergedRequestPayload.deptName ?? mergedRequestPayload.departmentName,
7387
7402
  deptId: userInfo.workDeptId ?? mergedRequestPayload.deptId ?? mergedRequestPayload.departmentId,
7388
7403
  clientIp: userInfo.loginip ?? mergedRequestPayload.clientIp ?? mergedRequestPayload.ip,
7404
+ isStart: userInfo.isStart ?? mergedRequestPayload.isStart,
7405
+ menuName: currentMenu.title ?? mergedRequestPayload.menuName,
7389
7406
  requestUrl: getFullRequestUrl(),
7390
7407
  traceId: resolveTraceId(response.headers),
7391
7408
  errorCode: code,
@@ -7916,8 +7933,23 @@ const _BaseApi = class _BaseApi extends BaseHttpClient {
7916
7933
  ]);
7917
7934
  (_a2 = this.messageInstance) == null ? void 0 : _a2.error({
7918
7935
  message: messageVNode,
7919
- duration: 5 * 1e3
7936
+ duration: 5 * 1e3,
7937
+ customClass: "system-error-message"
7938
+ // 添加自定义类名
7920
7939
  });
7940
+ if (typeof document !== "undefined") {
7941
+ let styleElement = document.getElementById("system-error-message-style");
7942
+ if (!styleElement) {
7943
+ styleElement = document.createElement("style");
7944
+ styleElement.id = "system-error-message-style";
7945
+ document.head.appendChild(styleElement);
7946
+ }
7947
+ styleElement.textContent = `
7948
+ .system-error-message {
7949
+ z-index: 99999998 !important;
7950
+ }
7951
+ `;
7952
+ }
7921
7953
  }
7922
7954
  handleBusinessError(code, message2) {
7923
7955
  var _a2;
@@ -7953,6 +7985,7 @@ const _BaseApi = class _BaseApi extends BaseHttpClient {
7953
7985
  const finalOptions = {
7954
7986
  ...defaultOptions,
7955
7987
  ...notificationOptions,
7988
+ dangerouslyUseHTMLString: true,
7956
7989
  message: html
7957
7990
  };
7958
7991
  (_a2 = this.notificationInstance) == null ? void 0 : _a2.call(this, finalOptions);
@@ -8103,12 +8136,15 @@ const SystemErrorDialog = defineComponent({
8103
8136
  const isMobile = typeof window !== "undefined" && window.innerWidth <= 768;
8104
8137
  const userInfo = computed(() => {
8105
8138
  const localUserInfo = getUserInfoFromLocalStorage();
8139
+ const currentMenu = getCurrentMenuLocalStorage();
8106
8140
  return {
8107
8141
  userName: localUserInfo.username ?? props.userName,
8108
8142
  userId: localUserInfo.usercode ?? props.userId,
8143
+ isStart: localUserInfo.isStart ?? false,
8144
+ menuName: (currentMenu == null ? void 0 : currentMenu.title) ?? "",
8109
8145
  deptName: localUserInfo.workDeptName ?? props.deptName,
8110
8146
  deptId: localUserInfo.workDeptId ?? props.deptId,
8111
- clientIp: localUserInfo.loginip ?? props.clientIp
8147
+ clientIp: localUserInfo.isStart ? localUserInfo.loginip ?? props.clientIp : ""
8112
8148
  };
8113
8149
  });
8114
8150
  const techSummaryItems = computed(() => [
@@ -8117,7 +8153,8 @@ const SystemErrorDialog = defineComponent({
8117
8153
  { label: "科室名称", value: userInfo.value.deptName },
8118
8154
  { label: "科室ID", value: userInfo.value.deptId },
8119
8155
  { label: "客户端IP", value: userInfo.value.clientIp },
8120
- { label: "菜单名称", value: currentUrl },
8156
+ { label: "菜单URL", value: currentUrl },
8157
+ { label: "菜单名称", value: userInfo.value.menuName },
8121
8158
  { label: "请求URL路径", value: props.requestUrl },
8122
8159
  { label: "链路ID", value: props.traceId }
8123
8160
  ]);
@@ -8146,7 +8183,8 @@ const SystemErrorDialog = defineComponent({
8146
8183
  clientIp: userInfo.value.clientIp,
8147
8184
  requestPath: props.requestUrl,
8148
8185
  traceId: props.traceId,
8149
- menuName: currentUrl,
8186
+ menuName: userInfo.value.menuName,
8187
+ menuUrl: currentUrl,
8150
8188
  errorMessage: props.errorMessage
8151
8189
  });
8152
8190
  ElMessage.success("上报成功");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moluoxixi/ajax-package",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "description": "AjaxPackage 组件",
5
5
  "sideEffects": [
6
6
  "*.css",