// Account selector strip. Collapsing to a 56px avatar-only column keeps // the right-side editor breathing on smaller screens; expanded it shows // nickname + UIN like the original. Selection routes through // `requestSwitchUin` so the dirty-modify guard still gates the switch. import { motion } from 'motion/react'; import { ChevronLeft, ChevronRight } from 'lucide-react'; import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar'; import { Button } from '@/components/ui/button'; import { ScrollArea } from '@/components/ui/scroll-area'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'; import { cn } from '@/lib/utils'; import type { QQInfo } from '@/types'; function qqAvatarUrl(uin: string) { return `/avatar/${encodeURIComponent(uin)}`; } interface AccountSidebarProps { accounts: QQInfo[]; selectedUin: string | null; onSelect: (uin: string) => void; collapsed: boolean; onToggleCollapsed: () => void; } export function AccountSidebar({ accounts, selectedUin, onSelect, collapsed, onToggleCollapsed, }: AccountSidebarProps) { return (
{!collapsed && 在线连接}
{accounts.length === 0 ? (

{collapsed ? '—' : '暂无在线会话'}

) : (
{accounts.map((q) => { const isActive = selectedUin === q.uin; const button = ( onSelect(q.uin)} className={cn( 'flex items-center gap-2.5 rounded-lg border text-left transition-colors cursor-pointer', collapsed ? 'justify-center p-1.5' : 'px-2.5 py-2', isActive ? 'border-primary/30 bg-primary/10' : 'border-transparent hover:bg-accent/40', )} > {(q.nickname || q.uin).slice(0, 2)} {!collapsed && (
{q.nickname || q.uin}
{q.uin}
)}
); return collapsed ? ( {button}
{q.nickname || q.uin} {q.uin}
) : ( button ); })}
)}
); }