import { useEffect } from 'react'; import { useAppStore } from '@/store'; import { useChat } from '@/hooks/useChat'; import { ChatMessage } from './ChatMessage'; import { ChatInput } from './ChatInput'; import { ScrollArea } from '@/components/ui/scroll-area'; export function ChatView() { const { activeConversationId, conversations, setConversations } = useAppStore(); const { messages, connected, send, createConversation } = useChat(activeConversationId); useEffect(() => { fetch('/api/pipeline/conversations') .then((r) => r.json()) .then(setConversations) .catch(() => {}); }, [messages]); const handleNewConversation = () => { createConversation('新对话'); setTimeout(() => { fetch('/api/pipeline/conversations') .then((r) => r.json()) .then(setConversations); }, 300); }; if (!activeConversationId) { return (

选择对话或开始新对话

); } return (
{connected ? '已连接' : '连接中...'}
{messages.map((msg) => ( ))}
); }