import React, { useState } from 'react'; import { DownOutlined, UpOutlined, BulbOutlined } from '@ant-design/icons'; import '../../styles/components/chat-with-llm/thinking-block.css'; interface ThinkingBlockProps { /** 思考过程内容 */ content: string; /** 是否默认展开 */ defaultExpanded?: boolean; } /** * 思考过程展示组件 * 参考 GPT-5 和 Claude 网页版的思考过程UI设计 * 可折叠的思考过程区域,契合当前淡绿色配色方案 */ export default function ThinkingBlock({ content, defaultExpanded = false }: ThinkingBlockProps) { const [expanded, setExpanded] = useState(defaultExpanded); if (!content) return null; return (
{/* 折叠/展开按钮 */}
setExpanded(!expanded)} role="button" tabIndex={0} onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { setExpanded(!expanded); } }} >
思考过程
{expanded ? ( ) : ( )}
{/* 思考内容 */} {expanded && (
{content.split('\n').map((line, index) => (

{line || '\u00A0'}

))}
)}
); }