From 873a9a953f74edac2250d5da3cbc78d3c3c14df2 Mon Sep 17 00:00:00 2001 From: zhangzhanwei Date: Fri, 27 Jun 2025 21:14:01 +0800 Subject: [PATCH] feat: System route permission --- ui/src/router/modules/system.ts | 128 ++++++++++++++++++++++---------- ui/src/utils/permission/data.ts | 18 +++-- 2 files changed, 98 insertions(+), 48 deletions(-) diff --git a/ui/src/router/modules/system.ts b/ui/src/router/modules/system.ts index 540e5ebf7..f55de3823 100644 --- a/ui/src/router/modules/system.ts +++ b/ui/src/router/modules/system.ts @@ -39,9 +39,7 @@ const systemRouter = { [RoleConst.ADMIN, RoleConst.WORKSPACE_MANAGE.getWorkspaceRole], [PermissionConst.ROLE_READ, PermissionConst.WORKSPACE_ROLE_READ], [EditionConst.IS_EE, EditionConst.IS_PE], - 'OR', - ), - ], + 'OR',),], }, component: () => import('@/views/system/role/index.vue'), }, @@ -61,9 +59,7 @@ const systemRouter = { [RoleConst.WORKSPACE_MANAGE, RoleConst.ADMIN], [PermissionConst.WORKSPACE_WORKSPACE_READ, PermissionConst.WORKSPACE_READ], [EditionConst.IS_EE], - 'OR', - ), - ], + 'OR',),], }, component: () => import('@/views/system/workspace/index.vue'), }, @@ -77,6 +73,20 @@ const systemRouter = { activeMenu: '/system', parentPath: '/system', parentName: 'system', + permission: [ + new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.RESOURCE_KNOWLEDGE_READ], + [EditionConst.IS_EE], + 'OR',),new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.RESOURCE_TOOL_READ], + [EditionConst.IS_EE], + 'OR',),new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.RESOURCE_MODEL_READ], + [EditionConst.IS_EE], + 'OR',),], }, children: [ // { @@ -100,6 +110,12 @@ const systemRouter = { parentPath: '/system', parentName: 'system', sameRoute: 'workspace', + permission: [ + new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.RESOURCE_KNOWLEDGE_READ], + [EditionConst.IS_EE], + 'OR',),], }, component: () => import('@/views/system-resource-management/KnowledgeResourceIndex.vue'), }, @@ -112,6 +128,12 @@ const systemRouter = { parentPath: '/system', parentName: 'system', sameRoute: 'workspace', + permission: [ + new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.RESOURCE_TOOL_READ], + [EditionConst.IS_EE], + 'OR',),], }, component: () => import('@/views/system-resource-management/ToolResourceIndex.vue'), }, @@ -123,6 +145,12 @@ const systemRouter = { activeMenu: '/system', parentPath: '/system', parentName: 'system', + permission: [ + new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.RESOURCE_MODEL_READ], + [EditionConst.IS_EE], + 'OR',),], }, component: () => import('@/views/system-resource-management/ModelResourceIndex.vue'), }, @@ -139,6 +167,12 @@ const systemRouter = { parentPath: '/system', parentName: 'system', sameRoute: 'authorization', + permission: [ + new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.SHARED_KNOWLEDGE_READ], + [EditionConst.IS_EE], + 'OR',),], }, children: [ @@ -198,7 +232,12 @@ const systemRouter = { activeMenu: '/system', parentPath: '/system', parentName: 'system', - permission: [EditionConst.IS_EE], + permission: [ + new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.SHARED_KNOWLEDGE_READ], + [EditionConst.IS_EE], + 'OR',),], }, children: [ { @@ -214,9 +253,15 @@ const systemRouter = { [RoleConst.ADMIN], [PermissionConst.SHARED_KNOWLEDGE_READ], [EditionConst.IS_EE], - 'OR', - ), - ], + 'OR',),new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.SHARED_TOOL_READ], + [EditionConst.IS_EE], + 'OR',),new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.SHARED_MODEL_READ], + [EditionConst.IS_EE], + 'OR',),], }, component: () => import('@/views/system-shared/KnowLedgeSharedIndex.vue'), }, @@ -233,10 +278,7 @@ const systemRouter = { [RoleConst.ADMIN], [PermissionConst.SHARED_TOOL_READ], [EditionConst.IS_EE], - 'OR', - ), - ], - }, + 'OR',),],}, component: () => import('@/views/system-shared/ToolSharedIndex.vue'), }, { @@ -252,9 +294,7 @@ const systemRouter = { [RoleConst.ADMIN], [PermissionConst.SHARED_MODEL_READ], [EditionConst.IS_EE], - 'OR', - ), - ], + 'OR',),], }, component: () => import('@/views/system-shared/ModelSharedIndex.vue'), }, @@ -275,9 +315,15 @@ const systemRouter = { [RoleConst.WORKSPACE_MANAGE, RoleConst.ADMIN], [PermissionConst.WORKSPACE_CHAT_USER_READ, PermissionConst.CHAT_USER_READ], [EditionConst.IS_EE, EditionConst.IS_PE], - 'OR', - ), - ], + 'OR',),new ComplexPermission( + [RoleConst.WORKSPACE_MANAGE, RoleConst.ADMIN], + [PermissionConst.WORKSPACE_USER_GROUP_READ, PermissionConst.USER_GROUP_READ], + [EditionConst.IS_EE, EditionConst.IS_PE], + 'OR',),new ComplexPermission( + [RoleConst.WORKSPACE_MANAGE, RoleConst.ADMIN], + [PermissionConst.CHAT_USER_AUTH_READ], + [EditionConst.IS_EE, EditionConst.IS_PE], + 'OR',)], }, children: [ { @@ -294,9 +340,7 @@ const systemRouter = { [RoleConst.WORKSPACE_MANAGE, RoleConst.ADMIN], [PermissionConst.CHAT_USER_READ, PermissionConst.WORKSPACE_CHAT_USER_READ], [EditionConst.IS_EE, EditionConst.IS_PE], - 'OR', - ), - ], + 'OR',),], }, component: () => import('@/views/system-chat-user/chat-user/index.vue'), }, @@ -314,9 +358,7 @@ const systemRouter = { [RoleConst.WORKSPACE_MANAGE, RoleConst.ADMIN], [PermissionConst.WORKSPACE_USER_GROUP_READ, PermissionConst.USER_GROUP_READ], [EditionConst.IS_EE, EditionConst.IS_PE], - 'OR', - ), - ], + 'OR',),], }, component: () => import('@/views/system-chat-user/group/index.vue'), }, @@ -334,9 +376,7 @@ const systemRouter = { [RoleConst.ADMIN], [PermissionConst.CHAT_USER_AUTH_READ], [EditionConst.IS_EE, EditionConst.IS_PE], - 'OR', - ), - ], + 'OR',),], }, component: () => import('@/views/system-chat-user/authentication/index.vue'), }, @@ -353,6 +393,20 @@ const systemRouter = { parentPath: '/system', parentName: 'system', sameRoute: 'setting', + permission: [ + new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.APPEARANCE_SETTINGS_READ], + [EditionConst.IS_EE, EditionConst.IS_PE], + 'OR',),new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.LOGIN_AUTH_READ], + [EditionConst.IS_EE, EditionConst.IS_PE], + 'OR',),new ComplexPermission( + [RoleConst.ADMIN], + [PermissionConst.EMAIL_SETTING_READ], + [EditionConst.IS_EE, EditionConst.IS_PE], + 'OR',),], }, children: [ { @@ -369,9 +423,7 @@ const systemRouter = { [RoleConst.ADMIN], [PermissionConst.APPEARANCE_SETTINGS_READ], [EditionConst.IS_EE, EditionConst.IS_PE], - 'OR', - ), - ], + 'OR',),], }, component: () => import('@/views/system-setting/theme/index.vue'), }, @@ -389,9 +441,7 @@ const systemRouter = { [RoleConst.ADMIN], [PermissionConst.LOGIN_AUTH_READ], [EditionConst.IS_EE, EditionConst.IS_PE], - 'OR', - ), - ], + 'OR',),], }, component: () => import('@/views/system-setting/authentication/index.vue'), }, @@ -409,9 +459,7 @@ const systemRouter = { [RoleConst.ADMIN], [PermissionConst.EMAIL_SETTING_READ], [EditionConst.IS_EE, EditionConst.IS_PE], - 'OR', - ), - ], + 'OR',),], }, component: () => import('@/views/system-setting/email/index.vue'), }, @@ -433,9 +481,7 @@ const systemRouter = { [RoleConst.ADMIN], [PermissionConst.OPERATION_LOG_READ], [EditionConst.IS_EE, EditionConst.IS_PE], - 'OR', - ), - ], + 'OR',),], }, component: () => import('@/views/system/operate-log/index.vue'), }, diff --git a/ui/src/utils/permission/data.ts b/ui/src/utils/permission/data.ts index f3f46c864..3b2fa76b2 100644 --- a/ui/src/utils/permission/data.ts +++ b/ui/src/utils/permission/data.ts @@ -194,13 +194,17 @@ const PermissionConst = { TOOL_IMPORT:new Permission('TOOL:READ+IMPORT'), TOOL_EXPORT:new Permission('TOOL:READ+EXPORT'), - RESOURCE_TOOL_CREATE:new Permission('SYSTEM_RES_TOOL:READ+CREATE'), - RESOURCE_TOOL_EDIT:new Permission('SYSTEM_RES_TOOL:READ+EDIT'), - RESOURCE_TOOL_READ:new Permission('SYSTEM_RES_TOOL:READ'), - RESOURCE_TOOL_DELETE:new Permission('SYSTEM_RES_TOOL:READ+DELETE'), - RESOURCE_TOOL_DEBUG:new Permission('SYSTEM_RES_TOOL:READ+DEBUG'), - RESOURCE_TOOL_IMPORT:new Permission('SYSTEM_RES_TOOL:READ+IMPORT'), - RESOURCE_TOOL_EXPORT:new Permission('SYSTEM_RES_TOOL:READ+EXPORT'), + RESOURCE_TOOL_CREATE:new Permission('SYSTEM_RESOURCE_TOOL:READ+CREATE'), + RESOURCE_TOOL_EDIT:new Permission('SYSTEM_RESOURCE_TOOL:READ+EDIT'), + RESOURCE_TOOL_READ:new Permission('SYSTEM_RESOURCE_TOOL:READ'), + RESOURCE_TOOL_DELETE:new Permission('SYSTEM_RESOURCE_TOOL:READ+DELETE'), + RESOURCE_TOOL_DEBUG:new Permission('SYSTEM_RESOURCE_TOOL:READ+DEBUG'), + RESOURCE_TOOL_IMPORT:new Permission('SYSTEM_RESOURCE_TOOL:READ+IMPORT'), + RESOURCE_TOOL_EXPORT:new Permission('SYSTEM_RESOURCE_TOOL:READ+EXPORT'), + + RESOURCE_KNOWLEDGE_READ:new Permission('SYSTEM_RESOURCE_KNOWLEDGE:READ'), + + RESOURCE_MODEL_READ:new Permission('SYSTEM_RESOURCE_MODEL:READ'), APPEARANCE_SETTINGS_READ:new Permission('APPEARANCE_SETTINGS:READ'), APPEARANCE_SETTINGS_EDIT:new Permission('APPEARANCE_SETTINGS:READ+EDIT'),