import { useEffect, useRef, useState } from 'react'; import { FileText, ChevronDown, ChevronRight, Brain } from 'lucide-react'; interface OutlineStreamingViewProps { text: string; thinkingText?: string; /** 用户自带大纲时为 true:文案显示「整理你的大纲」而非「规划大纲」。 */ organizing?: boolean; } export function OutlineStreamingView({ text, thinkingText, organizing }: OutlineStreamingViewProps) { const preRef = useRef(null); const thinkRef = useRef(null); const [thinkOpen, setThinkOpen] = useState(true); useEffect(() => { if (preRef.current) { preRef.current.scrollTop = preRef.current.scrollHeight; } }, [text]); useEffect(() => { if (thinkOpen && thinkRef.current) { thinkRef.current.scrollTop = thinkRef.current.scrollHeight; } }, [thinkingText, thinkOpen]); if (!text && !thinkingText) return null; return (
{/* 思考过程区(仅在有思考内容时展示) */} {thinkingText && (
{thinkOpen && (
              {thinkingText}
              {/* 思考仍在进行时显示光标 */}
              {!text && (
                
              )}
            
)}
)} {/* 正文流式区 */} {text && (
{organizing ? '作家正在整理你的大纲…' : '作家正在规划大纲…'} {[0, 1, 2].map((i) => ( ))}
            {text}
            
          
)}
); }