import React from 'react'; import { useTheme } from '../../contexts'; import type { ComplianceChunk } from '../../types'; interface ChatPanelProps { activeChunkId: number; chunks: ComplianceChunk[]; messages: Array<{ id: number; role: 'user' | 'assistant'; content: string }>; chatInput: string; setChatInput: (value: string) => void; chatLoading: boolean; sendChatMessage: () => void; closeChat: () => void; quickQuestions?: string[]; } export const ChatPanel: React.FC = ({ activeChunkId, chunks, messages, chatInput, setChatInput, chatLoading, sendChatMessage, closeChat, quickQuestions = [ '这个设计是否合规?', '需要修改哪些内容?', '法规的具体要求是什么?', ], }) => { const { theme } = useTheme(); const activeChunk = chunks.find(c => c.id === activeChunkId); return (
{/* Chat Header */}
合规对话
段落 #{activeChunk?.index} · {activeChunk?.regulations.length} 条法规
{/* Current Chunk Info */}
{activeChunk?.intent}
{activeChunk?.content.substring(0, 100)}...
{/* Chat Messages */}
{messages.map(msg => (
{msg.role === 'assistant' && (
)}
{msg.content}
))} {chatLoading && (
分析中...
)}
{/* Quick Questions */}
{quickQuestions.map(q => ( ))}
{/* Chat Input */}
setChatInput(e.target.value)} onKeyDown={e => e.key === 'Enter' && sendChatMessage()} placeholder="输入问题..." style={{ flex: 1, padding: 12, fontSize: 14, background: theme.bgHover, border: `1px solid ${theme.border}`, borderRadius: 8, color: theme.text, outline: 'none', }} />
); };