diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsx index 4588157..52e8004 100644 --- a/frontend/src/components/Sidebar.tsx +++ b/frontend/src/components/Sidebar.tsx @@ -19,8 +19,6 @@ import { Moon, LogOut, } from 'lucide-react'; -import { useQuery } from '@tanstack/react-query'; -import { apiClient } from '@/lib/api'; import { useTheme } from '@/providers/theme'; type ModuleType = 'pipelines' | 'gitops' | 'batch-release' | 'release-records' | 'environments' | 'credentials' | 'build-nodes' | 'tools' | 'jenkins-import' | 'plugins' | 'users' | 'docs' | 'settings'; @@ -33,57 +31,45 @@ interface SidebarProps { onLogout?: () => void; } -const menuGroups: { label: string; items: { id: ModuleType; label: string; icon: typeof GitBranch; badge: string | null }[] }[] = [ +const menuGroups: { label: string; items: { id: ModuleType; label: string; icon: typeof GitBranch }[] }[] = [ { label: '发布', items: [ - { id: 'pipelines', label: '流水线', icon: GitBranch, badge: null }, - { id: 'gitops', label: 'GitOps 部署', icon: CloudSync, badge: 'New' }, - { id: 'batch-release', label: '批量发布', icon: Zap, badge: null }, - { id: 'release-records', label: '发布记录', icon: History, badge: null }, + { id: 'pipelines', label: '流水线', icon: GitBranch }, + { id: 'gitops', label: 'GitOps 部署', icon: CloudSync }, + { id: 'batch-release', label: '批量发布', icon: Zap }, + { id: 'release-records', label: '发布记录', icon: History }, ], }, { label: '资源', items: [ - { id: 'environments', label: '环境管理', icon: Server, badge: null }, - { id: 'credentials', label: '凭证管理', icon: Key, badge: null }, - { id: 'build-nodes', label: '构建节点', icon: Cpu, badge: '3' }, + { id: 'environments', label: '环境管理', icon: Server }, + { id: 'credentials', label: '凭证管理', icon: Key }, + { id: 'build-nodes', label: '构建节点', icon: Cpu }, ], }, { label: '集成', items: [ - { id: 'jenkins-import', label: 'Jenkins导入', icon: Download, badge: null }, - { id: 'tools', label: '工具配置', icon: Wrench, badge: null }, + { id: 'jenkins-import', label: 'Jenkins导入', icon: Download }, + { id: 'tools', label: '工具配置', icon: Wrench }, ], }, { label: '系统', items: [ - { id: 'docs', label: '文档', icon: BookOpen, badge: null }, - { id: 'plugins', label: '插件市场', icon: Puzzle, badge: '12' }, - { id: 'users', label: '用户管理', icon: Users, badge: null }, - { id: 'settings', label: '系统设置', icon: Settings, badge: null }, + { id: 'docs', label: '文档', icon: BookOpen }, + { id: 'plugins', label: '插件市场', icon: Puzzle }, + { id: 'users', label: '用户管理', icon: Users }, + { id: 'settings', label: '系统设置', icon: Settings }, ], }, ]; export default function Sidebar({ activeModule, onModuleChange, collapsed, onToggleCollapse, onLogout }: SidebarProps) { - // 徽标数来自后端真实统计 - const { data: summary } = useQuery({ - queryKey: ['summary'], - queryFn: apiClient.getSummary, - refetchInterval: 15000, - }); const { toggle: themeToggle, isDark } = useTheme(); - const badgeFor = (id: ModuleType): string | null => { - if (id === 'build-nodes') return summary?.buildNodes != null ? String(summary.buildNodes) : null; - if (id === 'plugins') return summary?.plugins != null ? String(summary.plugins) : null; - return null; - }; - return (
{!collapsed && ( - <> - - {item.label} - - {(() => { - const badge = item.badge === 'New' ? 'New' : badgeFor(item.id); - if (!badge) return null; - return ( - - {badge} - - ); - })()} - + + {item.label} + )} {isActive && !collapsed && (