|
@ -285,7 +285,7 @@ watch(currentStock, (newStock) => { |
|
|
isLoading.value = false; // 数据加载完成,关闭加载状态 |
|
|
isLoading.value = false; // 数据加载完成,关闭加载状态 |
|
|
// 停止当前播放的音频 |
|
|
// 停止当前播放的音频 |
|
|
stopAudio(); |
|
|
stopAudio(); |
|
|
// 重置触发状态,允许新股票重新触发效果 |
|
|
|
|
|
|
|
|
// 重置触发状态,让每个股票都能独立触发效果 |
|
|
hasTriggeredAudio.value = false; |
|
|
hasTriggeredAudio.value = false; |
|
|
hasTriggeredTypewriter.value = false; |
|
|
hasTriggeredTypewriter.value = false; |
|
|
|
|
|
|
|
@ -355,39 +355,45 @@ watch(currentStock, (newStock) => { |
|
|
// 检查场景应用部分是否已经在视口中,如果是则立即触发效果 |
|
|
// 检查场景应用部分是否已经在视口中,如果是则立即触发效果 |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
if (scenarioApplicationRef.value && parsedConclusion.value) { |
|
|
if (scenarioApplicationRef.value && parsedConclusion.value) { |
|
|
|
|
|
const stockCode = newStock.stockInfo?.code || newStock.stockInfo?.symbol; |
|
|
|
|
|
|
|
|
|
|
|
// 如果该股票已经显示过,不需要再处理 |
|
|
|
|
|
if (stockCode && stockTypewriterShown.value.has(stockCode)) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const rect = scenarioApplicationRef.value.getBoundingClientRect(); |
|
|
const rect = scenarioApplicationRef.value.getBoundingClientRect(); |
|
|
const isInViewport = rect.top < window.innerHeight && rect.bottom > 0; |
|
|
const isInViewport = rect.top < window.innerHeight && rect.bottom > 0; |
|
|
|
|
|
|
|
|
if (isInViewport && !hasTriggeredTypewriter.value) { |
|
|
|
|
|
console.log('股票切换后检测到场景应用部分在视口中,立即触发效果'); |
|
|
|
|
|
const stockCode = newStock.stockInfo?.code || newStock.stockInfo?.symbol; |
|
|
|
|
|
|
|
|
if (isInViewport) { |
|
|
|
|
|
console.log('股票切换后检测到场景应用部分在视口中'); |
|
|
|
|
|
|
|
|
if (stockCode) { |
|
|
if (stockCode) { |
|
|
|
|
|
// 检查该股票是否是第一次触发 |
|
|
if (!stockTypewriterShown.value.has(stockCode)) { |
|
|
if (!stockTypewriterShown.value.has(stockCode)) { |
|
|
// 检查音频是否准备好,如果没有准备好则不触发效果 |
|
|
|
|
|
if (!audioUrl.value) { |
|
|
|
|
|
|
|
|
// 该股票第一次:播放音频和打字机效果 |
|
|
|
|
|
if (audioUrl.value) { |
|
|
|
|
|
console.log('该股票第一次进入场景应用,开始打字机效果和音频播放'); |
|
|
|
|
|
hasTriggeredTypewriter.value = true; |
|
|
|
|
|
hasTriggeredAudio.value = true; |
|
|
|
|
|
|
|
|
|
|
|
startTypewriterEffect(parsedConclusion.value); |
|
|
|
|
|
|
|
|
|
|
|
if (!stockAudioPlayed.value.has(stockCode)) { |
|
|
|
|
|
console.log('开始音频播放'); |
|
|
|
|
|
stockAudioPlayed.value.set(stockCode, true); |
|
|
|
|
|
playAudio(audioUrl.value); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
stockTypewriterShown.value.set(stockCode, true); |
|
|
|
|
|
} else { |
|
|
console.log('音频尚未准备好,等待音频加载完成后再触发效果(股票切换后)'); |
|
|
console.log('音频尚未准备好,等待音频加载完成后再触发效果(股票切换后)'); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
console.log('开始场景应用打字机效果和音频播放(股票切换后首次)'); |
|
|
|
|
|
hasTriggeredTypewriter.value = true; |
|
|
|
|
|
hasTriggeredAudio.value = true; |
|
|
|
|
|
|
|
|
|
|
|
startTypewriterEffect(parsedConclusion.value); |
|
|
|
|
|
|
|
|
|
|
|
if (!stockAudioPlayed.value.has(stockCode)) { |
|
|
|
|
|
console.log('同时开始音频播放(股票切换后)'); |
|
|
|
|
|
stockAudioPlayed.value.set(stockCode, true); |
|
|
|
|
|
playAudio(audioUrl.value); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
stockTypewriterShown.value.set(stockCode, true); |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
console.log('该股票已显示过,直接显示完整内容(股票切换后)'); |
|
|
|
|
|
hasTriggeredTypewriter.value = true; |
|
|
|
|
|
hasTriggeredAudio.value = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 非第一次或已经触发过:直接显示完整内容,不播放音频和打字机效果 |
|
|
|
|
|
console.log('非第一次股票切换或已触发过,直接显示完整内容'); |
|
|
|
|
|
|
|
|
// 直接显示完整内容 |
|
|
// 直接显示完整内容 |
|
|
const conclusion = parsedConclusion.value; |
|
|
const conclusion = parsedConclusion.value; |
|
|
displayedTexts.value = { |
|
|
displayedTexts.value = { |
|
@ -456,22 +462,25 @@ watch(parsedConclusion, (newConclusion) => { |
|
|
const rect = scenarioApplicationRef.value.getBoundingClientRect(); |
|
|
const rect = scenarioApplicationRef.value.getBoundingClientRect(); |
|
|
const isInViewport = rect.top < window.innerHeight && rect.bottom > 0; |
|
|
const isInViewport = rect.top < window.innerHeight && rect.bottom > 0; |
|
|
|
|
|
|
|
|
if (isInViewport && !hasTriggeredTypewriter.value && parsedConclusion.value && stockCode) { |
|
|
|
|
|
if (!stockTypewriterShown.value.has(stockCode)) { |
|
|
|
|
|
console.log('音频准备完成且场景应用部分在视口中,立即触发效果'); |
|
|
|
|
|
hasTriggeredTypewriter.value = true; |
|
|
|
|
|
hasTriggeredAudio.value = true; |
|
|
|
|
|
|
|
|
|
|
|
startTypewriterEffect(parsedConclusion.value); |
|
|
|
|
|
|
|
|
if (isInViewport && parsedConclusion.value && stockCode) { |
|
|
|
|
|
// 如果该股票已经显示过,不需要再处理 |
|
|
|
|
|
if (stockTypewriterShown.value.has(stockCode)) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 该股票第一次:播放音频和打字机效果 |
|
|
|
|
|
console.log('该股票第一次音频准备完成且场景应用部分在视口中,立即触发效果'); |
|
|
|
|
|
hasTriggeredTypewriter.value = true; |
|
|
|
|
|
hasTriggeredAudio.value = true; |
|
|
|
|
|
|
|
|
if (!stockAudioPlayed.value.has(stockCode)) { |
|
|
|
|
|
console.log('立即开始音频播放'); |
|
|
|
|
|
stockAudioPlayed.value.set(stockCode, true); |
|
|
|
|
|
playAudio(audioUrl.value); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
startTypewriterEffect(parsedConclusion.value); |
|
|
|
|
|
|
|
|
stockTypewriterShown.value.set(stockCode, true); |
|
|
|
|
|
|
|
|
if (!stockAudioPlayed.value.has(stockCode)) { |
|
|
|
|
|
console.log('立即开始音频播放'); |
|
|
|
|
|
stockAudioPlayed.value.set(stockCode, true); |
|
|
|
|
|
playAudio(audioUrl.value); |
|
|
} |
|
|
} |
|
|
|
|
|
stockTypewriterShown.value.set(stockCode, true); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, 100); // 短暂延迟确保DOM更新完成 |
|
|
}, 100); // 短暂延迟确保DOM更新完成 |
|
@ -763,9 +772,9 @@ async function handleSendMessage(input) { |
|
|
}; |
|
|
}; |
|
|
console.log('======================================') |
|
|
console.log('======================================') |
|
|
|
|
|
|
|
|
// 在调用第二个工作流接口前立即开始缓慢滚动 |
|
|
|
|
|
console.log('第二个工作流接口开始调用,立即开始缓慢滚动'); |
|
|
|
|
|
startAutoScroll(); |
|
|
|
|
|
|
|
|
// 取消自动滚动效果 |
|
|
|
|
|
// console.log('第二个工作流接口开始调用,立即开始缓慢滚动'); |
|
|
|
|
|
// startAutoScroll(); |
|
|
|
|
|
|
|
|
// 同时调用第二个数据流接口和fetchData方法 |
|
|
// 同时调用第二个数据流接口和fetchData方法 |
|
|
const [conclusionResult, fetchDataResult] = await Promise.all([ |
|
|
const [conclusionResult, fetchDataResult] = await Promise.all([ |
|
@ -1006,44 +1015,42 @@ function setupIntersectionObserver() { |
|
|
const observer = new IntersectionObserver( |
|
|
const observer = new IntersectionObserver( |
|
|
(entries) => { |
|
|
(entries) => { |
|
|
entries.forEach((entry) => { |
|
|
entries.forEach((entry) => { |
|
|
if (entry.isIntersecting && (!hasTriggeredAudio.value || !hasTriggeredTypewriter.value)) { |
|
|
|
|
|
console.log('场景应用部分进入视口,开始打字机效果和音频播放'); |
|
|
|
|
|
|
|
|
if (entry.isIntersecting) { |
|
|
|
|
|
console.log('场景应用部分进入视口'); |
|
|
|
|
|
|
|
|
// 获取当前股票代码 |
|
|
// 获取当前股票代码 |
|
|
const stockCode = currentStock.value?.stockInfo?.code || currentStock.value?.stockInfo?.symbol; |
|
|
const stockCode = currentStock.value?.stockInfo?.code || currentStock.value?.stockInfo?.symbol; |
|
|
|
|
|
|
|
|
// 同时触发打字机效果和音频播放 |
|
|
|
|
|
if (!hasTriggeredTypewriter.value && parsedConclusion.value && stockCode) { |
|
|
|
|
|
// 检查该股票是否已经显示过打字机效果 |
|
|
|
|
|
|
|
|
if (parsedConclusion.value && stockCode) { |
|
|
|
|
|
// 检查该股票是否是第一次触发 |
|
|
if (!stockTypewriterShown.value.has(stockCode)) { |
|
|
if (!stockTypewriterShown.value.has(stockCode)) { |
|
|
// 检查音频是否准备好,如果没有准备好则不触发效果 |
|
|
|
|
|
if (!audioUrl.value) { |
|
|
|
|
|
console.log('音频尚未准备好,等待音频加载完成后再触发效果'); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 该股票第一次:播放音频和打字机效果 |
|
|
|
|
|
if (audioUrl.value) { |
|
|
|
|
|
console.log('该股票第一次进入场景应用,开始打字机效果和音频播放'); |
|
|
|
|
|
hasTriggeredTypewriter.value = true; |
|
|
|
|
|
hasTriggeredAudio.value = true; |
|
|
|
|
|
|
|
|
console.log('开始场景应用打字机效果和音频播放(首次加载)'); |
|
|
|
|
|
hasTriggeredTypewriter.value = true; |
|
|
|
|
|
hasTriggeredAudio.value = true; |
|
|
|
|
|
|
|
|
// 开始打字机效果 |
|
|
|
|
|
startTypewriterEffect(parsedConclusion.value); |
|
|
|
|
|
|
|
|
// 同时开始打字机效果和音频播放 |
|
|
|
|
|
startTypewriterEffect(parsedConclusion.value); |
|
|
|
|
|
|
|
|
// 播放音频 |
|
|
|
|
|
if (!stockAudioPlayed.value.has(stockCode)) { |
|
|
|
|
|
console.log('开始音频播放'); |
|
|
|
|
|
stockAudioPlayed.value.set(stockCode, true); |
|
|
|
|
|
playAudio(audioUrl.value); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 立即开始播放音频 |
|
|
|
|
|
if (!stockAudioPlayed.value.has(stockCode)) { |
|
|
|
|
|
console.log('同时开始音频播放'); |
|
|
|
|
|
stockAudioPlayed.value.set(stockCode, true); |
|
|
|
|
|
playAudio(audioUrl.value); |
|
|
|
|
|
|
|
|
// 记录该股票已显示过 |
|
|
|
|
|
stockTypewriterShown.value.set(stockCode, true); |
|
|
|
|
|
} else { |
|
|
|
|
|
console.log('音频尚未准备好,等待音频加载完成后再触发效果'); |
|
|
|
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 记录该股票已显示过打字机效果 |
|
|
|
|
|
stockTypewriterShown.value.set(stockCode, true); |
|
|
|
|
|
} else { |
|
|
} else { |
|
|
console.log('该股票已显示过打字机效果,直接显示完整内容'); |
|
|
|
|
|
hasTriggeredTypewriter.value = true; |
|
|
|
|
|
hasTriggeredAudio.value = true; |
|
|
|
|
|
|
|
|
|
|
|
// 直接显示完整内容,不使用打字机效果 |
|
|
|
|
|
|
|
|
// 非第一次或已经触发过:直接显示完整内容,不播放音频和打字机效果 |
|
|
|
|
|
console.log('非第一次进入场景应用或已触发过,直接显示完整内容'); |
|
|
|
|
|
|
|
|
|
|
|
// 直接显示完整内容 |
|
|
const conclusion = parsedConclusion.value; |
|
|
const conclusion = parsedConclusion.value; |
|
|
displayedTexts.value = { |
|
|
displayedTexts.value = { |
|
|
one1: conclusion.one1 || '', |
|
|
one1: conclusion.one1 || '', |
|
|