|
|
@@ -1,3 +1,7 @@
|
|
|
+// import { generatePersistentKey } from "@/config/project";
|
|
|
+
|
|
|
+// const PERSISTENT_KEY = generatePersistentKey();
|
|
|
+
|
|
|
/**
|
|
|
* JeecgBoot 页面跳转工具
|
|
|
* 利用共享的 localStorage 实现免登录跳转
|
|
|
@@ -22,40 +26,40 @@ export interface JeecgPageConfig {
|
|
|
*/
|
|
|
export const systemPages: JeecgPageConfig[] = [
|
|
|
{
|
|
|
- key: 'user',
|
|
|
- title: '用户管理',
|
|
|
- path: '/system/user',
|
|
|
- description: '管理系统用户',
|
|
|
+ key: "user",
|
|
|
+ title: "用户管理",
|
|
|
+ path: "/system/user",
|
|
|
+ description: "管理系统用户",
|
|
|
},
|
|
|
{
|
|
|
- key: 'role',
|
|
|
- title: '角色管理',
|
|
|
- path: '/system/role',
|
|
|
- description: '管理用户角色和权限',
|
|
|
+ key: "role",
|
|
|
+ title: "角色管理",
|
|
|
+ path: "/system/role",
|
|
|
+ description: "管理用户角色和权限",
|
|
|
},
|
|
|
{
|
|
|
- key: 'menu',
|
|
|
- title: '菜单管理',
|
|
|
- path: '/system/menu',
|
|
|
- description: '管理系统菜单和权限',
|
|
|
+ key: "menu",
|
|
|
+ title: "菜单管理",
|
|
|
+ path: "/system/menu",
|
|
|
+ description: "管理系统菜单和权限",
|
|
|
},
|
|
|
{
|
|
|
- key: 'depart',
|
|
|
- title: '部门管理',
|
|
|
- path: '/system/depart',
|
|
|
- description: '管理组织架构',
|
|
|
+ key: "depart",
|
|
|
+ title: "部门管理",
|
|
|
+ path: "/system/depart",
|
|
|
+ description: "管理组织架构",
|
|
|
},
|
|
|
{
|
|
|
- key: 'dict',
|
|
|
- title: '字典管理',
|
|
|
- path: '/system/dict',
|
|
|
- description: '管理数据字典',
|
|
|
+ key: "dict",
|
|
|
+ title: "字典管理",
|
|
|
+ path: "/system/dict",
|
|
|
+ description: "管理数据字典",
|
|
|
},
|
|
|
{
|
|
|
- key: 'log',
|
|
|
- title: '日志管理',
|
|
|
- path: '/system/log',
|
|
|
- description: '查看系统日志',
|
|
|
+ key: "log",
|
|
|
+ title: "日志管理",
|
|
|
+ path: "/system/log",
|
|
|
+ description: "查看系统日志",
|
|
|
},
|
|
|
];
|
|
|
|
|
|
@@ -64,45 +68,51 @@ export const systemPages: JeecgPageConfig[] = [
|
|
|
* @param path JeecgBoot 页面路径
|
|
|
* @param newTab 是否在新标签页打开
|
|
|
*/
|
|
|
-export function navigateToJeecg(path: string, newTab: boolean = false): void {
|
|
|
- // 确保路径以 / 开头
|
|
|
- const normalizedPath = path.startsWith('/') ? path : `/${path}`;
|
|
|
-
|
|
|
- // 生产环境:同域名,直接跳转
|
|
|
- // 开发环境:不同端口,localStorage 不共享,需要通过 URL 参数传递 token
|
|
|
- if (import.meta.env.PROD) {
|
|
|
- // 生产环境:直接跳转
|
|
|
- const url = normalizedPath;
|
|
|
- if (newTab) {
|
|
|
- window.open(url, '_blank');
|
|
|
- } else {
|
|
|
- window.location.href = url;
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 开发环境:通过 URL 参数传递认证信息
|
|
|
- const token = localStorage.getItem('内容中心管理系统__PRODUCTION__1.0.0__COMMON__LOCAL__KEY__');
|
|
|
- const url = `http://localhost:3100${normalizedPath}`;
|
|
|
-
|
|
|
- if (token) {
|
|
|
- // 将 token 通过 URL 参数传递(仅用于开发环境测试)
|
|
|
- const urlWithToken = `${url}?_dev_token=${encodeURIComponent(token)}`;
|
|
|
-
|
|
|
- if (newTab) {
|
|
|
- window.open(urlWithToken, '_blank');
|
|
|
- } else {
|
|
|
- window.location.href = urlWithToken;
|
|
|
- }
|
|
|
-
|
|
|
- console.warn('[Dev Only] Token passed via URL parameter for local testing');
|
|
|
- } else {
|
|
|
- // 没有 token,直接跳转
|
|
|
- if (newTab) {
|
|
|
- window.open(url, '_blank');
|
|
|
- } else {
|
|
|
- window.location.href = url;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+export function navigateToJeecg(path: string): void {
|
|
|
+ const jeecgDomain = import.meta.env.VITE_JEECG_DOAMAIN;
|
|
|
+ window.open(jeecgDomain.replace(/\/$/, "") + path, "_blank");
|
|
|
+ return;
|
|
|
+
|
|
|
+ // // 确保路径以 / 开头
|
|
|
+ // const normalizedPath = path.startsWith("/") ? path : `/${path}`;
|
|
|
+
|
|
|
+ // // 生产环境:同域名,直接跳转
|
|
|
+ // // 开发环境:不同端口,localStorage 不共享,需要通过 URL 参数传递 token
|
|
|
+ // if (import.meta.env.PROD) {
|
|
|
+ // // 生产环境:直接跳转
|
|
|
+ // const url = normalizedPath;
|
|
|
+ // if (newTab) {
|
|
|
+ // window.open(url, "_blank");
|
|
|
+ // } else {
|
|
|
+ // window.location.href = url;
|
|
|
+ // }
|
|
|
+ // } else {
|
|
|
+ // // 开发环境:通过 URL 参数传递认证信息
|
|
|
+ // const token = localStorage.getItem(PERSISTENT_KEY);
|
|
|
+ // const url = `http://localhost:3100${normalizedPath}`;
|
|
|
+
|
|
|
+ // if (token) {
|
|
|
+ // // 将 token 通过 URL 参数传递(仅用于开发环境测试)
|
|
|
+ // const urlWithToken = `${url}?_dev_token=${encodeURIComponent(token)}`;
|
|
|
+
|
|
|
+ // if (newTab) {
|
|
|
+ // window.open(urlWithToken, "_blank");
|
|
|
+ // } else {
|
|
|
+ // window.location.href = urlWithToken;
|
|
|
+ // }
|
|
|
+
|
|
|
+ // console.warn(
|
|
|
+ // "[Dev Only] Token passed via URL parameter for local testing"
|
|
|
+ // );
|
|
|
+ // } else {
|
|
|
+ // // 没有 token,直接跳转
|
|
|
+ // if (newTab) {
|
|
|
+ // window.open(url, "_blank");
|
|
|
+ // } else {
|
|
|
+ // window.location.href = url;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -110,23 +120,11 @@ export function navigateToJeecg(path: string, newTab: boolean = false): void {
|
|
|
* @param key 页面标识
|
|
|
* @param newTab 是否在新标签页打开
|
|
|
*/
|
|
|
-export function navigateToJeecgByKey(key: string, newTab: boolean = false): void {
|
|
|
- const page = systemPages.find(p => p.key === key);
|
|
|
+export function navigateToJeecgByKey(key: string): void {
|
|
|
+ const page = systemPages.find((p) => p.key === key);
|
|
|
if (page) {
|
|
|
- navigateToJeecg(page.path, newTab);
|
|
|
+ navigateToJeecg(page.path);
|
|
|
} else {
|
|
|
console.error(`[JeecgNavigation] Page not found: ${key}`);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-/**
|
|
|
- * 获取 JeecgBoot 页面完整 URL
|
|
|
- * @param path JeecgBoot 页面路径
|
|
|
- */
|
|
|
-export function getJeecgUrl(path: string): string {
|
|
|
- const normalizedPath = path.startsWith('/') ? path : `/${path}`;
|
|
|
-
|
|
|
- return import.meta.env.PROD
|
|
|
- ? `${window.location.origin}${normalizedPath}`
|
|
|
- : `http://localhost:3100${normalizedPath}`;
|
|
|
-}
|