diff --git a/www/app.js b/www/app.js index a3959a5..c304c7f 100644 --- a/www/app.js +++ b/www/app.js @@ -53,9 +53,11 @@ let backendConfig = null; // 从API获取的配置 let currentUser = null; // 当前登录用户 { username, password, registeredAt } // TTS 语音播放状态 -let enableTTS = false; // 是否启用语音播放 +let enableTTS = false; // 是否启用语音播放(默认关闭) let currentPlayingAudio = null; // 当前播放的音频对象 let ttsVoice = 'zh-CN-XiaoxiaoNeural'; // TTS 语音 +let ttsQueue = []; // TTS 待播放队列 +let isTTSPlaying = false; // 是否正在播放队列 // 每日使用统计(未登录用户) let dailyUsage = { @@ -3137,6 +3139,10 @@ async function openAgent(agentId) { } } + // 重置 TTS 状态(新对话默认关闭) + enableTTS = false; + stopTTSQueue(); + // 创建新对话并设置智能体 const newConv = { id: backendId || Date.now().toString(), @@ -3159,6 +3165,9 @@ async function openAgent(agentId) { function showAgentChatPage() { if (!currentAgent || !currentConversation) return; + // 停止之前的 TTS 播放 + stopTTSQueue(); + const chatHtml = `