import { useState } from 'react' import { Briefcase, Bug, Wifi, BarChart3, Cog, LogOut, Radar, Settings, Terminal } from 'lucide-react' import { useTranslation } from 'react-i18next' import { Badge } from '@/components/ui/badge' import { SystemSettingsDialog } from '@/components/settings/SystemSettingsDialog' import { useCrawlerStore } from '@/store/crawlerStore' import { useCrawlerStatus } from '@/hooks/useCrawler' import type { AppView } from '@/App' import { LanguageSwitch } from './LanguageSwitch' import { PlatformSwitcher } from './PlatformSwitcher' import { ThemeToggle } from './ThemeToggle' interface SidebarProps { currentView: AppView onViewChange: (view: AppView) => void onLogout: () => void } const NAV_ITEMS: Array<{ value: AppView; label: string; icon: typeof Terminal }> = [ { value: 'crawler', label: '采集', icon: Terminal }, { value: 'monitor', label: '监控', icon: Radar }, { value: 'operation', label: '运营', icon: Briefcase }, { value: 'report', label: '报表', icon: BarChart3 }, { value: 'settings', label: '设置', icon: Settings }, ] export function Sidebar({ currentView, onViewChange, onLogout }: SidebarProps) { const { t } = useTranslation() const status = useCrawlerStore((state) => state.status) const [systemSettingsOpen, setSystemSettingsOpen] = useState(false) // Poll status useCrawlerStatus() const isRunning = status === 'running' return (
{/* Left: Logo, run state, workspace switch */}
综合采集平台 {isRunning && ( {t('status.active')} )} {isRunning && ( )} {/* Workspace switch */}
{NAV_ITEMS.map((item) => { const Icon = item.icon const active = currentView === item.value return ( ) })}
{/* Right: platform scope, then actions and status */}
{/* Scopes every workspace at once. */} {/* System-wide settings: deliberately separate from the platform-scoped 「设置」 page, because these values are not per platform. */} {/* Theme Toggle */} {/* Language Switch */} {/* Status Info */}
{t('sidebar.api')}: v1.0.0
{t('sidebar.local')}
{/* Logging out unmounts the whole tree, which closes the log WebSocket through the existing connection-count cleanup. */}
) }