diff --git a/components/SmartChatBox/InputBar.tsx b/components/SmartChatBox/InputBar.tsx index 3e8fc12..1785d0a 100644 --- a/components/SmartChatBox/InputBar.tsx +++ b/components/SmartChatBox/InputBar.tsx @@ -23,9 +23,10 @@ interface InputBarProps { setVideoPreview?: (url: string, id: string) => void; initialVideoUrl?: string; initialVideoId?: string; + setIsFocusChatInput?: (v: boolean) => void; } -export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVideoId }: InputBarProps) { +export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVideoId, setIsFocusChatInput }: InputBarProps) { const [text, setText] = useState(""); const [isUploading, setIsUploading] = useState(false); const [uploadProgress, setUploadProgress] = useState(0); @@ -285,6 +286,8 @@ export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVide handleSend(); } }} + onFocus={() => setIsFocusChatInput?.(true)} + onBlur={() => setIsFocusChatInput?.(false)} data-alt="text-input" /> diff --git a/components/SmartChatBox/SmartChatBox.tsx b/components/SmartChatBox/SmartChatBox.tsx index fd8b51c..1253216 100644 --- a/components/SmartChatBox/SmartChatBox.tsx +++ b/components/SmartChatBox/SmartChatBox.tsx @@ -16,6 +16,7 @@ interface SmartChatBoxProps { previewVideoUrl?: string | null; previewVideoId?: string | null; onClearPreview?: () => void; + setIsFocusChatInput?: (v: boolean) => void; } interface MessageGroup { @@ -42,7 +43,8 @@ export default function SmartChatBox({ userId, previewVideoUrl, previewVideoId, - onClearPreview + onClearPreview, + setIsFocusChatInput }: SmartChatBoxProps) { // 消息列表引用 const listRef = useRef(null); @@ -197,6 +199,7 @@ export default function SmartChatBox({ }} initialVideoUrl={previewVideoUrl || undefined} initialVideoId={previewVideoId || undefined} + setIsFocusChatInput={setIsFocusChatInput} /> ); diff --git a/components/SmartChatBox/api.ts b/components/SmartChatBox/api.ts index 76e291b..c24b255 100644 --- a/components/SmartChatBox/api.ts +++ b/components/SmartChatBox/api.ts @@ -294,7 +294,7 @@ function transformSystemMessage( case 'generate_script_summary': if (isScriptSummary(customData)) { blocks = [ - { type: 'text', text: `🎬 剧本摘要生成完成\n\n${customData.summary}\n${content}` } + { type: 'text', text: `🎬 剧本摘要生成完成\n\n${customData.summary}\n\n${content}` } ]; } break; diff --git a/components/pages/work-flow.tsx b/components/pages/work-flow.tsx index 84b6421..ca04305 100644 --- a/components/pages/work-flow.tsx +++ b/components/pages/work-flow.tsx @@ -28,6 +28,7 @@ const WorkFlow = React.memo(function WorkFlow() { const [isSmartChatBoxOpen, setIsSmartChatBoxOpen] = React.useState(true); const [previewVideoUrl, setPreviewVideoUrl] = React.useState(null); const [previewVideoId, setPreviewVideoId] = React.useState(null); + const [isFocusChatInput, setIsFocusChatInput] = React.useState(false); const searchParams = useSearchParams(); const episodeId = searchParams.get('episodeId') || ''; @@ -160,7 +161,7 @@ const WorkFlow = React.memo(function WorkFlow() { {taskObject.currentStage !== 'final_video' && taskObject.currentStage !== 'script' && (
{ setPreviewVideoUrl(null); setPreviewVideoId(null); diff --git a/components/pages/work-flow/thumbnail-grid.tsx b/components/pages/work-flow/thumbnail-grid.tsx index b089323..8e2e035 100644 --- a/components/pages/work-flow/thumbnail-grid.tsx +++ b/components/pages/work-flow/thumbnail-grid.tsx @@ -117,20 +117,12 @@ export function ThumbnailGrid({ useEffect(() => { // 组件挂载时自动聚焦 if (thumbnailsRef.current && !isDisabledFocus) { - thumbnailsRef.current.focus(); window.addEventListener('keydown', handleKeyDown); } return () => window.removeEventListener('keydown', handleKeyDown); }, [handleKeyDown, isDisabledFocus]); - // 确保在数据变化时保持焦点 - useEffect(() => { - if (thumbnailsRef.current && !isFocused && !isDisabledFocus) { - thumbnailsRef.current.focus(); - } - }, [taskObject.currentStage, isFocused]); - // 处理鼠标/触摸拖动事件 const handleMouseDown = (e: React.MouseEvent) => { // 阻止默认的拖拽行为