Browse Source

夺宝奇兵音频重新播放只播放第四个问题解决;打字机速度与音频对应;修改情绪大模型日期格式。

songjie/feature-20250628160649-上线前优化
宋杰 12 hours ago
parent
commit
5396ffc7b0
  1. 120
      src/views/AIchat.vue
  2. 15
      src/views/AiEmotion.vue

120
src/views/AIchat.vue

@ -717,18 +717,37 @@ watch(
//
//
let isCallingPlayNext = false;
//
let currentPlayIndex = 0;
const playNextAudio = () => {
console.log('=== playNextAudio 被调用 ===');
console.log('当前队列状态:', {
queueLength: audioQueue.value.length,
queueItems: audioQueue.value.map(item => item.name),
currentPlayIndex: currentPlayIndex,
isPlayingAudio: isPlayingAudio.value,
isCallingPlayNext: isCallingPlayNext,
audioStoreIsPlaying: audioStore.isPlaying
});
if (audioQueue.value.length === 0 || isPlayingAudio.value || isCallingPlayNext) {
console.log('播放条件不满足 - 队列长度:', audioQueue.value.length, '正在播放:', isPlayingAudio.value, '正在调用:', isCallingPlayNext);
console.log('播放条件不满足 - 队列长度:', audioQueue.value.length, '正在播放:', isPlayingAudio.value, '正在调用:', isCallingPlayNext);
return;
}
//
if (currentPlayIndex >= audioQueue.value.length && audioQueue.value.length > 0) {
console.log('🔄 所有音频播放完成,重置索引从第一个开始');
currentPlayIndex = 0;
}
isCallingPlayNext = true;
isPlayingAudio.value = true;
const audioInfo = audioQueue.value.shift();
const audioInfo = audioQueue.value[currentPlayIndex];
console.log(`开始播放${audioInfo.name}音频,剩余队列:`, audioQueue.value.length);
console.log(`✅ 开始播放${audioInfo.name}音频 (索引:${currentPlayIndex}),队列总长度:`, audioQueue.value.length);
console.log('完整队列内容:', audioQueue.value.map((item, index) => `${index === currentPlayIndex ? '▶️' : '⏸️'} ${item.name}`));
//
if (audioStore.nowSound && (audioStore.nowSound.playing() || audioStore.nowSound.state() === 'loading')) {
@ -744,6 +763,7 @@ watch(
onplay: () => {
audioStore.isPlaying = true;
audioStore.isPaused = false;
isPlayingAudio.value = true; //
isCallingPlayNext = false; //
console.log(`${audioInfo.name}音频开始播放,时长:`, audio.duration());
console.log('音频播放状态确认 - isPlayingAudio:', isPlayingAudio.value, 'audioStore.isPlaying:', audioStore.isPlaying);
@ -761,21 +781,27 @@ watch(
},
onend: () => {
console.log(`${audioInfo.name}音频播放完成,准备播放下一个`);
console.log('播放完成时的状态 - 队列长度:', audioQueue.value.length, 'isPlayingAudio:', isPlayingAudio.value);
console.log('播放完成时的状态 - 当前索引:', currentPlayIndex, '队列长度:', audioQueue.value.length, 'isPlayingAudio:', isPlayingAudio.value);
audioStore.isPlaying = false;
audioStore.isPaused = false;
audioStore.playbackPosition = 0;
isPlayingAudio.value = false;
//
currentPlayIndex++;
//
if (audioQueue.value.length > 0) {
console.log('队列中还有音频,500ms后播放下一个,当前队列:', audioQueue.value.map(item => item.name));
if (currentPlayIndex < audioQueue.value.length) {
console.log(`队列中还有音频,500ms后播放下一个 (索引:${currentPlayIndex}),当前队列:`, audioQueue.value.map((item, index) => `${index === currentPlayIndex ? '▶️' : '⏸️'} ${item.name}`));
setTimeout(() => {
isCallingPlayNext = false; //
playNextAudio();
}, 500);
} else {
console.log('所有音频播放完成');
console.log('🎉 所有音频播放完成,清除音频实例,队列保持完整,下次播放将从第一个开始');
// 使
audioStore.nowSound = null;
audioStore.soundInstance = null;
isCallingPlayNext = false; //
}
},
@ -865,8 +891,10 @@ watch(
console.log('当前音频状态 - isPlaying:', audioStore.isPlaying, 'isPaused:', audioStore.isPaused);
console.log('当前音频实例:', audioStore.soundInstance);
console.log('队列播放状态 - isPlayingAudio:', isPlayingAudio.value, '队列长度:', audioQueue.value.length);
console.log('当前播放索引:', currentPlayIndex, '是否所有音频播放完成:', currentPlayIndex >= audioQueue.value.length);
if (audioStore.soundInstance) {
//
if (audioStore.soundInstance && currentPlayIndex < audioQueue.value.length && isPlayingAudio.value) {
if (audioStore.isPlaying) {
//
console.log('暂停当前音频');
@ -883,23 +911,77 @@ watch(
}
} else {
console.log('没有音频实例,检查是否需要重新播放队列');
console.log('重新播放条件检查:', {
isPlayingAudio: isPlayingAudio.value,
queueLength: audioQueue.value.length,
currentPlayIndex: currentPlayIndex,
condition1: audioQueue.value.length === 0,
condition2: currentPlayIndex >= audioQueue.value.length,
finalCondition: !isPlayingAudio.value && (audioQueue.value.length === 0 || currentPlayIndex >= audioQueue.value.length)
});
//
if (!isPlayingAudio.value && audioQueue.value.length === 0) {
if (!isPlayingAudio.value && (audioQueue.value.length === 0 || currentPlayIndex >= audioQueue.value.length)) {
console.log('所有音频播放完成,重新构建队列从第一个开始播放');
//
//
const audioItems = [];
if (audioPreloadStatus.one.url) {
addToAudioQueue(audioPreloadStatus.one.url, "API1-第一个");
audioItems.push({ url: audioPreloadStatus.one.url, name: "API1-第一个", order: 1 });
}
if (audioPreloadStatus.two.url) {
addToAudioQueue(audioPreloadStatus.two.url, "API2-第二个");
audioItems.push({ url: audioPreloadStatus.two.url, name: "API2-第二个", order: 2 });
}
if (audioPreloadStatus.three.url) {
addToAudioQueue(audioPreloadStatus.three.url, "API3-第三个");
audioItems.push({ url: audioPreloadStatus.three.url, name: "API3-第三个", order: 3 });
}
if (audioPreloadStatus.four.url) {
addToAudioQueue(audioPreloadStatus.four.url, "API4-第四个");
audioItems.push({ url: audioPreloadStatus.four.url, name: "API4-第四个", order: 4 });
}
//
audioItems.sort((a, b) => a.order - b.order);
audioQueue.value = audioItems;
console.log('队列重建完成,队列内容:', audioQueue.value.map(item => item.name));
console.log('开始从第一个音频播放');
//
if (audioQueue.value.length > 0) {
//
isPlayingAudio.value = false;
isCallingPlayNext = false;
currentPlayIndex = 0; //
audioStore.isPlaying = false;
audioStore.isPaused = false;
audioStore.playbackPosition = 0;
audioStore.nowSound = null;
audioStore.soundInstance = null;
console.log('🔄 状态完全重置完成,准备从第一个音频开始播放');
console.log('✅ 完全重置播放状态,准备播放第一个音频');
console.log('重置后状态检查:', {
isPlayingAudio: isPlayingAudio.value,
isCallingPlayNext: isCallingPlayNext,
currentPlayIndex: currentPlayIndex,
audioStoreIsPlaying: audioStore.isPlaying,
queueLength: audioQueue.value.length
});
setTimeout(() => {
console.log('🚀 延迟后开始播放第一个音频');
console.log('播放前最终状态检查:', {
currentPlayIndex: currentPlayIndex,
queueLength: audioQueue.value.length,
queueItems: audioQueue.value.map((item, index) => `${index}: ${item.name}`),
isPlayingAudio: isPlayingAudio.value,
isCallingPlayNext: isCallingPlayNext,
audioStoreIsPlaying: audioStore.isPlaying,
audioStoreInstance: !!audioStore.soundInstance
});
console.log('🎯 即将调用 playNextAudio,期望播放:', audioQueue.value[currentPlayIndex]?.name || '无音频');
playNextAudio();
}, 200);
}
console.log('队列重建完成,开始从第一个音频播放');
} else if (!isPlayingAudio.value && audioQueue.value.length > 0) {
console.log('队列中还有音频,继续播放');
playNextAudio();
@ -1342,7 +1424,7 @@ watch(
// }
// }, 50); // 50ms/
addTypingTask(aiMessage3, [ac31, ac32], 180);
addTypingTask(aiMessage3, [ac31, ac32], 200);
// chatStore.messages.push({
// sender: "ai",
@ -1423,7 +1505,7 @@ watch(
addTypingTask(
aiMessage4,
[ac41, ac42, ac43, ac44, ac45, ac46, ac47, ac48],
180
200
);
// chatStore.messages.push({
@ -1508,7 +1590,7 @@ watch(
// }
// }, 50); // 50ms/
addTypingTask(aiMessage5, [ac51, ac52, ac53, ac54], 180);
addTypingTask(aiMessage5, [ac51, ac52, ac53, ac54], 240);
// chatStore.messages.push({
// sender: "ai",
@ -1539,7 +1621,7 @@ watch(
// }
// }, 50); // 50ms/
addTypingTask(aiMessage6, ["", ac6], 180);
addTypingTask(aiMessage6, ["", ac6], 210);
// chatStore.messages.push({
// sender: "ai",

15
src/views/AiEmotion.vue

@ -291,7 +291,19 @@ const stockName = computed(() => currentStock.value?.stockInfo.name || "");
const displayDate = computed(() => {
if (!currentStock.value?.apiData) return "";
const lastData = currentStock.value.apiData.GSWDJ?.at(-1);
return lastData ? lastData[0] : "";
if (!lastData || !lastData[0]) return "";
const dateStr = lastData[0];
// YYYY-MM-DD YYYY/MM/DD
const dateMatch = dateStr.match(/(\d{4})[\-\/](\d{1,2})[\-\/](\d{1,2})/);
if (dateMatch) {
const [, year, month, day] = dateMatch;
// DD/MM/YYYY
return `更新时间:${day.padStart(2, '0')}/${month.padStart(2, '0')}/${year}`;
}
//
return dateStr;
});
const data1 = computed(() => {
if (!currentStock.value?.apiData) return null;
@ -2004,6 +2016,7 @@ defineExpose({
.span02 {
font-size: 1.5rem;
font-weight: bold;
color: white;
float: right;
margin-top: -2%;

Loading…
Cancel
Save