|
|
@ -357,7 +357,14 @@ renderer.del = function (text) { |
|
|
|
}; |
|
|
|
|
|
|
|
// 定义自定义事件 |
|
|
|
const emit = defineEmits(["updateMessage", "sendMessage", "enableInput"]); |
|
|
|
const emit = defineEmits([ |
|
|
|
"updateMessage", |
|
|
|
"sendMessage", |
|
|
|
"enableInput", |
|
|
|
"ensureAIchat", |
|
|
|
"scrollToBottom", |
|
|
|
"showCount", |
|
|
|
]); |
|
|
|
|
|
|
|
// 音频播放方法 |
|
|
|
const playAudio = (url) => { |
|
|
@ -689,8 +696,6 @@ const createTypingEffect = (message, content, speed) => { |
|
|
|
apiStatus.two.isEnd = true; |
|
|
|
} else if (message.isEnd == "3") { |
|
|
|
apiStatus.three.isEnd = true; |
|
|
|
} else if (message.isEnd == "4") { |
|
|
|
apiStatus.four.isEnd = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (message.error) { |
|
|
@ -707,8 +712,6 @@ const createTypingEffect = (message, content, speed) => { |
|
|
|
apiStatus.two.isError = true; |
|
|
|
} else if (message.error == "3") { |
|
|
|
apiStatus.three.isError = true; |
|
|
|
} else if (message.error == "4") { |
|
|
|
apiStatus.four.isError = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (message.end) { |
|
|
@ -791,8 +794,6 @@ const createTypingEffect = (message, content, speed) => { |
|
|
|
apiStatus.two.isEnd = true; |
|
|
|
} else if (message.isEnd == "3") { |
|
|
|
apiStatus.three.isEnd = true; |
|
|
|
} else if (message.isEnd == "4") { |
|
|
|
apiStatus.four.isEnd = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (message.error) { |
|
|
@ -809,8 +810,6 @@ const createTypingEffect = (message, content, speed) => { |
|
|
|
apiStatus.two.isError = true; |
|
|
|
} else if (message.error == "3") { |
|
|
|
apiStatus.three.isError = true; |
|
|
|
} else if (message.error == "4") { |
|
|
|
apiStatus.four.isError = true; |
|
|
|
} |
|
|
|
} |
|
|
|
// 延时1秒后resolve |
|
|
@ -825,8 +824,6 @@ const createTypingEffect = (message, content, speed) => { |
|
|
|
apiStatus.two.isEnd = true; |
|
|
|
} else if (message.isEnd == "3") { |
|
|
|
apiStatus.three.isEnd = true; |
|
|
|
} else if (message.isEnd == "4") { |
|
|
|
apiStatus.four.isEnd = true; |
|
|
|
} |
|
|
|
} |
|
|
|
if (message.error) { |
|
|
@ -843,8 +840,6 @@ const createTypingEffect = (message, content, speed) => { |
|
|
|
apiStatus.two.isError = true; |
|
|
|
} else if (message.error == "3") { |
|
|
|
apiStatus.three.isError = true; |
|
|
|
} else if (message.error == "4") { |
|
|
|
apiStatus.four.isError = true; |
|
|
|
} |
|
|
|
} |
|
|
|
// 延时1秒后resolve |
|
|
@ -1337,14 +1332,6 @@ watch( |
|
|
|
|
|
|
|
chatStore.firstAPICall = false; |
|
|
|
console.log("历史记录可以点击"); |
|
|
|
// chatStore.messages.push({ |
|
|
|
// sender: "ai", |
|
|
|
// class: "title1", |
|
|
|
// type: "title1", |
|
|
|
// content: codeData.value.name + "深度共振分析图谱", |
|
|
|
// date: moment().format("MM/DD/YYYY"), |
|
|
|
// }); |
|
|
|
// 添加股票信息框 |
|
|
|
|
|
|
|
const pc1 = marked( |
|
|
|
result21.data.name + |
|
|
@ -1463,7 +1450,7 @@ watch( |
|
|
|
); |
|
|
|
|
|
|
|
// 添加内容框1 |
|
|
|
const ac2 = `<p>${result22.data.jgkjfx}</p>`; |
|
|
|
const ac2 = `<p>${result21.data.jgkjfx}</p>`; |
|
|
|
|
|
|
|
// 先推送初始消息 |
|
|
|
const aiMessage2 = reactive({ |
|
|
@ -1532,21 +1519,23 @@ watch( |
|
|
|
"", |
|
|
|
50 |
|
|
|
); |
|
|
|
const ac31 = result23.data.DXTSC; |
|
|
|
const ac32 = result23.data.DXTSC2; |
|
|
|
const ac33 = result23.data.ZJQSSC1; |
|
|
|
const ac3 = ``; |
|
|
|
const ac31 = result22.data.DXTSC; |
|
|
|
const ac32 = result22.data.DXTSC2; |
|
|
|
const ac33 = result22.data.ZJQSSC1; |
|
|
|
const ac3 = `<p>${result23.data.DXTSC}</p><p>${result23.data.DXTSC2}</p><p>${result23.data.ZJQSSC1}</p>`; |
|
|
|
const ac3Arr=[]; |
|
|
|
if(ac31!=""){ |
|
|
|
ac3 += `<p>${ac31}</p>`; |
|
|
|
ac3Arr.push("") |
|
|
|
ac3Arr.push(`<p>${ac31}</p>`); |
|
|
|
} |
|
|
|
if(ac32!=""){ |
|
|
|
ac3 += `<p>${ac32}</p>`; |
|
|
|
ac3Arr.push("") |
|
|
|
ac3Arr.push(`<p>${ac32}</p>`); |
|
|
|
} |
|
|
|
if(ac33!=""){ |
|
|
|
ac3 += `<p>${ac33}</p>`; |
|
|
|
ac3Arr.push("") |
|
|
|
ac3Arr.push(`<p>${ac33}</p>`); |
|
|
|
} |
|
|
|
// const ac3 = `<p>${result23.data.zhuli1}</p><p>${result23.data.zhuli2}</p><p>${result23.data.zhuli3}</p>`; |
|
|
|
|
|
|
|
// 先推送初始消息 |
|
|
|
const aiMessage3 = reactive({ |
|
|
|
sender: "ai", |
|
|
@ -1557,7 +1546,7 @@ watch( |
|
|
|
error: apiStatus.three.error ? "3" : "", |
|
|
|
isEnd: "2", |
|
|
|
}); |
|
|
|
addTypingTask(aiMessage3, ["", ac3], 200); |
|
|
|
addTypingTask(aiMessage3, ac3Arr, 200); |
|
|
|
} else { |
|
|
|
if ( |
|
|
|
apiStatus.one.isEnd && |
|
|
@ -1624,7 +1613,7 @@ watch( |
|
|
|
); |
|
|
|
|
|
|
|
// 添加内容框4 |
|
|
|
const ac5 = `<p>${result24.data.ZJQSSC2}</p>`; |
|
|
|
const ac5 = `<p>${result23.data.ZJQSSC2}</p>`; |
|
|
|
|
|
|
|
// 先推送初始消息 |
|
|
|
const aiMessage5 = reactive({ |
|
|
@ -1647,7 +1636,6 @@ watch( |
|
|
|
end: true, |
|
|
|
}); |
|
|
|
addTypingTask(aiMessage6, ["", ac6], 210); |
|
|
|
|
|
|
|
} else { |
|
|
|
if ( |
|
|
|
apiStatus.two.isEnd && |
|
|
@ -1668,62 +1656,11 @@ watch( |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 检查FourAPI(需要ThreeAPI已执行) |
|
|
|
if ( |
|
|
|
apiStatus.three.executed && |
|
|
|
apiStatus.four.completed && |
|
|
|
!apiStatus.four.executed |
|
|
|
) { |
|
|
|
if (apiStatus.four.result) { |
|
|
|
apiStatus.four.executed = true; |
|
|
|
console.log("执行FourAPI代码:", apiStatus.four.result); |
|
|
|
|
|
|
|
// 将第四个音频添加到播放队列(确保顺序:API4) |
|
|
|
if (audioPreloadStatus.four.url) { |
|
|
|
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 |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
if ( |
|
|
|
apiStatus.three.isEnd && |
|
|
|
apiStatus.four.error && |
|
|
|
!apiStatus.four.isError |
|
|
|
) { |
|
|
|
apiStatus.four.isError = true; |
|
|
|
chatStore.messages.push({ |
|
|
|
class: "ing", |
|
|
|
type: "ing", |
|
|
|
flag: false, |
|
|
|
content: "系统正在为您努力加载中,请稍后再试", |
|
|
|
}); |
|
|
|
chatStore.isLoading = false; |
|
|
|
chatStore.chatInput = false; |
|
|
|
emit("enableInput"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 检查是否所有API都已完成并执行 |
|
|
|
if ( |
|
|
|
apiStatus.one.completed && |
|
|
|
apiStatus.two.completed && |
|
|
|
apiStatus.three.completed && |
|
|
|
apiStatus.four.completed && |
|
|
|
apiStatus.four.executed |
|
|
|
apiStatus.three.completed |
|
|
|
) { |
|
|
|
console.log("所有API已完成,开始收集预加载的音频URL"); |
|
|
|
// 收集所有预加载的音频URL |
|
|
@ -1780,8 +1717,8 @@ watch( |
|
|
|
apiStatus.one.result = result21; |
|
|
|
|
|
|
|
// 预加载第一个接口的音频 |
|
|
|
if (result21?.data?.url) { |
|
|
|
await preloadAudio(result21.data.url.trim(), "one"); |
|
|
|
if (result21?.data?.link) { |
|
|
|
await preloadAudio(result21.data.link.trim(), "one"); |
|
|
|
} else { |
|
|
|
audioPreloadStatus.one.loaded = true; |
|
|
|
} |
|
|
@ -1862,40 +1799,10 @@ watch( |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
const handleFourAPI = async () => { |
|
|
|
try { |
|
|
|
result24 = await deepNineSecondThreeAPI(params2); |
|
|
|
if (result24.code == 400) { |
|
|
|
throw new Error("API返回错误码400,请求失败"); |
|
|
|
} |
|
|
|
console.log("FourAPI成功返回:", result24); |
|
|
|
|
|
|
|
apiStatus.four.completed = true; |
|
|
|
apiStatus.four.result = result24; |
|
|
|
|
|
|
|
// 预加载第四个接口的音频 |
|
|
|
if (result24?.data?.link) { |
|
|
|
await preloadAudio(result24.data.link.trim(), "six"); |
|
|
|
} else { |
|
|
|
audioPreloadStatus.four.loaded = true; |
|
|
|
} |
|
|
|
|
|
|
|
// 检查是否可以执行 |
|
|
|
checkAndExecuteInOrder(); |
|
|
|
} catch (error) { |
|
|
|
console.error("FourAPI失败:", error); |
|
|
|
apiStatus.four.completed = true; |
|
|
|
apiStatus.four.error = error; |
|
|
|
audioPreloadStatus.four.loaded = true; |
|
|
|
checkAndExecuteInOrder(); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
if (isNineTurns) { |
|
|
|
handleOneAPI(); |
|
|
|
handleTwoAPI(); |
|
|
|
handleThreeAPI(); |
|
|
|
handleFourAPI(); |
|
|
|
} else { |
|
|
|
chatStore.messages.pop(); |
|
|
|
chatStore.messages.push({ |
|
|
@ -1990,13 +1897,6 @@ watch( |
|
|
|
isError: false, |
|
|
|
isEnd: false, |
|
|
|
}; |
|
|
|
apiStatus.four = { |
|
|
|
completed: false, |
|
|
|
result: null, |
|
|
|
error: null, |
|
|
|
isError: false, |
|
|
|
isEnd: false, |
|
|
|
}; |
|
|
|
|
|
|
|
// 🔧 新增:重置数据有效性标志 |
|
|
|
hasValidData.value = false; |
|
|
|