From 1776aa2d1e0548a83e61d937a1309360003351fb Mon Sep 17 00:00:00 2001 From: wangys <3401275564@qq.com> Date: Sat, 13 Dec 2025 14:13:31 +0800 Subject: [PATCH] =?UTF-8?q?web=20iframe=E7=BB=93=E6=9E=84=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../postgres/sql/initDataPermission.sql | 194 ++++++------ .../org/xyzh/api/system/vo/PermissionVO.java | 5 + .../mapper/role/TbSysRolePermissionMapper.xml | 2 + urbanLifelineWeb/NGINX_SSO_CONFIG.md | 267 ++++++++++++++++ .../packages/bidding/public/app-config.js | 7 + .../layouts/SidebarLayout/SidebarLayout.vue | 293 ++++++++++++++++++ .../src/layouts/SidebarLayout/index.ts | 1 + .../packages/bidding/src/layouts/index.ts | 3 + .../bidding/src/router/dynamicRoute.ts | 155 +++++++++ .../packages/bidding/src/router/index.ts | 94 ++++++ .../packages/bidding/src/types/shared.d.ts | 184 +++++++++++ .../packages/bidding/vite.config.ts | 8 +- urbanLifelineWeb/packages/platform/index.html | 3 - .../packages/platform/public/app-config.js | 7 + .../layouts/SidebarLayout/SidebarLayout.vue | 11 +- .../packages/platform/src/layouts/index.ts | 4 +- .../platform/src/router/dynamicRoute.ts | 94 +++--- .../packages/platform/src/router/index.ts | 8 +- .../packages/platform/src/types/shared.d.ts | 36 ++- .../platform/src/views/public/Login/Login.vue | 4 +- .../packages/platform/vite.config.ts | 5 + .../src/components/iframe/IframeView.vue | 90 ++++++ .../packages/shared/src/components/index.ts | 5 +- .../packages/shared/src/config/index.ts | 29 ++ .../src/layouts/BlankLayout/BlankLayout.vue | 18 ++ .../packages/shared/src/layouts/index.ts | 1 + .../shared/src/types/sys/permission.ts | 2 + .../shared/src/utils/route/route-generator.ts | 96 +++++- .../packages/shared/vite.config.ts | 11 +- .../workcase}/localSharedImportMap.js | 90 +----- urbanLifelineWeb/packages/workcase/index.html | 17 - .../packages/workcase/package.json | 1 + .../packages/workcase/pnpm-lock.yaml | 62 ++++ .../packages/workcase/public/app-config.js | 7 + .../packages/workcase/public/avatar.svg | 8 + .../packages/workcase/public/favicon.svg | 5 + .../packages/workcase/public/logo.jpg | Bin 0 -> 33240 bytes .../packages/workcase/src/App.vue | 27 ++ .../packages/workcase/src/config.ts | 34 ++ .../layouts/SidebarLayout/SidebarLayout.scss | 264 ++++++++++++++++ .../layouts/SidebarLayout/SidebarLayout.vue | 293 ++++++++++++++++++ .../packages/workcase/src/layouts/index.ts | 3 + .../packages/workcase/src/main.ts | 48 +++ .../workcase/src/router/dynamicRoute.ts | 154 +++++++++ .../packages/workcase/src/router/index.ts | 94 ++++++ .../packages/workcase/src/types/shared.d.ts | 179 +++++++++++ .../src/views/public/AIChat/AIChatView.scss | 247 +++++++++++++++ .../src/views/public/AIChat/AIChatView.vue | 193 ++++++++++++ .../public/AIChat/components/ChatHistory.scss | 61 ++++ .../public/AIChat/components/ChatHistory.vue | 51 +++ .../workcase/src/views/public/Login/Login.vue | 47 +++ .../packages/workcase/vite.config.ts | 27 +- .../frontend/vite.config.js | 6 + 53 files changed, 3280 insertions(+), 275 deletions(-) create mode 100644 urbanLifelineWeb/NGINX_SSO_CONFIG.md create mode 100644 urbanLifelineWeb/packages/bidding/src/layouts/SidebarLayout/SidebarLayout.vue create mode 100644 urbanLifelineWeb/packages/bidding/src/layouts/SidebarLayout/index.ts create mode 100644 urbanLifelineWeb/packages/bidding/src/layouts/index.ts create mode 100644 urbanLifelineWeb/packages/bidding/src/router/dynamicRoute.ts create mode 100644 urbanLifelineWeb/packages/bidding/src/router/index.ts create mode 100644 urbanLifelineWeb/packages/bidding/src/types/shared.d.ts create mode 100644 urbanLifelineWeb/packages/shared/src/components/iframe/IframeView.vue create mode 100644 urbanLifelineWeb/packages/shared/src/layouts/BlankLayout/BlankLayout.vue create mode 100644 urbanLifelineWeb/packages/shared/src/layouts/index.ts rename urbanLifelineWeb/packages/{shared/.__mf__temp/shared => workcase/.__mf__temp/workcase}/localSharedImportMap.js (55%) create mode 100644 urbanLifelineWeb/packages/workcase/public/avatar.svg create mode 100644 urbanLifelineWeb/packages/workcase/public/favicon.svg create mode 100644 urbanLifelineWeb/packages/workcase/public/logo.jpg create mode 100644 urbanLifelineWeb/packages/workcase/src/App.vue create mode 100644 urbanLifelineWeb/packages/workcase/src/config.ts create mode 100644 urbanLifelineWeb/packages/workcase/src/layouts/SidebarLayout/SidebarLayout.scss create mode 100644 urbanLifelineWeb/packages/workcase/src/layouts/SidebarLayout/SidebarLayout.vue create mode 100644 urbanLifelineWeb/packages/workcase/src/layouts/index.ts create mode 100644 urbanLifelineWeb/packages/workcase/src/main.ts create mode 100644 urbanLifelineWeb/packages/workcase/src/router/dynamicRoute.ts create mode 100644 urbanLifelineWeb/packages/workcase/src/router/index.ts create mode 100644 urbanLifelineWeb/packages/workcase/src/types/shared.d.ts create mode 100644 urbanLifelineWeb/packages/workcase/src/views/public/AIChat/AIChatView.scss create mode 100644 urbanLifelineWeb/packages/workcase/src/views/public/AIChat/AIChatView.vue create mode 100644 urbanLifelineWeb/packages/workcase/src/views/public/AIChat/components/ChatHistory.scss create mode 100644 urbanLifelineWeb/packages/workcase/src/views/public/AIChat/components/ChatHistory.vue create mode 100644 urbanLifelineWeb/packages/workcase/src/views/public/Login/Login.vue diff --git a/urbanLifelineServ/.bin/database/postgres/sql/initDataPermission.sql b/urbanLifelineServ/.bin/database/postgres/sql/initDataPermission.sql index e25c3e29..5d7ea90e 100644 --- a/urbanLifelineServ/.bin/database/postgres/sql/initDataPermission.sql +++ b/urbanLifelineServ/.bin/database/postgres/sql/initDataPermission.sql @@ -175,68 +175,67 @@ INSERT INTO sys.tb_sys_view ( ('VIEW-P001', 'view_platform_home', '全部应用', NULL, '/agents', 'public/Agents/AgentPlatformView.vue', 'Grid', 1, 'route', NULL, 'platform', 'SidebarLayout', 20, '全部智能体', 'system', now(), false), -- iframe 嵌入菜单 -('VIEW-P005', 'view_platform_workflow', '智能体编排', NULL, NULL, NULL, 'Connection', 1, +-- url: platform中的路由路径(用于sidebar定位和路由跳转) +-- iframe_url: iframe的src地址(实际内容的URL) +('VIEW-P005', 'view_platform_workflow', '智能体编排', NULL, '/app/workflow', NULL, 'Connection', 1, 'iframe', 'http://localhost:3000', 'platform', 'SidebarLayout', 30, 'Dify智能体编排(iframe)', 'system', now(), false), -('VIEW-P003', 'view_platform_bidding', '招标助手', NULL, NULL, NULL, 'Document', 1, - 'iframe', 'http://localhost:5002', 'platform', 'SidebarLayout', 40, '招标应用(iframe)', 'system', now(), false), -('VIEW-P004', 'view_platform_workcase', '泰豪小电', NULL, ‘’, NULL, 'Service', 1, - 'iframe', 'http://localhost:5003', 'platform', 'SidebarLayout', 50, '客服应用(iframe)', 'system', now(), false), +('VIEW-P003', 'view_platform_bidding', '招标助手', NULL, '/app/bidding', NULL, 'Document', 1, + 'iframe', '/bidding/', 'platform', 'SidebarLayout', 40, '招标应用(iframe)', 'system', now(), false), +('VIEW-P004', 'view_platform_workcase', '泰豪小电', NULL, '/app/workcase', NULL, 'Service', 1, + 'iframe', '/workcase/', 'platform', 'SidebarLayout', 50, '客服应用(iframe)', 'system', now(), false), --- 系统管理目录 -('VIEW-P100', 'view_system', '系统管理', NULL, '/system', NULL, 'Settings', 0, - 'route', NULL, 'platform', 'SidebarLayout', 100, '系统管理目录', 'system', now(), false), - --- 系统管理子菜单 -('VIEW-P101', 'view_user', '用户管理', 'view_system', '/system/user', 'system/UserList', 'Users', 1, - 'route', NULL, 'platform', 'SidebarLayout', 10, '用户管理页面', 'system', now(), false), - -('VIEW-P102', 'view_role', '角色管理', 'view_system', '/system/role', 'system/RoleList', 'Shield', 1, - 'route', NULL, 'platform', 'SidebarLayout', 20, '角色管理页面', 'system', now(), false), - -('VIEW-P103', 'view_dept', '部门管理', 'view_system', '/system/dept', 'system/DeptList', 'Building', 1, - 'route', NULL, 'platform', 'SidebarLayout', 30, '部门管理页面', 'system', now(), false), - -('VIEW-P104', 'view_permission', '权限管理', 'view_system', '/system/permission', 'system/PermissionList', 'Lock', 1, - 'route', NULL, 'platform', 'SidebarLayout', 40, '权限管理页面', 'system', now(), false), - -('VIEW-P105', 'view_config', '配置管理', 'view_system', '/system/config', 'system/ConfigList', 'Settings', 1, - 'route', NULL, 'platform', 'SidebarLayout', 50, '配置管理页面', 'system', now(), false), - -('VIEW-P106', 'view_file', '文件管理', 'view_system', '/system/file', 'system/FileList', 'FileText', 1, - 'route', NULL, 'platform', 'SidebarLayout', 60, '文件管理页面', 'system', now(), false), - -('VIEW-P107', 'view_message', '消息管理', 'view_system', '/system/message', 'system/MessageList', 'Mail', 1, - 'route', NULL, 'platform', 'SidebarLayout', 70, '消息管理页面', 'system', now(), false), - --- ========================= --- 招标应用菜单 (bidding) --- ========================= -('VIEW-B001', 'view_bidding_home', '首页', NULL, '/home', 'Home', 'House', 1, - 'route', NULL, 'bidding', 'DefaultLayout', 10, '招标应用首页', 'system', now(), false), - -('VIEW-B002', 'view_bidding_list', '招标列表', NULL, '/bidding/list', 'bidding/List', 'List', 1, - 'route', NULL, 'bidding', 'DefaultLayout', 20, '招标项目列表', 'system', now(), false), - -('VIEW-B003', 'view_bidding_detail', '招标详情', NULL, '/bidding/detail', 'bidding/Detail', 'Document', 1, - 'route', NULL, 'bidding', 'DefaultLayout', 30, '招标项目详情', 'system', now(), false), - -('VIEW-B004', 'view_bidding_offer', '投标管理', NULL, '/bidding/offer', 'bidding/Offer', 'Edit', 1, - 'route', NULL, 'bidding', 'DefaultLayout', 40, '投标管理页面', 'system', now(), false), +-- -- 系统管理目录 +-- ('VIEW-P100', 'view_system', '系统管理', NULL, '/system', NULL, 'Settings', 0, +-- 'route', NULL, 'platform', 'SidebarLayout', 100, '系统管理目录', 'system', now(), false), +-- +-- -- 系统管理子菜单 +-- ('VIEW-P101', 'view_user', '用户管理', 'view_system', '/system/user', 'system/UserList', 'Users', 1, +-- 'route', NULL, 'platform', 'SidebarLayout', 10, '用户管理页面', 'system', now(), false), +-- +-- ('VIEW-P102', 'view_role', '角色管理', 'view_system', '/system/role', 'system/RoleList', 'Shield', 1, +-- 'route', NULL, 'platform', 'SidebarLayout', 20, '角色管理页面', 'system', now(), false), +-- +-- ('VIEW-P103', 'view_dept', '部门管理', 'view_system', '/system/dept', 'system/DeptList', 'Building', 1, +-- 'route', NULL, 'platform', 'SidebarLayout', 30, '部门管理页面', 'system', now(), false), +-- +-- ('VIEW-P104', 'view_permission', '权限管理', 'view_system', '/system/permission', 'system/PermissionList', 'Lock', 1, +-- 'route', NULL, 'platform', 'SidebarLayout', 40, '权限管理页面', 'system', now(), false), +-- +-- ('VIEW-P105', 'view_config', '配置管理', 'view_system', '/system/config', 'system/ConfigList', 'Settings', 1, +-- 'route', NULL, 'platform', 'SidebarLayout', 50, '配置管理页面', 'system', now(), false), +-- +-- ('VIEW-P106', 'view_file', '文件管理', 'view_system', '/system/file', 'system/FileList', 'FileText', 1, +-- 'route', NULL, 'platform', 'SidebarLayout', 60, '文件管理页面', 'system', now(), false), +-- +-- ('VIEW-P107', 'view_message', '消息管理', 'view_system', '/system/message', 'system/MessageList', 'Mail', 1, +-- 'route', NULL, 'platform', 'SidebarLayout', 70, '消息管理页面', 'system', now(), false), +-- +-- -- ========================= +-- -- 招标应用菜单 (bidding) +-- -- ========================= +-- ('VIEW-B001', 'view_bidding_home', '首页', NULL, '/home', 'Home', 'House', 1, +-- 'route', NULL, 'bidding', 'DefaultLayout', 10, '招标应用首页', 'system', now(), false), +-- +-- ('VIEW-B002', 'view_bidding_list', '招标列表', NULL, '/bidding/list', 'bidding/List', 'List', 1, +-- 'route', NULL, 'bidding', 'DefaultLayout', 20, '招标项目列表', 'system', now(), false), +-- +-- ('VIEW-B003', 'view_bidding_detail', '招标详情', NULL, '/bidding/detail', 'bidding/Detail', 'Document', 1, +-- 'route', NULL, 'bidding', 'DefaultLayout', 30, '招标项目详情', 'system', now(), false), +-- +-- ('VIEW-B004', 'view_bidding_offer', '投标管理', NULL, '/bidding/offer', 'bidding/Offer', 'Edit', 1, +-- 'route', NULL, 'bidding', 'DefaultLayout', 40, '投标管理页面', 'system', now(), false), -- ========================= -- 客服应用菜单 (workcase) -- ========================= -('VIEW-W001', 'view_workcase_home', '首页', NULL, '/home', 'Home', 'House', 1, - 'route', NULL, 'workcase', 'DefaultLayout', 10, '客服应用首页', 'system', now(), false), +('VIEW-W001', 'view_workcase_home', '智能客服', NULL, '/', 'public/AIChat/AIChatView.vue', 'House', 3, + 'route', NULL, 'workcase', 'BlankLayout', 10, '智能客服首页', 'system', now(), false), -('VIEW-W002', 'view_workcase_list', '工单列表', NULL, '/workcase/list', 'workcase/List', 'Tickets', 1, - 'route', NULL, 'workcase', 'DefaultLayout', 20, '工单列表页面', 'system', now(), false), +('VIEW-W002', 'view_workcase_list', '工单列表', NULL, '/list', 'workcase/List', 'Tickets', 1, + 'route', NULL, 'workcase', 'SidebarLayout', 20, '工单列表页面', 'system', now(), false), -('VIEW-W003', 'view_workcase_detail', '工单详情', NULL, '/workcase/detail', 'workcase/Detail', 'Document', 1, - 'route', NULL, 'workcase', 'DefaultLayout', 30, '工单详情页面', 'system', now(), false), - -('VIEW-W004', 'view_workcase_chat', '智能客服', NULL, '/workcase/chat', 'workcase/Chat', 'ChatDotRound', 1, - 'route', NULL, 'workcase', 'DefaultLayout', 40, '智能客服聊天', 'system', now(), false); +('VIEW-W003', 'view_workcase_detail', '工单详情', NULL, '/detail', 'workcase/Detail', 'Document', 1, + 'route', NULL, 'workcase', 'SidebarLayout', 30, '工单详情页面', 'system', now(), false); -- ============================= -- 6. 角色权限关联(超级管理员拥有所有权限) @@ -319,45 +318,50 @@ INSERT INTO sys.tb_sys_view_permission ( ('VP-P004', 'view_platform_workcase', 'perm_platform_workcase', 'system', NULL, now(), false), ('VP-P005', 'view_platform_workflow', 'perm_platform_workflow', 'system', NULL, now(), false), --- 用户管理视图关联用户权限 -('VP-0001', 'view_user', 'perm_user_view', 'system', NULL, now(), false), -('VP-0002', 'view_user', 'perm_user_create', 'system', NULL, now(), false), -('VP-0003', 'view_user', 'perm_user_edit', 'system', NULL, now(), false), -('VP-0004', 'view_user', 'perm_user_delete', 'system', NULL, now(), false), -('VP-0005', 'view_user', 'perm_user_export', 'system', NULL, now(), false), +-- Workcase服务内部视图关联(使用同一个workcase访问权限) +('VP-W001', 'view_workcase_home', 'perm_platform_workcase', 'system', NULL, now(), false), +('VP-W002', 'view_workcase_list', 'perm_platform_workcase', 'system', NULL, now(), false), +('VP-W003', 'view_workcase_detail', 'perm_platform_workcase', 'system', NULL, now(), false); --- 角色管理视图关联角色权限 -('VP-0011', 'view_role', 'perm_role_view', 'system', NULL, now(), false), -('VP-0012', 'view_role', 'perm_role_create', 'system', NULL, now(), false), -('VP-0013', 'view_role', 'perm_role_edit', 'system', NULL, now(), false), -('VP-0014', 'view_role', 'perm_role_delete', 'system', NULL, now(), false), -('VP-0015', 'view_role', 'perm_role_export', 'system', NULL, now(), false), - --- 部门管理视图关联部门权限 -('VP-0021', 'view_dept', 'perm_dept_view', 'system', NULL, now(), false), -('VP-0022', 'view_dept', 'perm_dept_create', 'system', NULL, now(), false), -('VP-0023', 'view_dept', 'perm_dept_edit', 'system', NULL, now(), false), -('VP-0024', 'view_dept', 'perm_dept_delete', 'system', NULL, now(), false), -('VP-0025', 'view_dept', 'perm_dept_export', 'system', NULL, now(), false), - --- 权限管理视图关联权限管理权限 -('VP-0031', 'view_permission', 'perm_permission_view', 'system', NULL, now(), false), -('VP-0032', 'view_permission', 'perm_permission_manage', 'system', NULL, now(), false), - --- 配置管理视图关联配置权限 -('VP-0041', 'view_config', 'perm_config_view', 'system', NULL, now(), false), -('VP-0042', 'view_config', 'perm_config_edit', 'system', NULL, now(), false), -('VP-0043', 'view_config', 'perm_config_export', 'system', NULL, now(), false), - --- 文件管理视图关联文件权限 -('VP-0051', 'view_file', 'perm_file_view', 'system', NULL, now(), false), -('VP-0052', 'view_file', 'perm_file_upload', 'system', NULL, now(), false), -('VP-0053', 'view_file', 'perm_file_download', 'system', NULL, now(), false), -('VP-0054', 'view_file', 'perm_file_delete', 'system', NULL, now(), false), -('VP-0055', 'view_file', 'perm_file_export', 'system', NULL, now(), false), - --- 消息管理视图关联消息权限 -('VP-0061', 'view_message', 'perm_message_view', 'system', NULL, now(), false), -('VP-0062', 'view_message', 'perm_message_send', 'system', NULL, now(), false), -('VP-0063', 'view_message', 'perm_message_manage', 'system', NULL, now(), false), -('VP-0064', 'view_message', 'perm_message_export', 'system', NULL, now(), false); +-- -- 用户管理视图关联用户权限(已注释,因为view_user被注释掉了) +-- -- ('VP-0001', 'view_user', 'perm_user_view', 'system', NULL, now(), false), +-- -- ('VP-0002', 'view_user', 'perm_user_create', 'system', NULL, now(), false), +-- -- ('VP-0003', 'view_user', 'perm_user_edit', 'system', NULL, now(), false), +-- -- ('VP-0004', 'view_user', 'perm_user_delete', 'system', NULL, now(), false), +-- -- ('VP-0005', 'view_user', 'perm_user_export', 'system', NULL, now(), false), +-- -- +-- -- -- 角色管理视图关联角色权限 +-- -- ('VP-0011', 'view_role', 'perm_role_view', 'system', NULL, now(), false), +-- -- ('VP-0012', 'view_role', 'perm_role_create', 'system', NULL, now(), false), +-- -- ('VP-0013', 'view_role', 'perm_role_edit', 'system', NULL, now(), false), +-- -- ('VP-0014', 'view_role', 'perm_role_delete', 'system', NULL, now(), false), +-- -- ('VP-0015', 'view_role', 'perm_role_export', 'system', NULL, now(), false), +-- -- +-- -- -- 部门管理视图关联部门权限 +-- -- ('VP-0021', 'view_dept', 'perm_dept_view', 'system', NULL, now(), false), +-- -- ('VP-0022', 'view_dept', 'perm_dept_create', 'system', NULL, now(), false), +-- -- ('VP-0023', 'view_dept', 'perm_dept_edit', 'system', NULL, now(), false), +-- -- ('VP-0024', 'view_dept', 'perm_dept_delete', 'system', NULL, now(), false), +-- -- ('VP-0025', 'view_dept', 'perm_dept_export', 'system', NULL, now(), false), +-- -- +-- -- -- 权限管理视图关联权限管理权限 +-- -- ('VP-0031', 'view_permission', 'perm_permission_view', 'system', NULL, now(), false), +-- -- ('VP-0032', 'view_permission', 'perm_permission_manage', 'system', NULL, now(), false), +-- -- +-- -- -- 配置管理视图关联配置权限 +-- -- ('VP-0041', 'view_config', 'perm_config_view', 'system', NULL, now(), false), +-- -- ('VP-0042', 'view_config', 'perm_config_edit', 'system', NULL, now(), false), +-- -- ('VP-0043', 'view_config', 'perm_config_export', 'system', NULL, now(), false), +-- -- +-- -- -- 文件管理视图关联文件权限 +-- -- ('VP-0051', 'view_file', 'perm_file_view', 'system', NULL, now(), false), +-- -- ('VP-0052', 'view_file', 'perm_file_upload', 'system', NULL, now(), false), +-- -- ('VP-0053', 'view_file', 'perm_file_download', 'system', NULL, now(), false), +-- -- ('VP-0054', 'view_file', 'perm_file_delete', 'system', NULL, now(), false), +-- -- ('VP-0055', 'view_file', 'perm_file_export', 'system', NULL, now(), false), +-- -- +-- -- -- 消息管理视图关联消息权限 +-- -- ('VP-0061', 'view_message', 'perm_message_view', 'system', NULL, now(), false), +-- -- ('VP-0062', 'view_message', 'perm_message_send', 'system', NULL, now(), false), +-- -- ('VP-0063', 'view_message', 'perm_message_manage', 'system', NULL, now(), false), +-- -- ('VP-0064', 'view_message', 'perm_message_export', 'system', NULL, now(), false); diff --git a/urbanLifelineServ/apis/api-system/src/main/java/org/xyzh/api/system/vo/PermissionVO.java b/urbanLifelineServ/apis/api-system/src/main/java/org/xyzh/api/system/vo/PermissionVO.java index a69c5eed..6b2aff31 100644 --- a/urbanLifelineServ/apis/api-system/src/main/java/org/xyzh/api/system/vo/PermissionVO.java +++ b/urbanLifelineServ/apis/api-system/src/main/java/org/xyzh/api/system/vo/PermissionVO.java @@ -107,6 +107,9 @@ public class PermissionVO extends BaseVO { @Schema(description = "iframe URL") private String viewIframeUrl; + @Schema(description = "所属服务:platform=平台应用 bidding=招标应用 workcase=客服应用") + private String viewService; + @Schema(description = "布局") private String viewLayout; @@ -176,6 +179,7 @@ public class PermissionVO extends BaseVO { dto.setType(vo.getViewType()); dto.setViewType(vo.getViewViewType()); dto.setIframeUrl(vo.getViewIframeUrl()); + dto.setService(vo.getViewService()); dto.setLayout(vo.getViewLayout()); dto.setOrderNum(vo.getViewOrderNum()); dto.setDescription(vo.getViewDescription()); @@ -205,6 +209,7 @@ public class PermissionVO extends BaseVO { vo.setViewType(dto.getType()); vo.setViewViewType(dto.getViewType()); vo.setViewIframeUrl(dto.getIframeUrl()); + vo.setViewService(dto.getService()); vo.setViewLayout(dto.getLayout()); vo.setViewOrderNum(dto.getOrderNum()); vo.setViewDescription(dto.getDescription()); diff --git a/urbanLifelineServ/system/src/main/resources/mapper/role/TbSysRolePermissionMapper.xml b/urbanLifelineServ/system/src/main/resources/mapper/role/TbSysRolePermissionMapper.xml index dedb52d2..c7124f05 100644 --- a/urbanLifelineServ/system/src/main/resources/mapper/role/TbSysRolePermissionMapper.xml +++ b/urbanLifelineServ/system/src/main/resources/mapper/role/TbSysRolePermissionMapper.xml @@ -48,6 +48,7 @@ + @@ -267,6 +268,7 @@ v.type AS view_type, v.view_type AS view_view_type, v.iframe_url AS view_iframe_url, + v.service AS view_service, v.layout AS view_layout, v.order_num AS view_order_num, v.description AS view_description, diff --git a/urbanLifelineWeb/NGINX_SSO_CONFIG.md b/urbanLifelineWeb/NGINX_SSO_CONFIG.md new file mode 100644 index 00000000..4f96ff39 --- /dev/null +++ b/urbanLifelineWeb/NGINX_SSO_CONFIG.md @@ -0,0 +1,267 @@ +# Nginx单点登录配置说明 + +## 架构概述 + +本系统使用 **Platform** 作为统一入口和单点登录服务,其他服务(Workcase、Bidding)通过 Nginx 代理访问。 + +## 访问方式 + +### 开发环境(推荐通过Nginx访问) + +1. **启动Nginx** + ```bash + # Windows + cd f:\Environment\Nginx\nginx-1.28.0 + start nginx + ``` + +2. **启动各服务** + ```bash + # Platform (5001端口) + pnpm --filter platform dev + + # Workcase (5003端口) + pnpm --filter workcase dev + + # Bidding (5002端口) + pnpm --filter bidding dev + + # 后端API (8180端口) + # 启动Spring Boot应用 + ``` + +3. **访问地址** + - **统一入口**: http://localhost (Nginx 80端口) + - Platform: http://localhost/ + - Workcase: http://localhost/workcase + - Bidding: http://localhost/bidding + - 后端API: http://localhost/api + +### 生产环境 + +与开发环境配置完全一致,只需将各服务构建后部署即可。 + +```bash +# 构建所有服务 +pnpm build + +# Nginx配置已经就绪,直接启动即可 +``` + +## Nginx配置详解 + +### 核心配置 (nginx.conf) + +```nginx +# Platform 主应用(单点登录入口) +location / { + proxy_pass http://localhost:5001/; +} + +# Workcase 工单服务 +location /workcase/ { + proxy_pass http://localhost:5003/; +} + +# Bidding 招标服务 +location /bidding/ { + proxy_pass http://localhost:5002/; +} + +# 后端 API 统一入口 +location /api/ { + proxy_pass http://localhost:8180/; +} +``` + +## 单点登录流程 + +### 1. 用户访问流程 + +``` +用户访问 http://localhost + ↓ +Nginx代理到 Platform (5001) + ↓ +Platform检查token + ↓ +未登录 → 显示登录页 +已登录 → 显示主页和菜单 +``` + +### 2. 子服务访问流程 + +``` +用户点击"泰豪小电"菜单 + ↓ +Platform iframe加载 http://localhost/workcase + ↓ +Nginx代理到 Workcase (5003) + ↓ +Workcase从LocalStorage读取token + ↓ +有token → 加载workcase路由 +无token → 重定向到 /login (Platform登录页) +``` + +### 3. Token共享机制 + +所有服务共享同一个LocalStorage(因为都在同一个域名下),因此: + +- **Token存储**: `localStorage.setItem('token', ...)` +- **用户信息**: `localStorage.setItem('loginDomain', ...)` +- **视图数据**: `loginDomain.userViews` + +每个服务根据 `service` 字段筛选自己的视图: +```typescript +// Workcase筛选 +const workcaseViews = allViews.filter(view => view.service === 'workcase') + +// Platform筛选 +const platformViews = allViews.filter(view => view.service === 'platform') +``` + +## 配置文件 + +### 1. Shared配置 (`packages/shared/src/config/index.ts`) + +```typescript +sso: { + platformUrl: '/', // Platform地址(相对路径) + workcaseUrl: '/workcase', // Workcase地址 + biddingUrl: '/bidding' // Bidding地址 +} +``` + +### 2. App-config.js(各服务) + +**Platform** (`packages/platform/public/app-config.js`): +```javascript +sso: { + platformUrl: '/', + workcaseUrl: '/workcase', + biddingUrl: '/bidding' +} +``` + +**Workcase** (`packages/workcase/public/app-config.js`): +```javascript +sso: { + platformUrl: '/', + workcaseUrl: '/workcase', + biddingUrl: '/bidding' +} +``` + +## 路由配置 + +### Workcase路由守卫 + +```typescript +// 未登录重定向到Platform登录页 +if (requiresAuth && !hasToken) { + const platformUrl = APP_CONFIG.sso?.platformUrl || '/' + const loginPath = platformUrl.endsWith('/') + ? `${platformUrl}login` + : `${platformUrl}/login` + const platformLoginUrl = `${loginPath}?redirect=${encodeURIComponent(window.location.href)}` + window.location.href = platformLoginUrl +} +``` + +### 动态路由加载 + +```typescript +// 从LocalStorage加载并筛选本服务的视图 +const allViews = loadViewsFromStorage('loginDomain', 'userViews') +const workcaseViews = allViews.filter(view => view.service === 'workcase') +addDynamicRoutes(workcaseViews) +``` + +## 数据库配置 + +### 视图表service字段 + +确保 `tb_sys_view` 表的视图数据正确设置了 `service` 字段: + +```sql +-- Platform视图 +('VIEW-P001', 'view_platform_home', '全部应用', NULL, '/agents', ..., + 'route', NULL, 'platform', 'SidebarLayout', ...) + +-- Workcase视图 +('VIEW-W001', 'view_workcase_home', '工单首页', NULL, '/home', ..., + 'route', NULL, 'workcase', 'SidebarLayout', ...) + +-- Bidding视图 +('VIEW-B001', 'view_bidding_home', '首页', NULL, '/home', ..., + 'route', NULL, 'bidding', 'DefaultLayout', ...) +``` + +## 开发建议 + +### 方式一:通过Nginx访问(推荐) + +**优点**: +- 与生产环境完全一致 +- 测试单点登录功能 +- 避免跨域问题 + +**配置**: +- 所有服务使用相对路径 `/`, `/workcase`, `/bidding` +- 通过 http://localhost 访问 + +### 方式二:直接访问各服务端口 + +**优点**: +- 独立开发调试 +- HMR更快 + +**配置**: +- 修改 `devConfig.sso` 为绝对URL + ```typescript + sso: { + platformUrl: 'http://localhost:5001', + workcaseUrl: 'http://localhost:5003', + biddingUrl: 'http://localhost:5002' + } + ``` +- 直接访问 http://localhost:5001, http://localhost:5003 + +## 常见问题 + +### 1. 登录后跳转到错误的地址 + +**原因**: `platformUrl` 配置不正确 + +**解决**: 检查 `app-config.js` 中的 `sso.platformUrl` 配置 + +### 2. Token无法共享 + +**原因**: 不同端口访问导致LocalStorage隔离 + +**解决**: 统一通过Nginx访问(http://localhost) + +### 3. Nginx无法启动 + +**检查**: +- 80端口是否被占用 +- nginx.conf配置是否正确 + +### 4. 子服务路由404 + +**检查**: +- Vite配置中的 `base` 是否正确设置 +- Workcase: `base: '/workcase'` +- Bidding: `base: '/bidding'` + +## 重启服务 + +```bash +# 重启Nginx(Windows) +nginx -s reload + +# 或完全重启 +nginx -s quit +start nginx +``` diff --git a/urbanLifelineWeb/packages/bidding/public/app-config.js b/urbanLifelineWeb/packages/bidding/public/app-config.js index 90302297..fb0f4f03 100644 --- a/urbanLifelineWeb/packages/bidding/public/app-config.js +++ b/urbanLifelineWeb/packages/bidding/public/app-config.js @@ -51,6 +51,13 @@ window.APP_RUNTIME_CONFIG = { publicImgPath: '/img', publicWebPath: '/', + // 单点登录配置 + sso: { + platformUrl: '/', // platform 平台地址 + workcaseUrl: '/workcase', // workcase 服务地址 + biddingUrl: '/bidding' // bidding 服务地址 + }, + // 功能开关 features: { enableDebug: false, diff --git a/urbanLifelineWeb/packages/bidding/src/layouts/SidebarLayout/SidebarLayout.vue b/urbanLifelineWeb/packages/bidding/src/layouts/SidebarLayout/SidebarLayout.vue new file mode 100644 index 00000000..8c780394 --- /dev/null +++ b/urbanLifelineWeb/packages/bidding/src/layouts/SidebarLayout/SidebarLayout.vue @@ -0,0 +1,293 @@ +