import { useState } from 'react' import { Plus, MessageSquare, Layers, Hash, Clock, RefreshCw, Trash2, Check, X } from 'lucide-react' import type { Topic } from '../../types/protocol' interface TopicListProps { sessionId: string | null topics: Topic[] currentTopicId: string | null isReadOnly: boolean onCreateTopic: () => void onRefresh: () => void onSwitchTopic: (topicId: string) => void onDeleteTopic: (topicId: string) => void } function formatTime(timestamp: number): string { const date = new Date(timestamp) const now = new Date() const diffDays = Math.floor((now.getTime() - date.getTime()) / (1000 * 60 * 60 * 24)) if (diffDays === 0) { return date.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' }) } else if (diffDays === 1) { return '昨天' } else if (diffDays < 7) { return `${diffDays}天前` } else { return date.toLocaleDateString('zh-CN', { month: 'short', day: 'numeric' }) } } export function TopicList({ sessionId, topics, currentTopicId, isReadOnly, onCreateTopic, onRefresh, onSwitchTopic, onDeleteTopic, }: TopicListProps) { const [confirmDeleteId, setConfirmDeleteId] = useState(null) return (
{/* Header */}

话题列表 {topics.length > 0 && ( ({topics.length}) )}

{isReadOnly ? ( ) : ( )}
{/* Topics 列表 */}
{!sessionId ? (

等待连接...

) : topics.length === 0 ? (

暂无话题

点击上方"新建"创建话题

) : (
{topics.map((topic, index) => (
{/* Delete button — visible on group hover */}
{confirmDeleteId === topic.id ? ( 确认删除? ) : ( )}
))}
)}
) }