Browse Source

优化:已查看的页面之间切换直接显示所有文本,不播放音频。

ds_hxl
宋杰 2 weeks ago
parent
commit
50772b908c
  1. 137
      src/views/AiEmotion.vue

137
src/views/AiEmotion.vue

@ -285,7 +285,7 @@ watch(currentStock, (newStock) => {
isLoading.value = false; //
//
stopAudio();
//
//
hasTriggeredAudio.value = false;
hasTriggeredTypewriter.value = false;
@ -355,38 +355,44 @@ watch(currentStock, (newStock) => {
//
setTimeout(() => {
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 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 (!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('音频尚未准备好,等待音频加载完成后再触发效果(股票切换后)');
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 {
console.log('该股票已显示过,直接显示完整内容(股票切换后)');
hasTriggeredTypewriter.value = true;
hasTriggeredAudio.value = true;
//
console.log('非第一次股票切换或已触发过,直接显示完整内容');
//
const conclusion = parsedConclusion.value;
@ -456,22 +462,25 @@ watch(parsedConclusion, (newConclusion) => {
const rect = scenarioApplicationRef.value.getBoundingClientRect();
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;
if (isInViewport && parsedConclusion.value && stockCode) {
//
if (stockTypewriterShown.value.has(stockCode)) {
return;
}
startTypewriterEffect(parsedConclusion.value);
//
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
@ -763,9 +772,9 @@ async function handleSendMessage(input) {
};
console.log('======================================')
//
console.log('第二个工作流接口开始调用,立即开始缓慢滚动');
startAutoScroll();
//
// console.log('');
// startAutoScroll();
// fetchData
const [conclusionResult, fetchDataResult] = await Promise.all([
@ -1006,44 +1015,42 @@ function setupIntersectionObserver() {
const observer = new IntersectionObserver(
(entries) => {
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;
//
if (!hasTriggeredTypewriter.value && parsedConclusion.value && stockCode) {
//
if (parsedConclusion.value && 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 {
console.log('该股票已显示过打字机效果,直接显示完整内容');
hasTriggeredTypewriter.value = true;
hasTriggeredAudio.value = true;
//
console.log('非第一次进入场景应用或已触发过,直接显示完整内容');
// 使
//
const conclusion = parsedConclusion.value;
displayedTexts.value = {
one1: conclusion.one1 || '',

Loading…
Cancel
Save