hrp-ui-base 1.4.5 → 1.4.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hrp-ui-base",
3
- "version": "1.4.5",
3
+ "version": "1.4.6",
4
4
  "description": "HRP 前端公共组件、工具方法和基础样式包",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -11,7 +11,7 @@
11
11
  "devDependencies": {},
12
12
  "module": "index.ts",
13
13
  "peerDependencies": {
14
- "hrp-ui-base": "1.4.4",
14
+ "hrp-ui-base": "1.4.6",
15
15
  "vue": "^3.0.0"
16
16
  }
17
17
  }
@@ -110,7 +110,7 @@ import type { TabsOptions } from "./stores/useLayoutTabsStore";
110
110
  import type HomeMenu from "../../api/bms/home/bo/HomeMenu";
111
111
  import type NoticeVO from "../../api/notice/bo/NoticeVO";
112
112
  import { ElNotification, ElMessage } from "element-plus";
113
- import { navigateByDomainRoute } from "./utils/redirect";
113
+ import { navigateByDomainRoute, navigateToPmsAuthRoute } from "./utils/redirect";
114
114
 
115
115
  defineOptions({ name: "LayoutContainer" });
116
116
 
@@ -291,8 +291,8 @@ const handleMessageNavigate = async (notice: NoticeVO) => {
291
291
  updateNum.value += 1;
292
292
  if (notice.noticeType === "file-notice") return;
293
293
  if (!notice.urlRoute) return;
294
- if (notice.urlRoute.startsWith("/project/") && options?.onCrossAppNavigate) {
295
- options.onCrossAppNavigate(notice.urlRoute);
294
+ if (notice.urlRoute.startsWith("/project/")) {
295
+ navigateToPmsAuthRoute(notice.urlRoute);
296
296
  } else {
297
297
  await navigateByDomainRoute(notice.urlRoute, router);
298
298
  }
@@ -419,8 +419,8 @@ const showNoticeNotification = async (notice: NoticeVO) => {
419
419
  if (options?.onFileDownload) {
420
420
  options.onFileDownload(notice);
421
421
  }
422
- } else if (notice.urlRoute?.startsWith("/project/") && options?.onCrossAppNavigate) {
423
- options.onCrossAppNavigate(notice.urlRoute);
422
+ } else if (notice.urlRoute?.startsWith("/project/")) {
423
+ navigateToPmsAuthRoute(notice.urlRoute);
424
424
  } else {
425
425
  await navigateByDomainRoute(notice.urlRoute, router);
426
426
  }
@@ -9,6 +9,7 @@ const menuStateRelation: Record<string, string> = {
9
9
  scm: "scm",
10
10
  bms: "bms",
11
11
  coc: "coc",
12
+ pms: "pms",
12
13
  hws: "hws",
13
14
  kbs: "kbs",
14
15
  fms: "fms",
@@ -51,9 +52,15 @@ export const getLayoutBasePath = () => {
51
52
 
52
53
  const parts = pathname.split("/").filter(Boolean);
53
54
  const knownDomainIds = getKnownDomainIds();
54
- const lastPart = parts[parts.length - 1];
55
- if (lastPart && knownDomainIds.includes(lastPart)) {
56
- return normalizeBasePath(`/${parts.slice(0, -1).join("/")}`);
55
+ let domainIndex = -1;
56
+ for (let i = parts.length - 1; i >= 0; i--) {
57
+ if (knownDomainIds.includes(parts[i])) {
58
+ domainIndex = i;
59
+ break;
60
+ }
61
+ }
62
+ if (domainIndex !== -1) {
63
+ return normalizeBasePath(`/${parts.slice(0, domainIndex).join("/")}`);
57
64
  }
58
65
 
59
66
  return normalizeBasePath(pathname.replace(/\/$/, ""));
@@ -97,6 +104,23 @@ export const getDomainRedirectUrl = (urlRoute: string) => {
97
104
  return `${originBase}/${domainId}/#${routePath}`;
98
105
  };
99
106
 
107
+ export const buildPmsAuthUrl = (urlRoute: string) => {
108
+ const routePath = normalizeRoutePath(urlRoute);
109
+ const projectId = routePath.match(/^\/project\/([^/]+)/)?.[1] || "";
110
+ const token = localStorage.getItem("TOKEN") || "";
111
+ const pmsBase = import.meta.env.DEV
112
+ ? `${window.location.protocol}//${window.location.hostname}:5191`
113
+ : `${window.location.origin}${getLayoutBasePath()}/pms`;
114
+
115
+ return `${pmsBase}/#/auth?projectId=${projectId}&token=${encodeURIComponent(token)}&returnUrl=${encodeURIComponent(routePath)}`;
116
+ };
117
+
118
+ export const navigateToPmsAuthRoute = (urlRoute: string) => {
119
+ const targetUrl = buildPmsAuthUrl(urlRoute);
120
+ if (!targetUrl) return;
121
+ window.open(targetUrl, "_blank");
122
+ };
123
+
100
124
  const isSameAppUrl = (targetUrl: string) => {
101
125
  const target = new URL(targetUrl, window.location.origin);
102
126
  const currentPath = window.location.pathname.replace(/\/$/, "");
@@ -118,4 +142,3 @@ export const navigateByDomainRoute = async (urlRoute: string, router?: any) => {
118
142
 
119
143
  window.location.href = targetUrl;
120
144
  };
121
-