import { useState } from 'react'; import { NavLink } from 'react-router-dom'; import { cn } from '@/lib/utils'; import { useThemeStore, useTabStore, useNotificationStore } from '@/store'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Badge } from '@/components/ui/badge'; import { Separator } from '@/components/ui/separator'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { Search, Bell, Menu, X, Plus, Settings, User, LogOut, CheckCheck, AlertTriangle, Info, CheckCircle, Terminal, Rocket, Server, Cloud, } from 'lucide-react'; import { formatDistanceToNow } from '@/lib/utils'; export function Header() { const { sidebarCollapsed, toggleSidebar } = useThemeStore(); const { tabs, activeTab, removeTab, setActiveTab } = useTabStore(); const { notifications, unreadCount, markAsRead, markAllAsRead } = useNotificationStore(); const [searchValue, setSearchValue] = useState(''); const getNotificationIcon = (type: string) => { switch (type) { case 'error': return ; case 'warning': return ; case 'success': return ; default: return ; } }; return ( {/* Left: Toggle & Search */} {sidebarCollapsed && ( )} {/* Global Search */} setSearchValue(e.target.value)} className="pl-9 h-9 bg-slate-800/50 border-slate-700 text-slate-200 placeholder:text-slate-500 focus-visible:ring-blue-500/30" /> ⌘K {/* Quick Actions */} WebShell 发布 {/* Right: Actions */} {/* Create New */} 快速创建 添加服务器 添加K8s集群 创建发布 创建工单 {/* Notifications */} {unreadCount > 0 && ( {unreadCount > 99 ? '99+' : unreadCount} )} 通知 {unreadCount > 0 && ( 全部已读 )} {notifications.length === 0 ? ( 暂无通知 ) : ( notifications.slice(0, 10).map((notification) => ( markAsRead(notification.id)} > {getNotificationIcon(notification.type)} {notification.title} {notification.message} {formatDistanceToNow(notification.timestamp)} {!notification.read && ( )} )) )} {/* User Menu */} 管 管理员 我的账号 个人中心 账号设置 退出登录 {/* Tabs */} {tabs.length > 0 && ( {tabs.map((tab) => ( setActiveTab(tab.id)} > {tab.title} {tab.closable && ( { e.stopPropagation(); removeTab(tab.id); }} > )} ))} )} ); }
暂无通知
{notification.title}
{notification.message}
{formatDistanceToNow(notification.timestamp)}