Browse Source

报错中断

dongqian/feature-20250702094358-小财神适配
dongqian 1 day ago
parent
commit
4e6d7e8970
  1. 16116
      package-lock.json
  2. BIN
      src/assets/img/AIchat/圈.png
  3. 2
      src/store/dataList.js
  4. 377
      src/views/AIchat.vue
  5. 3
      src/views/homePage.vue

16116
package-lock.json
File diff suppressed because it is too large
View File

BIN
src/assets/img/AIchat/圈.png

Before

Width: 640  |  Height: 640  |  Size: 494 KiB

After

Width: 739  |  Height: 750  |  Size: 154 KiB

2
src/store/dataList.js

@ -192,7 +192,7 @@ export const useDataStore = defineStore("data", () => {
// if (newValue === 1) fetchChartData() // if (newValue === 1) fetchChartData()
// }) // })
initData();
// initData();
return { return {
// brainDataList, // brainDataList,

377
src/views/AIchat.vue

@ -173,7 +173,7 @@ const playAudioSequence = (audioUrls) => {
"长度:", "长度:",
currentUrl?.length currentUrl?.length
); );
// URL // URL
if (!currentUrl || typeof currentUrl !== 'string' || currentUrl.trim() === '') { if (!currentUrl || typeof currentUrl !== 'string' || currentUrl.trim() === '') {
console.error(`音频 ${currentIndex + 1} URL无效,跳过该音频`); console.error(`音频 ${currentIndex + 1} URL无效,跳过该音频`);
@ -183,7 +183,7 @@ const playAudioSequence = (audioUrls) => {
}, 100); }, 100);
return; return;
} }
// URL // URL
try { try {
new URL(currentUrl); new URL(currentUrl);
@ -253,12 +253,12 @@ const playAudioSequence = (audioUrls) => {
console.error(`音频 ${currentIndex + 1} 加载失败:`, err); console.error(`音频 ${currentIndex + 1} 加载失败:`, err);
console.error('失败的音频URL:', currentUrl); console.error('失败的音频URL:', currentUrl);
console.error('错误详情:', { id, err }); console.error('错误详情:', { id, err });
// //
if (!sound.retryCount) { if (!sound.retryCount) {
sound.retryCount = 0; sound.retryCount = 0;
} }
if (sound.retryCount < 2) { if (sound.retryCount < 2) {
sound.retryCount++; sound.retryCount++;
console.log(`音频 ${currentIndex + 1}${sound.retryCount}次重试加载`); console.log(`音频 ${currentIndex + 1}${sound.retryCount}次重试加载`);
@ -278,7 +278,7 @@ const playAudioSequence = (audioUrls) => {
audioStore.nowSound = sound; audioStore.nowSound = sound;
audioStore.setAudioInstance(sound); audioStore.setAudioInstance(sound);
// //
const playTimeout = setTimeout(() => { const playTimeout = setTimeout(() => {
if (!audioStore.isPlaying && sound.state() === 'loading') { if (!audioStore.isPlaying && sound.state() === 'loading') {
@ -288,12 +288,12 @@ const playAudioSequence = (audioUrls) => {
playNext(); playNext();
} }
}, 10000); // 10 }, 10000); // 10
// //
sound.once('play', () => { sound.once('play', () => {
clearTimeout(playTimeout); clearTimeout(playTimeout);
}); });
console.log(`尝试播放音频 ${currentIndex + 1},URL: ${currentUrl}`); console.log(`尝试播放音频 ${currentIndex + 1},URL: ${currentUrl}`);
sound.play(); sound.play();
}; };
@ -306,7 +306,7 @@ const playAudioSequence = (audioUrls) => {
console.log('当前暂停状态:', audioStore.isPaused); console.log('当前暂停状态:', audioStore.isPaused);
console.log('当前音频实例:', audioStore.soundInstance); console.log('当前音频实例:', audioStore.soundInstance);
console.log('当前索引:', currentIndex, '音频序列长度:', audioSequence.length); console.log('当前索引:', currentIndex, '音频序列长度:', audioSequence.length);
if (audioStore.soundInstance) { if (audioStore.soundInstance) {
if (audioStore.isPlaying) { if (audioStore.isPlaying) {
// //
@ -367,7 +367,7 @@ const typeWriter = (text, callback) => {
// //
nextTick(() => { nextTick(() => {
const container = document.querySelector(".message-area"); const container = document.querySelector(".message-area");
if (container) container.scrollTop = container.scrollHeight;
if (container) container.scrollTop = container.scrollHeight;
}); });
} else { } else {
clearInterval(typingInterval); clearInterval(typingInterval);
@ -420,6 +420,36 @@ const createTypingEffect = (message, content, speed) => {
const processNextElement = () => { const processNextElement = () => {
if (currentIndex >= content.length) { if (currentIndex >= content.length) {
if (message.isEnd) {
if (message.isEnd == '1') {
apiStatus.one.isEnd = true;
} else if (message.isEnd == '2') {
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) {
chatStore.messages.push({
class: "ing",
type: "ing",
flag: false,
content: '工作流返回出错,请稍后重试',
})
chatStore.isLoading = false;
if (message.error == '2') {
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) {
chatStore.isLoading = false;
}
message.isTyping = false; message.isTyping = false;
nextTick(() => { nextTick(() => {
resolve(); // resolve resolve(); // resolve
@ -518,11 +548,65 @@ const createTypingEffect = (message, content, speed) => {
} }
}); });
} }
if (message.isEnd) {
if (message.isEnd == '1') {
apiStatus.one.isEnd = true;
} else if (message.isEnd == '2') {
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) {
chatStore.messages.push({
class: "ing",
type: "ing",
flag: false,
content: '工作流返回出错,请稍后重试',
})
chatStore.isLoading = false;
if (message.error == '2') {
apiStatus.two.isError = true;
} else if (message.error == '3') {
apiStatus.three.isError = true;
} else if (message.error == '4') {
apiStatus.four.isError = true;
}
}
// 1resolve // 1resolve
setTimeout(() => { setTimeout(() => {
resolve(); resolve();
}, 1000); }, 1000);
} else { } else {
if (message.isEnd) {
if (message.isEnd == '1') {
apiStatus.one.isEnd = true;
} else if (message.isEnd == '2') {
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) {
chatStore.messages.push({
class: "ing",
type: "ing",
flag: false,
content: '工作流返回出错,请稍后重试',
})
chatStore.isLoading = false;
if (message.error == '2') {
apiStatus.two.isError = true;
} else if (message.error == '3') {
apiStatus.three.isError = true;
} else if (message.error == '4') {
apiStatus.four.isError = true;
}
}
// 1resolve // 1resolve
setTimeout(() => { setTimeout(() => {
resolve(); resolve();
@ -532,6 +616,8 @@ const createTypingEffect = (message, content, speed) => {
}); });
}; };
let apiStatus = {}
// //
const processTypingQueue = async () => { const processTypingQueue = async () => {
if (isTypingInProgress.value || typingQueue.value.length === 0) { if (isTypingInProgress.value || typingQueue.value.length === 0) {
@ -638,10 +724,17 @@ watch(
content: aiContent, content: aiContent,
}); });
chatStore.setLoading(false);
chatStore.isLoading = false;
} }
} catch (e) { } catch (e) {
console.log(e, "意图识别失败"); console.log(e, "意图识别失败");
chatStore.messages.push({
class: "ing",
type: "ing",
flag: false,
content: '工作流返回出错,请稍后重试',
})
chatStore.isLoading = false;
} }
if (flag) { if (flag) {
@ -662,8 +755,8 @@ watch(
const env = import.meta.env.VITE_ENV; const env = import.meta.env.VITE_ENV;
const result20 = await dataListAPI({ const result20 = await dataListAPI({
token: token:
'8Csj5VVX1UbIb4C3oxrnbZi0+fEeMx8pywnIlrmTm45Cb/EllzWACLto9J9+fCFsfdgBOvKvyY94FvqlvM0',
// "8nkj4QBV1RPIb4CzoRTnbZi0+fEeMx8pywnIlrmTxdwROKkuwWqAWu9orpkpeXVqL98DPfeonNYpHv+mucA",
'8Csj5VVX1UbIb4C3oxrnbZi0+fEeMx8pywnIlrmTm45Cb/EllzWACLto9J9+fCFsfdgBOvKvyY94FvqlvM0',
// "8nkj4QBV1RPIb4CzoRTnbZi0+fEeMx8pywnIlrmTxdwROKkuwWqAWu9orpkpeXVqL98DPfeonNYpHv+mucA",
market: codeData.value.market, market: codeData.value.market,
code: codeData.value.code, code: codeData.value.code,
language: "cn", //t.value.suoxie, language: "cn", //t.value.suoxie,
@ -685,6 +778,8 @@ watch(
marketList: userStore.aiGoldMarketList, marketList: userStore.aiGoldMarketList,
}); });
const HomePage = result20.data.HomePage; const HomePage = result20.data.HomePage;
const AIGoldBull = result20.data.AIGoldBull; const AIGoldBull = result20.data.AIGoldBull;
@ -695,11 +790,11 @@ watch(
let result23; let result23;
let result24; let result24;
// API // API
const apiStatus = {
one: { completed: false, result: null, error: null },
two: { completed: false, result: null, error: null },
three: { completed: false, result: null, error: null },
four: { completed: false, result: null, error: null },
apiStatus = {
one: { completed: false, result: null, error: null, isError: false, isEnd: false },
two: { completed: false, result: null, error: null, isError: false, isEnd: false },
three: { completed: false, result: null, error: null, isError: false, isEnd: false },
four: { completed: false, result: null, error: null, isError: false, isEnd: false },
}; };
// //
@ -719,7 +814,7 @@ watch(
let isCallingPlayNext = false; let isCallingPlayNext = false;
// //
let currentPlayIndex = 0; let currentPlayIndex = 0;
const playNextAudio = () => { const playNextAudio = () => {
console.log('=== playNextAudio 被调用 ==='); console.log('=== playNextAudio 被调用 ===');
console.log('当前队列状态:', { console.log('当前队列状态:', {
@ -730,7 +825,7 @@ watch(
isCallingPlayNext: isCallingPlayNext, isCallingPlayNext: isCallingPlayNext,
audioStoreIsPlaying: audioStore.isPlaying audioStoreIsPlaying: audioStore.isPlaying
}); });
if (audioQueue.value.length === 0 || isPlayingAudio.value || isCallingPlayNext) { 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; return;
@ -745,10 +840,10 @@ watch(
isCallingPlayNext = true; isCallingPlayNext = true;
isPlayingAudio.value = true; isPlayingAudio.value = true;
const audioInfo = audioQueue.value[currentPlayIndex]; const audioInfo = audioQueue.value[currentPlayIndex];
console.log(`✅ 开始播放${audioInfo.name}音频 (索引:${currentPlayIndex}),队列总长度:`, audioQueue.value.length); console.log(`✅ 开始播放${audioInfo.name}音频 (索引:${currentPlayIndex}),队列总长度:`, audioQueue.value.length);
console.log('完整队列内容:', audioQueue.value.map((item, index) => `${index === currentPlayIndex ? '▶️' : '⏸️'} ${item.name}`)); console.log('完整队列内容:', audioQueue.value.map((item, index) => `${index === currentPlayIndex ? '▶️' : '⏸️'} ${item.name}`));
// //
if (audioStore.nowSound && (audioStore.nowSound.playing() || audioStore.nowSound.state() === 'loading')) { if (audioStore.nowSound && (audioStore.nowSound.playing() || audioStore.nowSound.state() === 'loading')) {
console.log('停止之前的音频实例'); console.log('停止之前的音频实例');
@ -786,10 +881,10 @@ watch(
audioStore.isPaused = false; audioStore.isPaused = false;
audioStore.playbackPosition = 0; audioStore.playbackPosition = 0;
isPlayingAudio.value = false; isPlayingAudio.value = false;
// //
currentPlayIndex++; currentPlayIndex++;
// //
if (currentPlayIndex < audioQueue.value.length) { if (currentPlayIndex < audioQueue.value.length) {
console.log(`队列中还有音频,500ms后播放下一个 (索引:${currentPlayIndex}),当前队列:`, audioQueue.value.map((item, index) => `${index === currentPlayIndex ? '▶️' : '⏸️'} ${item.name}`)); console.log(`队列中还有音频,500ms后播放下一个 (索引:${currentPlayIndex}),当前队列:`, audioQueue.value.map((item, index) => `${index === currentPlayIndex ? '▶️' : '⏸️'} ${item.name}`));
@ -827,7 +922,7 @@ watch(
audioStore.setCurrentAudioUrl(audioInfo.url); audioStore.setCurrentAudioUrl(audioInfo.url);
audioStore.nowSound = audio; audioStore.nowSound = audio;
audioStore.setAudioInstance(audio); audioStore.setAudioInstance(audio);
console.log(`尝试播放${audioInfo.name}音频`); console.log(`尝试播放${audioInfo.name}音频`);
audio.play(); audio.play();
}; };
@ -839,21 +934,21 @@ watch(
'API3-第三个': 3, 'API3-第三个': 3,
'API4-第四个': 4 'API4-第四个': 4
}; };
// //
const addToAudioQueue = (url, name) => { const addToAudioQueue = (url, name) => {
console.log(`=== 添加音频到队列 ===`); console.log(`=== 添加音频到队列 ===`);
console.log('URL:', url); console.log('URL:', url);
console.log('Name:', name); console.log('Name:', name);
console.log('音频启用状态:', audioStore.isVoiceEnabled); console.log('音频启用状态:', audioStore.isVoiceEnabled);
if (url && audioStore.isVoiceEnabled) { if (url && audioStore.isVoiceEnabled) {
const audioItem = { url, name, order: audioQueueOrder[name] || 999 }; const audioItem = { url, name, order: audioQueueOrder[name] || 999 };
audioQueue.value.push(audioItem); audioQueue.value.push(audioItem);
// //
audioQueue.value.sort((a, b) => a.order - b.order); audioQueue.value.sort((a, b) => a.order - b.order);
console.log(`音频${name}已添加到播放队列,顺序:${audioItem.order}`); console.log(`音频${name}已添加到播放队列,顺序:${audioItem.order}`);
console.log('当前队列顺序:', audioQueue.value.map(item => `${item.name}(${item.order})`)); console.log('当前队列顺序:', audioQueue.value.map(item => `${item.name}(${item.order})`));
console.log('当前播放状态详情:'); console.log('当前播放状态详情:');
@ -862,7 +957,7 @@ watch(
console.log(' - audioStore.nowSound:', audioStore.nowSound); console.log(' - audioStore.nowSound:', audioStore.nowSound);
console.log(' - isCallingPlayNext:', isCallingPlayNext); console.log(' - isCallingPlayNext:', isCallingPlayNext);
console.log(' - 队列长度:', audioQueue.value.length); console.log(' - 队列长度:', audioQueue.value.length);
// //
if (!isPlayingAudio.value && !audioStore.isPlaying && audioQueue.value.length === 1) { if (!isPlayingAudio.value && !audioStore.isPlaying && audioQueue.value.length === 1) {
console.log('✅ 条件满足:没有音频在播放且这是第一个音频,立即开始播放'); console.log('✅ 条件满足:没有音频在播放且这是第一个音频,立即开始播放');
@ -892,7 +987,7 @@ watch(
console.log('当前音频实例:', audioStore.soundInstance); console.log('当前音频实例:', audioStore.soundInstance);
console.log('队列播放状态 - isPlayingAudio:', isPlayingAudio.value, '队列长度:', audioQueue.value.length); console.log('队列播放状态 - isPlayingAudio:', isPlayingAudio.value, '队列长度:', audioQueue.value.length);
console.log('当前播放索引:', currentPlayIndex, '是否所有音频播放完成:', currentPlayIndex >= audioQueue.value.length); console.log('当前播放索引:', currentPlayIndex, '是否所有音频播放完成:', currentPlayIndex >= audioQueue.value.length);
// //
if (audioStore.soundInstance && currentPlayIndex < audioQueue.value.length && isPlayingAudio.value) { if (audioStore.soundInstance && currentPlayIndex < audioQueue.value.length && isPlayingAudio.value) {
if (audioStore.isPlaying) { if (audioStore.isPlaying) {
@ -936,14 +1031,14 @@ watch(
if (audioPreloadStatus.four.url) { if (audioPreloadStatus.four.url) {
audioItems.push({ url: audioPreloadStatus.four.url, name: "API4-第四个", order: 4 }); audioItems.push({ url: audioPreloadStatus.four.url, name: "API4-第四个", order: 4 });
} }
// //
audioItems.sort((a, b) => a.order - b.order); audioItems.sort((a, b) => a.order - b.order);
audioQueue.value = audioItems; audioQueue.value = audioItems;
console.log('队列重建完成,队列内容:', audioQueue.value.map(item => item.name)); console.log('队列重建完成,队列内容:', audioQueue.value.map(item => item.name));
console.log('开始从第一个音频播放'); console.log('开始从第一个音频播放');
// //
if (audioQueue.value.length > 0) { if (audioQueue.value.length > 0) {
// //
@ -955,9 +1050,9 @@ watch(
audioStore.playbackPosition = 0; audioStore.playbackPosition = 0;
audioStore.nowSound = null; audioStore.nowSound = null;
audioStore.soundInstance = null; audioStore.soundInstance = null;
console.log('🔄 状态完全重置完成,准备从第一个音频开始播放'); console.log('🔄 状态完全重置完成,准备从第一个音频开始播放');
console.log('✅ 完全重置播放状态,准备播放第一个音频'); console.log('✅ 完全重置播放状态,准备播放第一个音频');
console.log('重置后状态检查:', { console.log('重置后状态检查:', {
isPlayingAudio: isPlayingAudio.value, isPlayingAudio: isPlayingAudio.value,
@ -966,7 +1061,7 @@ watch(
audioStoreIsPlaying: audioStore.isPlaying, audioStoreIsPlaying: audioStore.isPlaying,
queueLength: audioQueue.value.length queueLength: audioQueue.value.length
}); });
setTimeout(() => { setTimeout(() => {
console.log('🚀 延迟后开始播放第一个音频'); console.log('🚀 延迟后开始播放第一个音频');
console.log('播放前最终状态检查:', { console.log('播放前最终状态检查:', {
@ -1032,32 +1127,32 @@ watch(
// //
const checkAndExecuteInOrder = () => { const checkAndExecuteInOrder = () => {
// OneAPI - // OneAPI -
if (canStartFirstOutput() && !apiStatus.one.executed) {
apiStatus.one.executed = true;
if (apiStatus.one.result) {
console.log("执行OneAPI代码(文本和音频同步开始):", apiStatus.one.result);
// API1
if (audioPreloadStatus.one.url) {
addToAudioQueue(audioPreloadStatus.one.url, "API1-第一个");
console.log("音频队列:添加API1音频,当前队列长度:", audioQueue.value.length);
}
// OneAPI
//
chatStore.messages.pop();
//
addTypingTask(
{
sender: "ai",
class: "title1",
type: "title1",
content: codeData.value.name + "全景作战报告",
date: result21.data.date,
},
"",
50
);
if (canStartFirstOutput() && !apiStatus.one.executed) {
if (apiStatus.one.result) {
apiStatus.one.executed = true;
console.log("执行OneAPI代码(文本和音频同步开始):", apiStatus.one.result);
// API1
if (audioPreloadStatus.one.url) {
addToAudioQueue(audioPreloadStatus.one.url, "API1-第一个");
console.log("音频队列:添加API1音频,当前队列长度:", audioQueue.value.length);
}
// OneAPI
//
chatStore.messages.pop();
//
addTypingTask(
{
sender: "ai",
class: "title1",
type: "title1",
content: codeData.value.name + "全景作战报告",
date: result21.data.date,
},
"",
50
);
// chatStore.messages.push({ // chatStore.messages.push({
// sender: "ai", // sender: "ai",
// class: "title1", // class: "title1",
@ -1069,10 +1164,10 @@ watch(
const pc1 = marked( const pc1 = marked(
result21.data.name + result21.data.name +
"\n" +
result21.data.price +
"\n" +
result21.data.date
"\n" +
result21.data.price +
"\n" +
result21.data.date
); );
const ac1 = pc1.replace(katexRegex, (match, formula) => { const ac1 = pc1.replace(katexRegex, (match, formula) => {
try { try {
@ -1234,6 +1329,8 @@ watch(
messageId: klineMessageId2, messageId: klineMessageId2,
hasValidData: true, // hasValidData hasValidData: true, // hasValidData
klineType: 2, klineType: 2,
error: apiStatus.two.error ? '2' : '',
isEnd: '1',
}, },
"", "",
50 50
@ -1270,6 +1367,14 @@ watch(
// console.warn("K线"); // console.warn("K线");
// } // }
// }); // });
} else {
chatStore.messages.push({
class: "ing",
type: "ing",
flag: false,
content: '工作流返回出错,请稍后重试',
})
chatStore.isLoading = false;
} }
} }
@ -1279,16 +1384,17 @@ watch(
apiStatus.two.completed && apiStatus.two.completed &&
!apiStatus.two.executed !apiStatus.two.executed
) { ) {
apiStatus.two.executed = true;
if (apiStatus.two.result) { if (apiStatus.two.result) {
apiStatus.two.executed = true;
console.log("执行TwoAPI代码:", apiStatus.two.result); console.log("执行TwoAPI代码:", apiStatus.two.result);
// API2 // API2
if (audioPreloadStatus.two.url) { if (audioPreloadStatus.two.url) {
addToAudioQueue(audioPreloadStatus.two.url, "API2-第二个"); addToAudioQueue(audioPreloadStatus.two.url, "API2-第二个");
console.log("音频队列:添加API2音频,当前队列长度:", audioQueue.value.length); console.log("音频队列:添加API2音频,当前队列长度:", audioQueue.value.length);
} }
// TwoAPI // TwoAPI
// 2 // 2
addTypingTask( addTypingTask(
@ -1328,6 +1434,8 @@ watch(
type: "content3", type: "content3",
content: "", content: "",
isTyping: true, isTyping: true,
error: apiStatus.three.error ? '3' : '',
isEnd: '2'
}); });
// chatStore.messages.push(aiMessage2); // chatStore.messages.push(aiMessage2);
@ -1349,6 +1457,18 @@ watch(
// type: "content3", // type: "content3",
// content: ac2, // content: ac2,
// }); // });
} else {
console.log('1111111111111111111')
if (apiStatus.one.isEnd && apiStatus.two.error && !apiStatus.two.isError) {
apiStatus.two.isError = true
chatStore.messages.push({
class: "ing",
type: "ing",
flag: false,
content: '工作流返回出错,请稍后重试',
})
chatStore.isLoading = false;
}
} }
} }
@ -1358,16 +1478,17 @@ watch(
apiStatus.three.completed && apiStatus.three.completed &&
!apiStatus.three.executed !apiStatus.three.executed
) { ) {
apiStatus.three.executed = true;
if (apiStatus.three.result) { if (apiStatus.three.result) {
apiStatus.three.executed = true;
console.log("执行ThreeAPI代码:", apiStatus.three.result); console.log("执行ThreeAPI代码:", apiStatus.three.result);
// API3 // API3
if (audioPreloadStatus.three.url) { if (audioPreloadStatus.three.url) {
addToAudioQueue(audioPreloadStatus.three.url, "API3-第三个"); addToAudioQueue(audioPreloadStatus.three.url, "API3-第三个");
console.log("音频队列:添加API3音频,当前队列长度:", audioQueue.value.length); console.log("音频队列:添加API3音频,当前队列长度:", audioQueue.value.length);
} }
// ThreeAPI // ThreeAPI
// 3-2 // 3-2
addTypingTask( addTypingTask(
@ -1488,6 +1609,8 @@ watch(
type: "content3", type: "content3",
content: "", content: "",
isTyping: true, isTyping: true,
error: apiStatus.four.error ? '4' : '',
isEnd: '3'
}); });
// chatStore.messages.push(aiMessage4); // chatStore.messages.push(aiMessage4);
@ -1514,6 +1637,17 @@ watch(
// type: "content3", // type: "content3",
// content: ac4, // content: ac4,
// }); // });
} else {
if (apiStatus.two.isEnd && apiStatus.three.error && !apiStatus.three.isError) {
apiStatus.three.isError = true;
chatStore.messages.push({
class: "ing",
type: "ing",
flag: false,
content: '工作流返回出错,请稍后重试1111',
})
chatStore.isLoading = false;
}
} }
} }
@ -1523,16 +1657,17 @@ watch(
apiStatus.four.completed && apiStatus.four.completed &&
!apiStatus.four.executed !apiStatus.four.executed
) { ) {
apiStatus.four.executed = true;
if (apiStatus.four.result) { if (apiStatus.four.result) {
apiStatus.four.executed = true;
console.log("执行FourAPI代码:", apiStatus.four.result); console.log("执行FourAPI代码:", apiStatus.four.result);
// API4 // API4
if (audioPreloadStatus.four.url) { if (audioPreloadStatus.four.url) {
addToAudioQueue(audioPreloadStatus.four.url, "API4-第四个"); addToAudioQueue(audioPreloadStatus.four.url, "API4-第四个");
console.log("音频队列:添加API4音频,当前队列长度:", audioQueue.value.length); console.log("音频队列:添加API4音频,当前队列长度:", audioQueue.value.length);
} }
// FourAPI // FourAPI
// 3-4 // 3-4
addTypingTask( addTypingTask(
@ -1607,6 +1742,7 @@ watch(
type: "mianze", type: "mianze",
content: "", content: "",
isTyping: true, isTyping: true,
end: true
}); });
// chatStore.messages.push(aiMessage6); // chatStore.messages.push(aiMessage6);
@ -1622,13 +1758,24 @@ watch(
// } // }
// }, 50); // 50ms/ // }, 50); // 50ms/
addTypingTask(aiMessage6, ["", ac6], 210); addTypingTask(aiMessage6, ["", ac6], 210);
// chatStore.isLoading = false;
// chatStore.messages.push({ // chatStore.messages.push({
// sender: "ai", // sender: "ai",
// class: "mianze", // class: "mianze",
// type: "mianze", // type: "mianze",
// content: "AI,", // content: "AI,",
// });
// });
} 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;
}
} }
} }
@ -1690,17 +1837,11 @@ watch(
checkAndExecuteInOrder(); checkAndExecuteInOrder();
} catch (error) { } catch (error) {
console.error("OneAPI失败:", error); console.error("OneAPI失败:", error);
// apiStatus.one.completed = true;
apiStatus.one.completed = true;
apiStatus.one.error = error; apiStatus.one.error = error;
audioPreloadStatus.one.loaded = true; // audioPreloadStatus.one.loaded = true; //
// 使 // 使
// checkAndExecuteInOrder();
chatStore.messages.push({
class: "ing",
type: "ing",
flag: flag,
content: '工作流返回出错,请稍后重试',
})
checkAndExecuteInOrder();
} }
}; };
@ -1723,16 +1864,19 @@ watch(
checkAndExecuteInOrder(); checkAndExecuteInOrder();
} catch (error) { } catch (error) {
console.error("TwoAPI失败:", error); console.error("TwoAPI失败:", error);
// apiStatus.two.completed = true;
apiStatus.two.completed = true;
apiStatus.two.error = error; apiStatus.two.error = error;
audioPreloadStatus.two.loaded = true; audioPreloadStatus.two.loaded = true;
// checkAndExecuteInOrder();
checkAndExecuteInOrder();
} }
}; };
const handleThreeAPI = async () => { const handleThreeAPI = async () => {
try { try {
result23 = await dbqbSecondThreeAPI(params2); result23 = await dbqbSecondThreeAPI(params2);
// result23 = await dbqbSecondThreeAPI();
console.log("ThreeAPI成功返回:", result23); console.log("ThreeAPI成功返回:", result23);
apiStatus.three.completed = true; apiStatus.three.completed = true;
@ -1749,10 +1893,10 @@ watch(
checkAndExecuteInOrder(); checkAndExecuteInOrder();
} catch (error) { } catch (error) {
console.error("ThreeAPI失败:", error); console.error("ThreeAPI失败:", error);
// apiStatus.three.completed = true;
apiStatus.three.completed = true;
apiStatus.three.error = error; apiStatus.three.error = error;
audioPreloadStatus.three.loaded = true; audioPreloadStatus.three.loaded = true;
// checkAndExecuteInOrder();
checkAndExecuteInOrder();
} }
}; };
@ -1775,10 +1919,11 @@ watch(
checkAndExecuteInOrder(); checkAndExecuteInOrder();
} catch (error) { } catch (error) {
console.error("FourAPI失败:", error); console.error("FourAPI失败:", error);
// apiStatus.four.completed = true;
apiStatus.four.completed = true;
apiStatus.four.error = error; apiStatus.four.error = error;
audioPreloadStatus.four.loaded = true; audioPreloadStatus.four.loaded = true;
// checkAndExecuteInOrder();
checkAndExecuteInOrder();
} }
}; };
@ -1930,7 +2075,7 @@ watch(
// }); // });
// chatStore.setLoading(false); // chatStore.setLoading(false);
} finally { } finally {
chatStore.setLoading(false);
// chatStore.setLoading(false);
await chatStore.getUserCount(); await chatStore.getUserCount();
} }
} }
@ -2064,7 +2209,7 @@ function KlineCanvsEcharts(containerId) {
}, },
axisLabel: { axisLabel: {
show: true, show: true,
formatter: function (v) {},
formatter: function (v) { },
textStyle: { textStyle: {
color: "auto", color: "auto",
}, },
@ -2730,14 +2875,14 @@ function KlineCanvsEcharts(containerId) {
window.innerWidth > 1024 window.innerWidth > 1024
? "70vw" ? "70vw"
: window.innerWidth > 768 : window.innerWidth > 768
? "65vw"
: "55vw",
? "65vw"
: "55vw",
right: right:
window.innerWidth > 1024 window.innerWidth > 1024
? "40vw" ? "40vw"
: window.innerWidth > 768 : window.innerWidth > 768
? "30vw"
: "40vw",
? "30vw"
: "40vw",
top: window.innerWidth > 768 ? "8%" : "5%", top: window.innerWidth > 768 ? "8%" : "5%",
height: window.innerWidth > 768 ? "34%" : "34%", height: window.innerWidth > 768 ? "34%" : "34%",
containLabel: false, containLabel: false,
@ -2747,14 +2892,14 @@ function KlineCanvsEcharts(containerId) {
window.innerWidth > 1024 window.innerWidth > 1024
? "70vw" ? "70vw"
: window.innerWidth > 768 : window.innerWidth > 768
? "65vw"
: "55vw",
? "65vw"
: "55vw",
right: right:
window.innerWidth > 1024 window.innerWidth > 1024
? "40vw" ? "40vw"
: window.innerWidth > 768 : window.innerWidth > 768
? "30vw"
: "40vw",
? "30vw"
: "40vw",
top: window.innerWidth > 768 ? "45%" : "42%", top: window.innerWidth > 768 ? "45%" : "42%",
height: window.innerWidth > 768 ? "22%" : "22%", height: window.innerWidth > 768 ? "22%" : "22%",
containLabel: false, containLabel: false,
@ -2764,14 +2909,14 @@ function KlineCanvsEcharts(containerId) {
window.innerWidth > 1024 window.innerWidth > 1024
? "70vw" ? "70vw"
: window.innerWidth > 768 : window.innerWidth > 768
? "65vw"
: "55vw",
? "65vw"
: "55vw",
right: right:
window.innerWidth > 1024 window.innerWidth > 1024
? "40vw" ? "40vw"
: window.innerWidth > 768 : window.innerWidth > 768
? "30vw"
: "40vw",
? "30vw"
: "40vw",
top: window.innerWidth > 768 ? "73%" : "70%", top: window.innerWidth > 768 ? "73%" : "70%",
height: window.innerWidth > 768 ? "20%" : "22%", height: window.innerWidth > 768 ? "20%" : "22%",
containLabel: false, containLabel: false,
@ -3631,15 +3776,11 @@ onUnmounted(() => {
<img :src="logo2" alt="夺宝奇兵大模型logo" class="logo2" /> <img :src="logo2" alt="夺宝奇兵大模型logo" class="logo2" />
</div> </div>
<div
v-for="(msg, index) in chatMsg"
:key="index"
:class="{
'message-bubble': true,
[msg.sender]: msg.sender,
[msg.class]: msg.class,
}"
>
<div v-for="(msg, index) in chatMsg" :key="index" :class="{
'message-bubble': true,
[msg.sender]: msg.sender,
[msg.class]: msg.class,
}">
<div v-if="msg.type === 'kline'" class="kline-container"> <div v-if="msg.type === 'kline'" class="kline-container">
<div :id="'kline-container-' + index" class="chart-mount-point"> <div :id="'kline-container-' + index" class="chart-mount-point">
<div v-if="!msg.hasValidData" class="no-data-message"> <div v-if="!msg.hasValidData" class="no-data-message">
@ -3720,6 +3861,7 @@ onUnmounted(() => {
/* right: 30px; */ /* right: 30px; */
/* top: -30px; */ /* top: -30px; */
} }
.logo1 { .logo1 {
max-width: 350px; max-width: 350px;
min-width: 200px; min-width: 200px;
@ -3854,28 +3996,35 @@ onUnmounted(() => {
.dot:nth-child(1) { .dot:nth-child(1) {
animation-delay: 0s; animation-delay: 0s;
} }
.dot:nth-child(2) { .dot:nth-child(2) {
animation-delay: 0.2s; animation-delay: 0.2s;
} }
.dot:nth-child(3) { .dot:nth-child(3) {
animation-delay: 0.4s; animation-delay: 0.4s;
} }
.dot:nth-child(4) { .dot:nth-child(4) {
animation-delay: 0.6s; animation-delay: 0.6s;
} }
.dot:nth-child(5) { .dot:nth-child(5) {
animation-delay: 0.8s; animation-delay: 0.8s;
} }
.dot:nth-child(6) { .dot:nth-child(6) {
animation-delay: 1s; animation-delay: 1s;
} }
@keyframes loading { @keyframes loading {
0%, 0%,
60%, 60%,
100% { 100% {
opacity: 0.4; opacity: 0.4;
} }
30% { 30% {
opacity: 1; opacity: 1;
} }

3
src/views/homePage.vue

@ -174,7 +174,6 @@ const sendMessage = async () => {
ElMessage.warning("输入内容不能为空"); ElMessage.warning("输入内容不能为空");
return; return;
} }
isScrolling.value = false; isScrolling.value = false;
// AiEmotion // AiEmotion
@ -190,7 +189,7 @@ const sendMessage = async () => {
console.log(chatStore.isLoading, "isLoading.value1111"); console.log(chatStore.isLoading, "isLoading.value1111");
if (chatStore.isLoading) return; if (chatStore.isLoading) return;
chatStore.setLoading(true);
chatStore.isLoading=true;
console.log(chatStore.isLoading, "isLoading.value2222"); console.log(chatStore.isLoading, "isLoading.value2222");
const messageContent = message.value; const messageContent = message.value;

Loading…
Cancel
Save