From 15b1dd56fa2873812006d44c53e7daa424e9e109 Mon Sep 17 00:00:00 2001 From: cfy666 <3087823110@qq.com> Date: Sun, 14 Jun 2026 15:07:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=81=8A=E5=A4=A9=E6=A1=86=E4=B8=8E?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=8A=9F=E8=83=BD=E8=A7=A3=E8=80=A6=EF=BC=8C?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E6=96=87=E5=AD=97=E5=8D=B3=E5=8F=AF=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E5=AF=B9=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 之前必须点击「开始对话」连接 WebSocket 后才能使用聊天框。 现在聊天输入框始终可用,输入文字自动连接 WebSocket 并发送消息; 左侧按钮改为「开始视频通话」,单独控制摄像头/麦克风。 - ChatPanel 移除 !isConnected early return,始终显示输入框 - useVisionSession 新增待发消息队列,sendTextMessage 支持自动连接 - startSession 改为仅负责视频(摄像头 + 麦克风 + VAD) - 修复 statusRef 在 useWebSocketManager 之前声明导致的 TDZ 错误 - 更新 i18n 翻译(新增 controls.startVideo、video.placeholder) --- frontend/src/App.tsx | 4 +- frontend/src/components/ChatPanel/index.tsx | 20 ++----- frontend/src/hooks/useVisionSession.ts | 62 ++++++++++++++++++--- frontend/src/lib/i18n/en-US.ts | 6 +- frontend/src/lib/i18n/ja-JP.ts | 6 +- frontend/src/lib/i18n/zh-CN.ts | 6 +- 6 files changed, 73 insertions(+), 31 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 241bfd0..3cbf62e 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -175,7 +175,7 @@ function AppContent() { - {tr("video.clickToStart")} + {tr("video.placeholder")} )} {isConnected && !isCameraOn && ( @@ -194,7 +194,7 @@ function AppContent() {
{!isConnected ? ( ) : (
diff --git a/frontend/src/components/ChatPanel/index.tsx b/frontend/src/components/ChatPanel/index.tsx index e19ada5..4ff7902 100644 --- a/frontend/src/components/ChatPanel/index.tsx +++ b/frontend/src/components/ChatPanel/index.tsx @@ -53,17 +53,6 @@ export function ChatPanel({ messages, currentReply, connectionStatus, onSendText setInputText(""); }; - // 未连接时的空状态 - if (!isConnected) { - return ( -
- 💬 -

{t("chat.empty.prompt")}

- {t("chat.empty.hint")} -
- ); - } - return (
@@ -71,8 +60,8 @@ export function ChatPanel({ messages, currentReply, connectionStatus, onSendText {messages.length === 0 && !currentReply && (
💬 -

{t("chat.welcome.prompt")}

- {t("chat.welcome.hint")} +

{isConnected ? t("chat.welcome.prompt") : t("chat.empty.prompt")}

+ {isConnected ? t("chat.welcome.hint") : t("chat.empty.hint")}
)} @@ -106,7 +95,7 @@ export function ChatPanel({ messages, currentReply, connectionStatus, onSendText
- {/* 文本输入框 - 连接后始终显示 */} + {/* 文本输入框 - 始终显示 */} {onSendText && (
setInputText(e.target.value)} + disabled={connectionStatus === "connecting"} />