diff --git a/frontend/src/App.css b/frontend/src/App.css index c88346b..4dd9ebe 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -265,6 +265,11 @@ body { margin-bottom: 4px; } +.video-placeholder__hint { + font-size: 0.72rem; + opacity: 0.6; +} + .video-indicator { position: absolute; bottom: 16px; diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 71517d7..58ac759 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -173,6 +173,16 @@ function App() { 点击下方按钮开始对话 )} + {isConnected && !isCameraOn && ( +
+ + + + + 摄像头未开启 + 可在右侧聊天框打字对话 +
+ )} {/* 视频下方控制栏 */} diff --git a/frontend/src/components/ChatPanel/index.tsx b/frontend/src/components/ChatPanel/index.tsx index b405ef5..f37e01c 100644 --- a/frontend/src/components/ChatPanel/index.tsx +++ b/frontend/src/components/ChatPanel/index.tsx @@ -58,15 +58,15 @@ export function ChatPanel({ messages, currentReply, connectionStatus, onSendText
💬

点击下方按钮开始对话

- 连接后可通过摄像头和麦克风与 AI 交互 + 连接后可打字或语音与 AI 交互
); } return (
- 🎙️ -

对着摄像头说话即可

- AI 会自动识别你的语音并分析画面 + 💬 +

在下方输入文字开始对话

+ 也可以开启麦克风用语音对话
); } diff --git a/frontend/src/hooks/useVisionSession.ts b/frontend/src/hooks/useVisionSession.ts index 49b5891..b3e278c 100644 --- a/frontend/src/hooks/useVisionSession.ts +++ b/frontend/src/hooks/useVisionSession.ts @@ -284,21 +284,26 @@ export function useVisionSession() { /** 启动会话 */ const startSession = useCallback(async () => { - // 1. 获取摄像头和麦克风 - await startCamera(); - setIsCameraOn(true); - const micStream = await startMic(); - if (!micStream) { - showToast("无法获取麦克风权限", "error"); - return; - } - setIsMicOn(true); - - // 2. 连接 WebSocket + // 1. 连接 WebSocket(必须) connect(); - // 3. 启动 VAD(传入麦克风 stream) - await startVAD(micStream); + // 2. 尝试获取摄像头(可选) + try { + await startCamera(); + setIsCameraOn(true); + } catch { + console.warn("[Session] 无法获取摄像头权限,将以纯文本模式运行"); + } + + // 3. 尝试获取麦克风(可选) + const micStream = await startMic(); + if (micStream) { + setIsMicOn(true); + // 4. 启动 VAD(仅在麦克风可用时) + await startVAD(micStream); + } else { + console.warn("[Session] 无法获取麦克风权限,将以文本输入模式运行"); + } }, [startCamera, startMic, connect, startVAD]); /** 结束会话 */