|
|
@ -71,7 +71,10 @@ const playNextAudio = () => { |
|
|
|
} |
|
|
|
|
|
|
|
if (currentPlayIndex >= audioQueue.value.length) { |
|
|
|
console.log("所有音频播放完成,重置到第一个音频"); |
|
|
|
console.log( |
|
|
|
"所有音频播放完成,重置到第一个音频 currentPlayIndex", |
|
|
|
currentPlayIndex |
|
|
|
); |
|
|
|
// 播放完成后重置到第一个音频,但不自动播放 |
|
|
|
currentPlayIndex = 0; |
|
|
|
audioStore.isPlaying = false; |
|
|
@ -114,7 +117,7 @@ const playNextAudio = () => { |
|
|
|
audioStore.isPlaying = true; |
|
|
|
isPlayingAudio.value = true; |
|
|
|
isCallingPlayNext = false; |
|
|
|
console.log(`${audioInfo.name}音频开始播放`); |
|
|
|
console.log(`${audioInfo.name}音频开始播放111`); |
|
|
|
}, |
|
|
|
onpause: () => { |
|
|
|
audioStore.isPlaying = false; |
|
|
@ -740,6 +743,7 @@ const createTypingEffect = (message, content, speed) => { |
|
|
|
content: "工作流返回出错,请稍后重试", |
|
|
|
}); |
|
|
|
chatStore.isLoading = false; |
|
|
|
chatStore.chatInput = false; |
|
|
|
emit("enableInput"); |
|
|
|
if (message.error == "2") { |
|
|
|
apiStatus.two.isError = true; |
|
|
@ -753,6 +757,7 @@ const createTypingEffect = (message, content, speed) => { |
|
|
|
chatStore.getUserCount(); |
|
|
|
chatStore.isLoading = false; |
|
|
|
console.log("打印完毕,接触输入框禁用状态"); |
|
|
|
chatStore.chatInput = false; |
|
|
|
emit("enableInput"); |
|
|
|
} |
|
|
|
message.isTyping = false; |
|
|
@ -872,6 +877,7 @@ const createTypingEffect = (message, content, speed) => { |
|
|
|
content: "工作流返回出错,请稍后重试", |
|
|
|
}); |
|
|
|
chatStore.isLoading = false; |
|
|
|
chatStore.chatInput = false; |
|
|
|
emit("enableInput"); |
|
|
|
if (message.error == "2") { |
|
|
|
apiStatus.two.isError = true; |
|
|
@ -905,6 +911,7 @@ const createTypingEffect = (message, content, speed) => { |
|
|
|
content: "工作流返回出错,请稍后重试", |
|
|
|
}); |
|
|
|
chatStore.isLoading = false; |
|
|
|
chatStore.chatInput = false; |
|
|
|
emit("enableInput"); |
|
|
|
if (message.error == "2") { |
|
|
|
apiStatus.two.isError = true; |
|
|
@ -1065,6 +1072,9 @@ watch( |
|
|
|
// // 添加空值判断 |
|
|
|
if (!newVal?.length || newVal === previousMessagesLength.value) return; |
|
|
|
|
|
|
|
chatStore.firstAPICall = true; |
|
|
|
console.log("第一阶段,意图识别,获取回复,历史记录禁止点击"); |
|
|
|
|
|
|
|
previousMessagesLength.value = newVal.length; |
|
|
|
if (newVal.length > 0) { |
|
|
|
// 清理语音下标 |
|
|
@ -1097,6 +1107,8 @@ watch( |
|
|
|
console.log("消息列表已更新,最新消息:", newVal[newVal.length - 1]); |
|
|
|
chatStore.messages.push(newVal[newVal.length - 1]); |
|
|
|
chatStore.currentUserIndex = chatStore.messages.length - 1; |
|
|
|
chatStore.inputUserIndex = chatStore.messages.length - 1; |
|
|
|
|
|
|
|
console.log( |
|
|
|
"消息列表已更新,最新消息:", |
|
|
|
chatStore.messages[chatStore.messages.length - 1], |
|
|
@ -1190,6 +1202,10 @@ watch( |
|
|
|
}); |
|
|
|
|
|
|
|
chatStore.isLoading = false; |
|
|
|
chatStore.chatInput = false; |
|
|
|
chatStore.firstAPICall = false; |
|
|
|
|
|
|
|
console.log("历史记录可以点击"); |
|
|
|
emit("enableInput"); |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
@ -1209,6 +1225,9 @@ watch( |
|
|
|
content: "工作流返回出错,请稍后重试", |
|
|
|
}); |
|
|
|
chatStore.isLoading = false; |
|
|
|
chatStore.chatInput = false; |
|
|
|
chatStore.firstAPICall = false; |
|
|
|
console.log("历史记录可以点击"); |
|
|
|
emit("enableInput"); |
|
|
|
} |
|
|
|
|
|
|
@ -1315,171 +1334,171 @@ watch( |
|
|
|
|
|
|
|
// 重写audioStore的togglePlayPause方法以支持队列播放控制 |
|
|
|
const originalTogglePlayPause = audioStore.togglePlayPause; |
|
|
|
audioStore.togglePlayPause = () => { |
|
|
|
console.log("主页音频控制按钮被点击22222222222222"); |
|
|
|
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 && |
|
|
|
currentPlayIndex < audioQueue.value.length && |
|
|
|
isPlayingAudio.value |
|
|
|
) { |
|
|
|
if (audioStore.isPlaying) { |
|
|
|
// 暂停当前音频 |
|
|
|
console.log("暂停当前音频"); |
|
|
|
audioStore.soundInstance.pause(); |
|
|
|
} else if ( |
|
|
|
audioStore.isPaused && |
|
|
|
audioStore.playbackPosition > 0 |
|
|
|
) { |
|
|
|
// 从暂停位置继续播放 |
|
|
|
console.log( |
|
|
|
"从暂停位置继续播放音频,位置:", |
|
|
|
audioStore.playbackPosition |
|
|
|
); |
|
|
|
audioStore.soundInstance.seek(audioStore.playbackPosition); |
|
|
|
audioStore.soundInstance.play(); |
|
|
|
} else { |
|
|
|
// 重新开始播放 |
|
|
|
console.log("重新开始播放音频"); |
|
|
|
audioStore.soundInstance.play(); |
|
|
|
} |
|
|
|
} 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 || |
|
|
|
currentPlayIndex >= audioQueue.value.length) |
|
|
|
) { |
|
|
|
console.log("所有音频播放完成,重新构建队列从第一个开始播放"); |
|
|
|
// 重新构建音频队列,按顺序添加所有音频(不自动播放) |
|
|
|
const audioItems = []; |
|
|
|
if (audioPreloadStatus.one.url) { |
|
|
|
audioItems.push({ |
|
|
|
url: audioPreloadStatus.one.url, |
|
|
|
name: "API1-第一个", |
|
|
|
order: 1, |
|
|
|
}); |
|
|
|
} |
|
|
|
if (audioPreloadStatus.two.url) { |
|
|
|
audioItems.push({ |
|
|
|
url: audioPreloadStatus.two.url, |
|
|
|
name: "API2-第二个", |
|
|
|
order: 2, |
|
|
|
}); |
|
|
|
} |
|
|
|
if (audioPreloadStatus.three.url) { |
|
|
|
audioItems.push({ |
|
|
|
url: audioPreloadStatus.three.url, |
|
|
|
name: "API3-第三个", |
|
|
|
order: 3, |
|
|
|
}); |
|
|
|
} |
|
|
|
if (audioPreloadStatus.four.url) { |
|
|
|
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); |
|
|
|
} |
|
|
|
} else if (!isPlayingAudio.value && audioQueue.value.length > 0) { |
|
|
|
console.log("队列中还有音频,继续播放"); |
|
|
|
playNextAudio(); |
|
|
|
} else { |
|
|
|
console.log( |
|
|
|
"无法播放 - isPlayingAudio:", |
|
|
|
isPlayingAudio.value, |
|
|
|
"队列长度:", |
|
|
|
audioQueue.value.length |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
// audioStore.togglePlayPause = () => { |
|
|
|
// console.log("主页音频控制按钮被点击22222222222222"); |
|
|
|
// 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 && |
|
|
|
// currentPlayIndex < audioQueue.value.length && |
|
|
|
// isPlayingAudio.value |
|
|
|
// ) { |
|
|
|
// if (audioStore.isPlaying) { |
|
|
|
// // 暂停当前音频 |
|
|
|
// console.log("暂停当前音频"); |
|
|
|
// audioStore.soundInstance.pause(); |
|
|
|
// } else if ( |
|
|
|
// audioStore.isPaused && |
|
|
|
// audioStore.playbackPosition > 0 |
|
|
|
// ) { |
|
|
|
// // 从暂停位置继续播放 |
|
|
|
// console.log( |
|
|
|
// "从暂停位置继续播放音频,位置:", |
|
|
|
// audioStore.playbackPosition |
|
|
|
// ); |
|
|
|
// audioStore.soundInstance.seek(audioStore.playbackPosition); |
|
|
|
// audioStore.soundInstance.play(); |
|
|
|
// } else { |
|
|
|
// // 重新开始播放 |
|
|
|
// console.log("重新开始播放音频"); |
|
|
|
// audioStore.soundInstance.play(); |
|
|
|
// } |
|
|
|
// } 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 || |
|
|
|
// currentPlayIndex >= audioQueue.value.length) |
|
|
|
// ) { |
|
|
|
// console.log("所有音频播放完成,重新构建队列从第一个开始播放"); |
|
|
|
// // 重新构建音频队列,按顺序添加所有音频(不自动播放) |
|
|
|
// const audioItems = []; |
|
|
|
// if (audioPreloadStatus.one.url) { |
|
|
|
// audioItems.push({ |
|
|
|
// url: audioPreloadStatus.one.url, |
|
|
|
// name: "API1-第一个", |
|
|
|
// order: 1, |
|
|
|
// }); |
|
|
|
// } |
|
|
|
// if (audioPreloadStatus.two.url) { |
|
|
|
// audioItems.push({ |
|
|
|
// url: audioPreloadStatus.two.url, |
|
|
|
// name: "API2-第二个", |
|
|
|
// order: 2, |
|
|
|
// }); |
|
|
|
// } |
|
|
|
// if (audioPreloadStatus.three.url) { |
|
|
|
// audioItems.push({ |
|
|
|
// url: audioPreloadStatus.three.url, |
|
|
|
// name: "API3-第三个", |
|
|
|
// order: 3, |
|
|
|
// }); |
|
|
|
// } |
|
|
|
// if (audioPreloadStatus.four.url) { |
|
|
|
// 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); |
|
|
|
// } |
|
|
|
// } else if (!isPlayingAudio.value && audioQueue.value.length > 0) { |
|
|
|
// console.log("队列中还有音频,继续播放"); |
|
|
|
// playNextAudio(); |
|
|
|
// } else { |
|
|
|
// console.log( |
|
|
|
// "无法播放 - isPlayingAudio:", |
|
|
|
// isPlayingAudio.value, |
|
|
|
// "队列长度:", |
|
|
|
// audioQueue.value.length |
|
|
|
// ); |
|
|
|
// } |
|
|
|
// } |
|
|
|
// }; |
|
|
|
|
|
|
|
// 预加载音频函数 |
|
|
|
const preloadAudio = (url, apiKey) => { |
|
|
@ -1532,10 +1551,16 @@ watch( |
|
|
|
|
|
|
|
// 将第一个音频添加到播放队列(确保顺序:API1) |
|
|
|
if (audioPreloadStatus.one.url) { |
|
|
|
chatStore.messages[ |
|
|
|
chatStore.currentUserIndex |
|
|
|
].audioArray.push(audioPreloadStatus.one.url); |
|
|
|
addToAudioQueue(audioPreloadStatus.one.url, "API1-第一个"); |
|
|
|
chatStore.messages[chatStore.inputUserIndex].audioArray.push( |
|
|
|
audioPreloadStatus.one.url |
|
|
|
); |
|
|
|
if (chatStore.currentUserIndex == chatStore.inputUserIndex) { |
|
|
|
addToAudioQueue(audioPreloadStatus.one.url, "API1-第一个"); |
|
|
|
} else { |
|
|
|
chatStore.messages[ |
|
|
|
chatStore.inputUserIndex |
|
|
|
].audioStatus = false; |
|
|
|
} |
|
|
|
console.log( |
|
|
|
"音频队列:添加API1音频,当前队列长度:", |
|
|
|
audioQueue.value.length |
|
|
@ -1557,6 +1582,9 @@ watch( |
|
|
|
"", |
|
|
|
50 |
|
|
|
); |
|
|
|
|
|
|
|
chatStore.firstAPICall = false; |
|
|
|
console.log("历史记录可以点击"); |
|
|
|
// chatStore.messages.push({ |
|
|
|
// sender: "ai", |
|
|
|
// class: "title1", |
|
|
@ -1789,6 +1817,7 @@ watch( |
|
|
|
content: "工作流返回出错,请稍后重试", |
|
|
|
}); |
|
|
|
chatStore.isLoading = false; |
|
|
|
chatStore.chatInput = false; |
|
|
|
emit("enableInput"); |
|
|
|
} |
|
|
|
} |
|
|
@ -1805,10 +1834,16 @@ watch( |
|
|
|
|
|
|
|
// 将第二个音频添加到播放队列(确保顺序:API2) |
|
|
|
if (audioPreloadStatus.two.url) { |
|
|
|
chatStore.messages[ |
|
|
|
chatStore.currentUserIndex |
|
|
|
].audioArray.push(audioPreloadStatus.two.url); |
|
|
|
addToAudioQueue(audioPreloadStatus.two.url, "API2-第二个"); |
|
|
|
chatStore.messages[chatStore.inputUserIndex].audioArray.push( |
|
|
|
audioPreloadStatus.two.url |
|
|
|
); |
|
|
|
if (chatStore.currentUserIndex == chatStore.inputUserIndex) { |
|
|
|
addToAudioQueue(audioPreloadStatus.two.url, "API2-第二个"); |
|
|
|
} else { |
|
|
|
chatStore.messages[ |
|
|
|
chatStore.inputUserIndex |
|
|
|
].audioStatus = false; |
|
|
|
} |
|
|
|
console.log( |
|
|
|
"音频队列:添加API2音频,当前队列长度:", |
|
|
|
audioQueue.value.length |
|
|
@ -1892,6 +1927,7 @@ watch( |
|
|
|
content: "工作流返回出错,请稍后重试", |
|
|
|
}); |
|
|
|
chatStore.isLoading = false; |
|
|
|
chatStore.chatInput = false; |
|
|
|
emit("enableInput"); |
|
|
|
} |
|
|
|
} |
|
|
@ -1909,10 +1945,19 @@ watch( |
|
|
|
|
|
|
|
// 将第三个音频添加到播放队列(确保顺序:API3) |
|
|
|
if (audioPreloadStatus.three.url) { |
|
|
|
chatStore.messages[ |
|
|
|
chatStore.currentUserIndex |
|
|
|
].audioArray.push(audioPreloadStatus.three.url); |
|
|
|
addToAudioQueue(audioPreloadStatus.three.url, "API3-第三个"); |
|
|
|
chatStore.messages[chatStore.inputUserIndex].audioArray.push( |
|
|
|
audioPreloadStatus.three.url |
|
|
|
); |
|
|
|
if (chatStore.currentUserIndex == chatStore.inputUserIndex) { |
|
|
|
addToAudioQueue( |
|
|
|
audioPreloadStatus.three.url, |
|
|
|
"API3-第三个" |
|
|
|
); |
|
|
|
} else { |
|
|
|
chatStore.messages[ |
|
|
|
chatStore.inputUserIndex |
|
|
|
].audioStatus = false; |
|
|
|
} |
|
|
|
console.log( |
|
|
|
"音频队列:添加API3音频,当前队列长度:", |
|
|
|
audioQueue.value.length |
|
|
@ -2081,6 +2126,7 @@ watch( |
|
|
|
content: "工作流返回出错,请稍后重试1111", |
|
|
|
}); |
|
|
|
chatStore.isLoading = false; |
|
|
|
chatStore.chatInput = false; |
|
|
|
emit("enableInput"); |
|
|
|
} |
|
|
|
} |
|
|
@ -2098,10 +2144,16 @@ watch( |
|
|
|
|
|
|
|
// 将第四个音频添加到播放队列(确保顺序:API4) |
|
|
|
if (audioPreloadStatus.four.url) { |
|
|
|
chatStore.messages[ |
|
|
|
chatStore.currentUserIndex |
|
|
|
].audioArray.push(audioPreloadStatus.four.url); |
|
|
|
addToAudioQueue(audioPreloadStatus.four.url, "API4-第四个"); |
|
|
|
chatStore.messages[chatStore.inputUserIndex].audioArray.push( |
|
|
|
audioPreloadStatus.four.url |
|
|
|
); |
|
|
|
if (chatStore.currentUserIndex == chatStore.inputUserIndex) { |
|
|
|
addToAudioQueue(audioPreloadStatus.four.url, "API4-第四个"); |
|
|
|
} else { |
|
|
|
chatStore.messages[ |
|
|
|
chatStore.inputUserIndex |
|
|
|
].audioStatus = false; |
|
|
|
} |
|
|
|
console.log( |
|
|
|
"音频队列:添加API4音频,当前队列长度:", |
|
|
|
audioQueue.value.length |
|
|
@ -2219,6 +2271,7 @@ watch( |
|
|
|
content: "工作流返回出错,请稍后重试", |
|
|
|
}); |
|
|
|
chatStore.isLoading = false; |
|
|
|
chatStore.chatInput = false; |
|
|
|
emit("enableInput"); |
|
|
|
} |
|
|
|
} |
|
|
@ -2408,6 +2461,7 @@ watch( |
|
|
|
content: "数据缺失,请稍后重试", |
|
|
|
}); |
|
|
|
chatStore.isLoading = false; |
|
|
|
chatStore.chatInput = false; |
|
|
|
emit("enableInput"); |
|
|
|
} |
|
|
|
} catch (e) { |
|
|
@ -2441,11 +2495,84 @@ watch( |
|
|
|
const clickRecord = ref(newValue); |
|
|
|
console.log("dbqbClickRecord 发生变化:", clickRecord.value); |
|
|
|
|
|
|
|
// 在下一个事件循环中清空 dbqbClickRecord |
|
|
|
setTimeout(() => { |
|
|
|
chatStore.dbqbClickRecord = {}; |
|
|
|
console.log("dbqbClickRecord 已清空"); |
|
|
|
}, 0); |
|
|
|
// 🔧 新增:完整的任务停止逻辑 |
|
|
|
try { |
|
|
|
// 1. 停止所有音频相关任务 |
|
|
|
chatStore.currentUserIndex = null; |
|
|
|
audioStore.stop(); // 暂停语音 |
|
|
|
|
|
|
|
// 🔧 新增:重置音频队列状态,确保新音频能够自动播放 |
|
|
|
audioQueue.value = []; |
|
|
|
isPlayingAudio.value = false; |
|
|
|
currentPlayIndex = 0; |
|
|
|
isCallingPlayNext = false; |
|
|
|
|
|
|
|
// 🔧 新增:重置音频预加载状态 |
|
|
|
audioPreloadStatus.one = { loaded: false, url: null }; |
|
|
|
audioPreloadStatus.two = { loaded: false, url: null }; |
|
|
|
audioPreloadStatus.three = { loaded: false, url: null }; |
|
|
|
audioPreloadStatus.four = { loaded: false, url: null }; |
|
|
|
|
|
|
|
// 🔧 新增:清理音频实例 |
|
|
|
if (audioStore.soundInstance) { |
|
|
|
audioStore.soundInstance.stop(); |
|
|
|
audioStore.soundInstance.unload(); |
|
|
|
audioStore.soundInstance = null; |
|
|
|
} |
|
|
|
audioStore.nowSound = null; |
|
|
|
|
|
|
|
// 2. 停止API调用和状态重置 |
|
|
|
// 🔧 新增:重置API状态 |
|
|
|
apiStatus.one = { |
|
|
|
completed: false, |
|
|
|
result: null, |
|
|
|
error: null, |
|
|
|
isError: false, |
|
|
|
isEnd: false, |
|
|
|
}; |
|
|
|
apiStatus.two = { |
|
|
|
completed: false, |
|
|
|
result: null, |
|
|
|
error: null, |
|
|
|
isError: false, |
|
|
|
isEnd: false, |
|
|
|
}; |
|
|
|
apiStatus.three = { |
|
|
|
completed: false, |
|
|
|
result: null, |
|
|
|
error: null, |
|
|
|
isError: false, |
|
|
|
isEnd: false, |
|
|
|
}; |
|
|
|
apiStatus.four = { |
|
|
|
completed: false, |
|
|
|
result: null, |
|
|
|
error: null, |
|
|
|
isError: false, |
|
|
|
isEnd: false, |
|
|
|
}; |
|
|
|
|
|
|
|
// 🔧 新增:重置数据有效性标志 |
|
|
|
hasValidData.value = false; |
|
|
|
|
|
|
|
// 3. 停止打字机效果 |
|
|
|
typingQueue.value = []; |
|
|
|
isTypingInProgress.value = false; |
|
|
|
|
|
|
|
// 4. 重置加载状态 |
|
|
|
chatStore.isLoading = false; |
|
|
|
chatStore.chatInput = false; |
|
|
|
emit("enableInput"); |
|
|
|
|
|
|
|
// 在下一个事件循环中清空 dbqbClickRecord |
|
|
|
setTimeout(() => { |
|
|
|
chatStore.dbqbClickRecord = {}; |
|
|
|
console.log("dbqbClickRecord 已清空"); |
|
|
|
}, 0); |
|
|
|
} catch (error) { |
|
|
|
console.error("停止任务时发生错误:", error); |
|
|
|
} |
|
|
|
|
|
|
|
if ( |
|
|
|
!clickRecord.value.wokeFlowData.One || |
|
|
|
!clickRecord.value.wokeFlowData.Two || |
|
|
@ -2455,16 +2582,6 @@ watch( |
|
|
|
return; |
|
|
|
} |
|
|
|
try { |
|
|
|
// 清理语音下标 |
|
|
|
chatStore.currentUserIndex = null; |
|
|
|
audioStore.stop(); // 暂停语音 |
|
|
|
|
|
|
|
// 解开输入框 |
|
|
|
emit("enableInput"); |
|
|
|
// 清除打字机队列和状态 |
|
|
|
typingQueue.value = []; |
|
|
|
isTypingInProgress.value = false; |
|
|
|
|
|
|
|
// 清空聊天框内容 |
|
|
|
chatStore.messages = []; |
|
|
|
|
|
|
@ -4348,8 +4465,42 @@ function renderAllKlineCharts() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
const clearAudio = () => { |
|
|
|
// 停止音频播放 |
|
|
|
if (audioStore.isPlaying) { |
|
|
|
audioStore.stop(); |
|
|
|
console.log("组件卸载,音频已停止"); |
|
|
|
} |
|
|
|
// 清理队列系统 |
|
|
|
audioQueue.value = []; |
|
|
|
isPlayingAudio.value = false; |
|
|
|
currentPlayIndex = 0; |
|
|
|
isCallingPlayNext = false; |
|
|
|
|
|
|
|
// 清理音频实例 |
|
|
|
audioStore.soundInstance = null; |
|
|
|
audioStore.nowSound = null; |
|
|
|
|
|
|
|
// 停止所有 Howler 实例 |
|
|
|
Howler.stop(); |
|
|
|
Howler.unload(); |
|
|
|
|
|
|
|
// 重置音频状态 |
|
|
|
audioStore.isPlaying = false; |
|
|
|
audioStore.isPaused = false; |
|
|
|
audioStore.playbackPosition = 0; |
|
|
|
|
|
|
|
// 清理预加载状态 |
|
|
|
Object.keys(audioPreloadStatus).forEach((key) => { |
|
|
|
audioPreloadStatus[key] = { loaded: false, url: null }; |
|
|
|
}); |
|
|
|
|
|
|
|
chatStore.currentUserIndex = -1; |
|
|
|
}; |
|
|
|
|
|
|
|
// 初始化随机GIF |
|
|
|
onMounted(() => { |
|
|
|
clearAudio(); |
|
|
|
// 检测移动设备 |
|
|
|
const isMobile = |
|
|
|
/Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test( |
|
|
@ -4447,11 +4598,7 @@ onUnmounted(() => { |
|
|
|
// 移除页面可见性变化监听器 |
|
|
|
document.removeEventListener("visibilitychange", handleVisibilityChange); |
|
|
|
|
|
|
|
// 停止音频播放 |
|
|
|
if (audioStore.isPlaying) { |
|
|
|
audioStore.stop(); |
|
|
|
console.log("组件卸载,音频已停止"); |
|
|
|
} |
|
|
|
clearAudio(); |
|
|
|
|
|
|
|
// 清理所有图表实例 |
|
|
|
Object.keys(chartInstancesMap).forEach((key) => { |
|
|
|