import Icon from "./Icon"; type ActivePage = "home" | "scripts" | "schedules" | "system"; type SidebarProps = { activePage: ActivePage; collapsed: boolean; onNavigate: (page: ActivePage) => void; onToggleCollapse: () => void; onEndEditing?: () => void; onSelectScript?: (scriptId: null) => void; editSessionRef?: React.RefObject; isSystemAdmin?: boolean; }; type NavigationItem = { label: string; icon: "home" | "script" | "schedule" | "settings"; page: ActivePage; }; export function Sidebar({ activePage, collapsed, onNavigate, onToggleCollapse, onEndEditing, onSelectScript, editSessionRef, isSystemAdmin = false, }: SidebarProps) { const handleNavigationClick = (page: ActivePage) => { if (page !== "scripts") { if (editSessionRef?.current) { onEndEditing?.(); } else { onSelectScript?.(null); } } onNavigate(page); }; const navigation: NavigationItem[] = [ { label: "工作台", icon: "home", page: "home" }, { label: "构建脚本", icon: "script", page: "scripts" }, { label: "调度配置", icon: "schedule", page: "schedules" }, ]; if (isSystemAdmin) { navigation.push({ label: "系统管理", icon: "settings", page: "system" }); } return ( ); }