From 4e87b4a15f935eca15889583d990d29714acf8d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Tue, 26 Aug 2025 17:15:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=BB=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=BD=93=E5=89=8D=E9=80=89=E4=B8=AD=E5=88=87=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SmartChatBox/InputBar.tsx | 5 ++++- components/SmartChatBox/SmartChatBox.tsx | 5 ++++- components/SmartChatBox/api.ts | 2 +- components/pages/work-flow.tsx | 5 ++++- components/pages/work-flow/thumbnail-grid.tsx | 8 -------- 5 files changed, 13 insertions(+), 12 deletions(-) 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) => { // 阻止默认的拖拽行为