You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
334 lines
8.2 KiB
334 lines
8.2 KiB
import { LucideIcon, LayoutDashboard, Users, Settings, TestTube, BarChart3, Gauge, FileText, ClipboardList, Network, Smartphone } from 'lucide-react';
|
|
|
|
// 定义权限类型
|
|
export type Permission =
|
|
| 'dashboard.view'
|
|
| 'users.view'
|
|
| 'users.manage'
|
|
| 'roles.view'
|
|
| 'roles.manage'
|
|
| 'permissions.view'
|
|
| 'permissions.manage'
|
|
| 'settings.view'
|
|
| 'settings.manage'
|
|
// 场景管理权限
|
|
| 'scenarios.view'
|
|
| 'scenarios.manage'
|
|
// 用例管理权限
|
|
| 'testcases.view'
|
|
| 'testcases.manage'
|
|
| 'testcases.create'
|
|
| 'teststeps.view'
|
|
| 'teststeps.manage'
|
|
| 'teststeps.create'
|
|
// 任务管理权限
|
|
| 'tasks.view'
|
|
| 'tasks.manage'
|
|
| 'tasks.create'
|
|
| 'taskreviews.view'
|
|
| 'taskreviews.manage'
|
|
| 'taskreviews.create'
|
|
| 'taskexecutions.view'
|
|
| 'taskexecutions.manage'
|
|
| 'taskexecutions.create'
|
|
// 结果分析权限
|
|
| 'functionalanalysis.view'
|
|
| 'functionalanalysis.manage'
|
|
| 'performanceanalysis.view'
|
|
| 'performanceanalysis.manage'
|
|
| 'issueanalysis.view'
|
|
| 'issueanalysis.manage'
|
|
| 'ueanalysis.view'
|
|
| 'ueanalysis.manage'
|
|
// 仪表管理权限
|
|
| 'devices.view'
|
|
| 'devices.manage'
|
|
| 'protocols.view'
|
|
| 'protocols.manage'
|
|
| 'ranconfigurations.view'
|
|
| 'ranconfigurations.manage'
|
|
| 'imsconfigurations.view'
|
|
| 'imsconfigurations.manage'
|
|
| 'corenetworkconfigs.view'
|
|
| 'corenetworkconfigs.manage'
|
|
| 'networkstackconfigs.view'
|
|
| 'networkstackconfigs.manage'
|
|
// 终端服务管理权限
|
|
| 'terminalservices.view'
|
|
| 'terminalservices.manage'
|
|
// 终端设备管理权限
|
|
| 'terminaldevices.view'
|
|
| 'terminaldevices.manage'
|
|
// ADB操作管理权限
|
|
| 'adboperations.view'
|
|
| 'adboperations.manage'
|
|
// AT操作管理权限
|
|
| 'atoperations.view'
|
|
| 'atoperations.manage'
|
|
// 设备运行时管理权限
|
|
| 'deviceruntimes.view'
|
|
| 'deviceruntimes.manage'
|
|
// 协议日志管理权限
|
|
| 'protocollogs.view'
|
|
| 'protocollogs.manage'
|
|
|
|
|
|
export interface MenuItem {
|
|
title: string;
|
|
icon: LucideIcon;
|
|
href: string;
|
|
permission?: Permission;
|
|
children?: {
|
|
title: string;
|
|
href: string;
|
|
permission?: Permission;
|
|
}[];
|
|
}
|
|
|
|
export const menuItems: MenuItem[] = [
|
|
{
|
|
title: '仪表盘',
|
|
icon: LayoutDashboard,
|
|
href: '/dashboard',
|
|
permission: 'dashboard.view',
|
|
},
|
|
{
|
|
title: '场景管理',
|
|
icon: FileText,
|
|
href: '/dashboard/scenarios',
|
|
permission: 'scenarios.view',
|
|
children: [
|
|
{
|
|
title: '场景列表',
|
|
href: '/dashboard/scenarios/list',
|
|
permission: 'scenarios.view',
|
|
},
|
|
{
|
|
title: '场景配置',
|
|
href: '/dashboard/scenarios/config',
|
|
permission: 'scenarios.manage',
|
|
},
|
|
{
|
|
title: '场景绑定',
|
|
href: '/dashboard/scenarios/binding',
|
|
permission: 'scenarios.manage',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: '用例管理',
|
|
icon: TestTube,
|
|
href: '/dashboard/testcases',
|
|
permission: 'testcases.view',
|
|
children: [
|
|
{
|
|
title: '用例列表',
|
|
href: '/dashboard/testcases/list',
|
|
permission: 'testcases.view',
|
|
},
|
|
{
|
|
title: '创建用例',
|
|
href: '/dashboard/testcases/create',
|
|
permission: 'testcases.create',
|
|
},
|
|
{
|
|
title: '步骤列表',
|
|
href: '/dashboard/testcases/steps',
|
|
permission: 'teststeps.view',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: '任务管理',
|
|
icon: ClipboardList,
|
|
href: '/dashboard/tasks',
|
|
permission: 'tasks.view',
|
|
children: [
|
|
{
|
|
title: '任务列表',
|
|
href: '/dashboard/tasks/list',
|
|
permission: 'tasks.view',
|
|
},
|
|
{
|
|
title: '创建任务',
|
|
href: '/dashboard/tasks/create',
|
|
permission: 'tasks.create',
|
|
},
|
|
{
|
|
title: '审核任务',
|
|
href: '/dashboard/tasks/reviews',
|
|
permission: 'taskreviews.view',
|
|
},
|
|
{
|
|
title: '执行任务',
|
|
href: '/dashboard/tasks/executions',
|
|
permission: 'taskexecutions.view',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: '结果分析',
|
|
icon: BarChart3,
|
|
href: '/dashboard/analysis',
|
|
permission: 'functionalanalysis.view',
|
|
children: [
|
|
{
|
|
title: '功能分析',
|
|
href: '/dashboard/analysis/functional',
|
|
permission: 'functionalanalysis.view',
|
|
},
|
|
{
|
|
title: '性能分析',
|
|
href: '/dashboard/analysis/performance',
|
|
permission: 'performanceanalysis.view',
|
|
},
|
|
{
|
|
title: '问题分析',
|
|
href: '/dashboard/analysis/issue',
|
|
permission: 'issueanalysis.view',
|
|
},
|
|
{
|
|
title: 'UE分析',
|
|
href: '/dashboard/analysis/ue',
|
|
permission: 'ueanalysis.view',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: '仪表管理',
|
|
icon: Gauge,
|
|
href: '/dashboard/instruments',
|
|
permission: 'devices.view',
|
|
children: [
|
|
{
|
|
title: '设备列表',
|
|
href: '/dashboard/instruments/list',
|
|
permission: 'devices.view',
|
|
},
|
|
{
|
|
title: '协议列表',
|
|
href: '/dashboard/instruments/protocols',
|
|
permission: 'protocols.view',
|
|
},
|
|
{
|
|
title: '启动设备网络',
|
|
href: '/dashboard/instruments/device-runtimes/list',
|
|
permission: 'deviceruntimes.view',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: '终端管理',
|
|
icon: Smartphone,
|
|
href: '/dashboard/terminal-services',
|
|
permission: 'terminalservices.view',
|
|
children: [
|
|
{
|
|
title: '终端服务',
|
|
href: '/dashboard/terminal-services',
|
|
permission: 'terminalservices.view',
|
|
},
|
|
{
|
|
title: '终端设备',
|
|
href: '/dashboard/terminal-devices/list',
|
|
permission: 'terminaldevices.view',
|
|
},
|
|
{
|
|
title: 'ADB命令配置',
|
|
href: '/dashboard/terminal-services/adb-operations',
|
|
permission: 'adboperations.view',
|
|
},
|
|
{
|
|
title: 'AT命令配置',
|
|
href: '/dashboard/terminal-services/at-operations',
|
|
permission: 'atoperations.view',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: '信令分析',
|
|
icon: FileText,
|
|
href: '/dashboard/protocol-logs',
|
|
permission: 'protocollogs.view',
|
|
children: [
|
|
{
|
|
title: '在线协议日志',
|
|
href: '/dashboard/protocol-logs/online-logs',
|
|
permission: 'protocollogs.view',
|
|
},
|
|
{
|
|
title: '历史协议日志',
|
|
href: '/dashboard/protocol-logs/history-logs',
|
|
permission: 'protocollogs.view',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: '网络栈配置',
|
|
icon: Network,
|
|
href: '/dashboard/network-stack-configs',
|
|
permission: 'ranconfigurations.view',
|
|
children: [
|
|
{
|
|
title: 'RAN配置',
|
|
href: '/dashboard/network-stack-configs/ran-configurations',
|
|
permission: 'ranconfigurations.view',
|
|
},
|
|
{
|
|
title: 'IMS配置',
|
|
href: '/dashboard/network-stack-configs/ims-configurations',
|
|
permission: 'imsconfigurations.view',
|
|
},
|
|
{
|
|
title: '核心网络配置',
|
|
href: '/dashboard/network-stack-configs/core-network-configs',
|
|
permission: 'corenetworkconfigs.view',
|
|
},
|
|
{
|
|
title: '网络栈配置',
|
|
href: '/dashboard/network-stack-configs/network-stack-configs',
|
|
permission: 'networkstackconfigs.view',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: '用户管理',
|
|
icon: Users,
|
|
href: '/dashboard/users',
|
|
permission: 'users.view',
|
|
children: [
|
|
{
|
|
title: '用户列表',
|
|
href: '/dashboard/users/list',
|
|
permission: 'users.view',
|
|
},
|
|
{
|
|
title: '角色管理',
|
|
href: '/dashboard/users/roles',
|
|
permission: 'roles.view',
|
|
},
|
|
{
|
|
title: '权限管理',
|
|
href: '/dashboard/users/permissions',
|
|
permission: 'permissions.view',
|
|
},
|
|
],
|
|
},
|
|
{
|
|
title: '系统设置',
|
|
icon: Settings,
|
|
href: '/dashboard/settings',
|
|
permission: 'settings.view',
|
|
},
|
|
];
|
|
|
|
// 导出权限检查工具函数
|
|
export const hasPermission = (userPermissions: Permission[] | undefined | null, requiredPermission?: Permission): boolean => {
|
|
// 如果没有设置权限要求,则默认允许访问
|
|
if (!requiredPermission) return true;
|
|
|
|
// 如果用户权限为空,则拒绝访问
|
|
if (!userPermissions || !Array.isArray(userPermissions)) return false;
|
|
|
|
return userPermissions.includes(requiredPermission);
|
|
};
|