Browse Source

报错中断

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

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()
// })
initData();
// initData();
return {
// brainDataList,

213
src/views/AIchat.vue

@ -420,6 +420,36 @@ const createTypingEffect = (message, content, speed) => {
const processNextElement = () => {
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;
nextTick(() => {
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
setTimeout(() => {
resolve();
}, 1000);
} 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
setTimeout(() => {
resolve();
@ -532,6 +616,8 @@ const createTypingEffect = (message, content, speed) => {
});
};
let apiStatus = {}
//
const processTypingQueue = async () => {
if (isTypingInProgress.value || typingQueue.value.length === 0) {
@ -638,10 +724,17 @@ watch(
content: aiContent,
});
chatStore.setLoading(false);
chatStore.isLoading = false;
}
} catch (e) {
console.log(e, "意图识别失败");
chatStore.messages.push({
class: "ing",
type: "ing",
flag: false,
content: '工作流返回出错,请稍后重试',
})
chatStore.isLoading = false;
}
if (flag) {
@ -685,6 +778,8 @@ watch(
marketList: userStore.aiGoldMarketList,
});
const HomePage = result20.data.HomePage;
const AIGoldBull = result20.data.AIGoldBull;
@ -695,11 +790,11 @@ watch(
let result23;
let result24;
// 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 },
};
//
@ -1033,8 +1128,8 @@ watch(
const checkAndExecuteInOrder = () => {
// OneAPI -
if (canStartFirstOutput() && !apiStatus.one.executed) {
apiStatus.one.executed = true;
if (apiStatus.one.result) {
apiStatus.one.executed = true;
console.log("执行OneAPI代码(文本和音频同步开始):", apiStatus.one.result);
// API1
@ -1234,6 +1329,8 @@ watch(
messageId: klineMessageId2,
hasValidData: true, // hasValidData
klineType: 2,
error: apiStatus.two.error ? '2' : '',
isEnd: '1',
},
"",
50
@ -1270,6 +1367,14 @@ watch(
// console.warn("K线");
// }
// });
} else {
chatStore.messages.push({
class: "ing",
type: "ing",
flag: false,
content: '工作流返回出错,请稍后重试',
})
chatStore.isLoading = false;
}
}
@ -1279,8 +1384,9 @@ watch(
apiStatus.two.completed &&
!apiStatus.two.executed
) {
apiStatus.two.executed = true;
if (apiStatus.two.result) {
apiStatus.two.executed = true;
console.log("执行TwoAPI代码:", apiStatus.two.result);
// API2
@ -1328,6 +1434,8 @@ watch(
type: "content3",
content: "",
isTyping: true,
error: apiStatus.three.error ? '3' : '',
isEnd: '2'
});
// chatStore.messages.push(aiMessage2);
@ -1349,6 +1457,18 @@ watch(
// type: "content3",
// 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,8 +1478,9 @@ watch(
apiStatus.three.completed &&
!apiStatus.three.executed
) {
apiStatus.three.executed = true;
if (apiStatus.three.result) {
apiStatus.three.executed = true;
console.log("执行ThreeAPI代码:", apiStatus.three.result);
// API3
@ -1488,6 +1609,8 @@ watch(
type: "content3",
content: "",
isTyping: true,
error: apiStatus.four.error ? '4' : '',
isEnd: '3'
});
// chatStore.messages.push(aiMessage4);
@ -1514,6 +1637,17 @@ watch(
// type: "content3",
// 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,8 +1657,9 @@ watch(
apiStatus.four.completed &&
!apiStatus.four.executed
) {
apiStatus.four.executed = true;
if (apiStatus.four.result) {
apiStatus.four.executed = true;
console.log("执行FourAPI代码:", apiStatus.four.result);
// API4
@ -1607,6 +1742,7 @@ watch(
type: "mianze",
content: "",
isTyping: true,
end: true
});
// chatStore.messages.push(aiMessage6);
@ -1622,13 +1758,24 @@ watch(
// }
// }, 50); // 50ms/
addTypingTask(aiMessage6, ["", ac6], 210);
// chatStore.isLoading = false;
// chatStore.messages.push({
// sender: "ai",
// class: "mianze",
// type: "mianze",
// 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();
} catch (error) {
console.error("OneAPI失败:", error);
// apiStatus.one.completed = true;
apiStatus.one.completed = true;
apiStatus.one.error = error;
audioPreloadStatus.one.loaded = true; //
// 使
// checkAndExecuteInOrder();
chatStore.messages.push({
class: "ing",
type: "ing",
flag: flag,
content: '工作流返回出错,请稍后重试',
})
checkAndExecuteInOrder();
}
};
@ -1723,16 +1864,19 @@ watch(
checkAndExecuteInOrder();
} catch (error) {
console.error("TwoAPI失败:", error);
// apiStatus.two.completed = true;
apiStatus.two.completed = true;
apiStatus.two.error = error;
audioPreloadStatus.two.loaded = true;
// checkAndExecuteInOrder();
checkAndExecuteInOrder();
}
};
const handleThreeAPI = async () => {
try {
result23 = await dbqbSecondThreeAPI(params2);
// result23 = await dbqbSecondThreeAPI();
console.log("ThreeAPI成功返回:", result23);
apiStatus.three.completed = true;
@ -1749,10 +1893,10 @@ watch(
checkAndExecuteInOrder();
} catch (error) {
console.error("ThreeAPI失败:", error);
// apiStatus.three.completed = true;
apiStatus.three.completed = true;
apiStatus.three.error = error;
audioPreloadStatus.three.loaded = true;
// checkAndExecuteInOrder();
checkAndExecuteInOrder();
}
};
@ -1775,10 +1919,11 @@ watch(
checkAndExecuteInOrder();
} catch (error) {
console.error("FourAPI失败:", error);
// apiStatus.four.completed = true;
apiStatus.four.completed = true;
apiStatus.four.error = error;
audioPreloadStatus.four.loaded = true;
// checkAndExecuteInOrder();
checkAndExecuteInOrder();
}
};
@ -1930,7 +2075,7 @@ watch(
// });
// chatStore.setLoading(false);
} finally {
chatStore.setLoading(false);
// chatStore.setLoading(false);
await chatStore.getUserCount();
}
}
@ -3631,15 +3776,11 @@ onUnmounted(() => {
<img :src="logo2" alt="夺宝奇兵大模型logo" class="logo2" />
</div>
<div
v-for="(msg, index) in chatMsg"
:key="index"
: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 :id="'kline-container-' + index" class="chart-mount-point">
<div v-if="!msg.hasValidData" class="no-data-message">
@ -3720,6 +3861,7 @@ onUnmounted(() => {
/* right: 30px; */
/* top: -30px; */
}
.logo1 {
max-width: 350px;
min-width: 200px;
@ -3854,28 +3996,35 @@ onUnmounted(() => {
.dot:nth-child(1) {
animation-delay: 0s;
}
.dot:nth-child(2) {
animation-delay: 0.2s;
}
.dot:nth-child(3) {
animation-delay: 0.4s;
}
.dot:nth-child(4) {
animation-delay: 0.6s;
}
.dot:nth-child(5) {
animation-delay: 0.8s;
}
.dot:nth-child(6) {
animation-delay: 1s;
}
@keyframes loading {
0%,
60%,
100% {
opacity: 0.4;
}
30% {
opacity: 1;
}

3
src/views/homePage.vue

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

Loading…
Cancel
Save