From 2dc7c5e616918c5293764be877161ac31e0f142c 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 00:11:24 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=B0=83=E6=95=B4chatbox=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SmartChatBox/InputBar.tsx | 109 +++++++++++++++----- components/SmartChatBox/MessageRenderer.tsx | 12 +-- components/SmartChatBox/SmartChatBox.tsx | 6 +- components/SmartChatBox/api.ts | 12 +-- components/pages/work-flow.tsx | 2 +- 5 files changed, 98 insertions(+), 43 deletions(-) diff --git a/components/SmartChatBox/InputBar.tsx b/components/SmartChatBox/InputBar.tsx index b9c9d26..5c6e8bf 100644 --- a/components/SmartChatBox/InputBar.tsx +++ b/components/SmartChatBox/InputBar.tsx @@ -1,5 +1,5 @@ import React, { useRef, useState, useEffect } from "react"; -import { Image as ImageIcon, Send, Trash2 } from "lucide-react"; +import { Image as ImageIcon, Send, Trash2, ArrowUp } from "lucide-react"; import { MessageBlock } from "./types"; import { useUploadFile } from "@/app/service/domain/service"; @@ -17,9 +17,23 @@ export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVide const [imageUrl, setImageUrl] = useState(null); const [videoUrl, setVideoUrl] = useState(initialVideoUrl || null); const [videoId, setVideoId] = useState(initialVideoId || null); - + const [isMultiline, setIsMultiline] = useState(false); + + const textareaRef = useRef(null); const { uploadFile } = useUploadFile(); + const adjustHeight = () => { + const textarea = textareaRef.current; + if (textarea) { + textarea.style.height = 'auto'; + const newHeight = Math.min(Math.max(textarea.scrollHeight, 48), 120); + textarea.style.height = `${newHeight}px`; + + // 检查是否超过一行(48px 是单行高度) + setIsMultiline(newHeight > 48); + } + }; + // 监听初始视频 URL 和 ID 的变化 useEffect(() => { if (initialVideoUrl && initialVideoId) { @@ -28,6 +42,11 @@ export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVide } }, [initialVideoUrl, initialVideoId]); + // 监听文本变化和组件挂载时调整高度 + useEffect(() => { + adjustHeight(); + }, [text]); + const handleSend = () => { const blocks: MessageBlock[] = []; if (text.trim()) blocks.push({ type: "text" as const, text: text.trim() }); @@ -153,26 +172,30 @@ export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVide )} -
- {/* 图片上传 */} - +
+ {/* 图片上传按钮 - 单行时显示在左侧,多行时显示在底部 */} + {!isMultiline && ( + + )} {/* 文本输入 */} - setText(e.target.value)} onKeyDown={(e) => { @@ -184,15 +207,45 @@ export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVide data-alt="text-input" /> - {/* 发送按钮 */} - + {isMultiline ? ( + // 多行模式:底部按钮区域 +
+ {/* 图片上传 */} + + + {/* 发送按钮 */} + +
+ ) : ( + // 单行模式:发送按钮 + + )}
); diff --git a/components/SmartChatBox/MessageRenderer.tsx b/components/SmartChatBox/MessageRenderer.tsx index f1c9a62..f158c7c 100644 --- a/components/SmartChatBox/MessageRenderer.tsx +++ b/components/SmartChatBox/MessageRenderer.tsx @@ -16,9 +16,9 @@ export function MessageRenderer({ msg }: MessageRendererProps) { const isSystem = msg.role === "system"; const bubbleClass = useMemo(() => { - if (isSystem) return "bg-amber-50 text-amber-900 border border-amber-200"; - if (isUser) return "bg-blue-500/30 text-white"; - return "bg-[#62402733] text-gray-100"; // assistant + if (isSystem) return "bg-[#281c1459] text-white"; + if (isUser) return "bg-[#27416c59] text-white"; + return "bg-[#281c1459] text-white"; // assistant }, [isSystem, isUser]); const badge = isSystem ? ( @@ -78,14 +78,14 @@ export function MessageRenderer({ msg }: MessageRendererProps) { >
{/* Header */} -
+ {/*
{badge}
{typeLabel} {hhmm(msg.createdAt)} {statusIcon}
-
+
*/} {/* Content blocks */}
@@ -93,7 +93,7 @@ export function MessageRenderer({ msg }: MessageRendererProps) { switch (b.type) { case "text": return ( -

+

{b.text}

); diff --git a/components/SmartChatBox/SmartChatBox.tsx b/components/SmartChatBox/SmartChatBox.tsx index 6beeb62..fd8b51c 100644 --- a/components/SmartChatBox/SmartChatBox.tsx +++ b/components/SmartChatBox/SmartChatBox.tsx @@ -167,8 +167,10 @@ export default function SmartChatBox({ {/* Loading indicator */} {isLoading && !hasMore && ( -
-
+
+ + +
)} diff --git a/components/SmartChatBox/api.ts b/components/SmartChatBox/api.ts index e1a612c..76e291b 100644 --- a/components/SmartChatBox/api.ts +++ b/components/SmartChatBox/api.ts @@ -286,7 +286,7 @@ function transformSystemMessage( if (isProjectInit(customData)) { blocks = [{ type: 'text', - text: `🎬 根据您输入的 "${customData.project_data.script}",我已完成项目的初始化。\n\n${content}` + text: `🎬 根据您输入的 "${customData.project_data.script}",我已完成项目的初始化。\n${content}` }]; } break; @@ -294,7 +294,7 @@ function transformSystemMessage( case 'generate_script_summary': if (isScriptSummary(customData)) { blocks = [ - { type: 'text', text: `🎬 剧本摘要生成完成\n\n${customData.summary}\n\n${content}` } + { type: 'text', text: `🎬 剧本摘要生成完成\n\n${customData.summary}\n${content}` } ]; } break; @@ -317,7 +317,7 @@ function transformSystemMessage( label: `已完成 ${customData.completed_count} 个演员,共有 ${customData.total_count} 个` }, { type: 'text', - text: `\n\n${content}` + text: `\n${content}` }]; } break; @@ -340,7 +340,7 @@ function transformSystemMessage( label: `已完成 ${customData.completed_count} 个场景,共有 ${customData.total_count} 个` }, { type: 'text', - text: `\n\n${content}` + text: `\n${content}` }]; } break; @@ -363,7 +363,7 @@ function transformSystemMessage( label: `已完成 ${customData.completed_count} 个故事板静帧,共有 ${customData.total_count} 个` }, { type: 'text', - text: `\n\n${content}` + text: `\n${content}` }]; } break; @@ -390,7 +390,7 @@ function transformSystemMessage( label: `已完成 ${customData.completed_count} 个分镜,共有 ${customData.total_count} 个分镜` }, { type: 'text', - text: `\n\n${content}` + text: `\n${content}` }) } break; diff --git a/components/pages/work-flow.tsx b/components/pages/work-flow.tsx index b066504..84b6421 100644 --- a/components/pages/work-flow.tsx +++ b/components/pages/work-flow.tsx @@ -205,7 +205,7 @@ const WorkFlow = React.memo(function WorkFlow() { {/* 智能对话弹窗 */} Date: Tue, 26 Aug 2025 00:18:15 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=A9=E7=95=A5?= =?UTF-8?q?=E5=9B=BE=E5=8C=BA=E5=9F=9F=20=E8=87=AA=E5=8A=A8=E6=BB=9A?= =?UTF-8?q?=E5=8A=A8=E5=81=8F=E5=B7=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/pages/work-flow/thumbnail-grid.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/components/pages/work-flow/thumbnail-grid.tsx b/components/pages/work-flow/thumbnail-grid.tsx index 3e2d1fd..b089323 100644 --- a/components/pages/work-flow/thumbnail-grid.tsx +++ b/components/pages/work-flow/thumbnail-grid.tsx @@ -30,13 +30,19 @@ export function ThumbnailGrid({ useEffect(() => { if (thumbnailsRef.current) { const container = thumbnailsRef.current; - const thumbnailWidth = container.offsetWidth / 4; // 每个缩略图宽度(包含间距) - const scrollPosition = currentSketchIndex * thumbnailWidth; + const thumbnails = container.children; + + if (currentSketchIndex >= 0 && currentSketchIndex < thumbnails.length) { + const thumbnail = thumbnails[currentSketchIndex] as HTMLElement; + const containerLeft = container.getBoundingClientRect().left; + const thumbnailLeft = thumbnail.getBoundingClientRect().left; + const scrollPosition = container.scrollLeft + (thumbnailLeft - containerLeft); - container.scrollTo({ - left: scrollPosition, - behavior: 'smooth' - }); + container.scrollTo({ + left: scrollPosition, + behavior: 'smooth' + }); + } } }, [currentSketchIndex]); From dbb6493712a74489145b972aa54693697e437835 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 00:52:24 +0800 Subject: [PATCH 3/3] =?UTF-8?q?chatbox=20=E5=BF=85=E9=A1=BB=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E6=96=87=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SmartChatBox/InputBar.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/SmartChatBox/InputBar.tsx b/components/SmartChatBox/InputBar.tsx index 5c6e8bf..c015596 100644 --- a/components/SmartChatBox/InputBar.tsx +++ b/components/SmartChatBox/InputBar.tsx @@ -225,12 +225,12 @@ export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVide /> - {/* 发送按钮 */} + {/* 发送按钮 必须有文字 */} @@ -241,7 +241,7 @@ export function InputBar({ onSend, setVideoPreview, initialVideoUrl, initialVide onClick={handleSend} className="inline-flex items-center gap-2 p-2 my-2 rounded-full bg-[#f1f3f4] text-[#25294b] shadow disabled:text-white/25 disabled:border disabled:border-white/10 disabled:bg-[#1b1b1b80] disabled:cursor-not-allowed" data-alt="send-button" - disabled={!text.trim() && !imageUrl && !videoUrl} + disabled={!text.trim()} >