From 989ec1d76467c6ce33d33a874819b8646e9883b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=8B=E6=9D=B0?= Date: Thu, 26 Jun 2025 16:35:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=83=85=E7=BB=AA=E5=A4=A7=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=82=A1=E7=A5=A8=E5=8F=AF=E4=BB=A5=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E5=AF=B9=E5=BA=94=E8=82=A1=E7=A5=A8=E7=9A=84=E9=9F=B3?= =?UTF-8?q?=E9=A2=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/AiEmotion.vue | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/views/AiEmotion.vue b/src/views/AiEmotion.vue index 6d9d9e7..b79b692 100644 --- a/src/views/AiEmotion.vue +++ b/src/views/AiEmotion.vue @@ -323,6 +323,10 @@ watch(currentStock, (newStock) => { // 页面加载状态现在由 handleSendMessage 统一控制 // 停止当前播放的音频 stopAudio(); + // 清理音频URL,确保不会播放之前股票的音频 + audioUrl.value = ''; + // 只停止音频播放,不清理currentAudioUrl,让新音频能正确设置 + emotionAudioStore.stop(); // 清理正在进行的打字机效果定时器 clearTypewriterTimers(); // 重置触发状态,让每个股票都能独立触发效果 @@ -360,6 +364,28 @@ watch(currentStock, (newStock) => { four: !!conclusion.four, disclaimer: true }; + + // 重要:即使已经显示过,也要播放当前股票的音频 + // 提取音频URL并播放 + let voiceUrl = null; + if (conclusion.url) { + voiceUrl = conclusion.url.toString().trim().replace(/[`\s]/g, ''); + } else if (conclusion.audioUrl) { + voiceUrl = conclusion.audioUrl.toString().trim().replace(/[`\s]/g, ''); + } else if (conclusion.voice_url) { + voiceUrl = conclusion.voice_url.toString().trim().replace(/[`\s]/g, ''); + } else if (conclusion.audio) { + voiceUrl = conclusion.audio.toString().trim().replace(/[`\s]/g, ''); + } else if (conclusion.tts_url) { + voiceUrl = conclusion.tts_url.toString().trim().replace(/[`\s]/g, ''); + } + + if (voiceUrl && voiceUrl.startsWith('http')) { + console.log('切换到已显示股票,播放对应音频:', voiceUrl); + audioUrl.value = voiceUrl; + // 立即播放当前股票的音频 + playAudio(voiceUrl); + } } catch (error) { console.error('解析结论数据失败:', error); }