From 65f17b4a661a6d905a4735998fc389e38eeb20dd Mon Sep 17 00:00:00 2001 From: Song367 <601337784@qq.com> Date: Tue, 29 Jul 2025 18:14:04 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=A2=9E=E5=8A=A0=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E8=BF=87=E6=B8=A1=E6=95=88=E6=9E=9C=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E9=BB=91=E5=B1=8F=E3=80=82UI=E5=A4=A7=E6=95=B4?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.js | 6 +- src/chat_with_audio.js | 14 +- src/index.html | 257 ++++++++++++++++++++++++---- src/index.js | 379 ++++++++++++++++++++++++++++++----------- src/llm_stream.js | 2 +- src/minimaxi_stream.js | 2 +- videos/bd-1.mp4 | Bin 0 -> 734516 bytes videos/d-0.mp4 | Bin 0 -> 3409370 bytes 8 files changed, 516 insertions(+), 144 deletions(-) create mode 100644 videos/bd-1.mp4 create mode 100644 videos/d-0.mp4 diff --git a/server.js b/server.js index 506d47d..6b126b1 100644 --- a/server.js +++ b/server.js @@ -88,15 +88,15 @@ const connectedClients = new Map(); // 视频映射配置 const videoMapping = { // 'say-6s-m-e': '1-m.mp4', - 'default': '0-2.mp4', + 'default': 'bd-1.mp4', // 'say-5s-amplitude': '2.mp4', // 'say-5s-m-e': '4.mp4', - 'say-5s-m-sw': '5.mp4', + 'say-5s-m-sw': 'd-0.mp4', // 'say-3s-m-sw': '6.mp4', }; // 默认视频流配置 -const DEFAULT_VIDEO = '0-2.mp4'; +const DEFAULT_VIDEO = 'bd-1.mp4'; const INTERACTION_TIMEOUT = 10000; // 10秒后回到默认视频 // 获取视频列表 diff --git a/src/chat_with_audio.js b/src/chat_with_audio.js index c4dfa70..990de50 100644 --- a/src/chat_with_audio.js +++ b/src/chat_with_audio.js @@ -69,22 +69,30 @@ function updateHistoryMessage(userInput, assistantResponse) { } } +// 保存消息到服务端 // 保存消息到服务端 async function saveMessage(userInput, assistantResponse) { try { + // 验证参数是否有效 + if (!userInput || !userInput.trim() || !assistantResponse || !assistantResponse.trim()) { + console.warn('跳过保存消息:用户输入或助手回复为空'); + return; + } + const response = await fetch('/api/messages/save', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ - userInput, - assistantResponse + userInput: userInput.trim(), + assistantResponse: assistantResponse.trim() }) }); if (!response.ok) { - throw new Error('保存消息失败'); + const errorData = await response.json().catch(() => ({})); + throw new Error(`保存消息失败: ${response.status} ${errorData.error || response.statusText}`); } console.log('消息已保存到服务端'); diff --git a/src/index.html b/src/index.html index bc582a3..66d5b59 100644 --- a/src/index.html +++ b/src/index.html @@ -2,69 +2,260 @@
- +