feat: 优化发送消息的中断重连问题
This commit is contained in:
@@ -581,18 +581,19 @@ const sendChat = (message, isInstruct = false) => {
|
||||
initWebSocket();
|
||||
// 短暂延迟后再次检查连接状态
|
||||
setTimeout(() => {
|
||||
if (webSocketManager && webSocketManager.isConnected()) {
|
||||
const connected = webSocketManager && webSocketManager.isConnected();
|
||||
isSessionActive.value = connected;
|
||||
// 更新AI消息状态
|
||||
const aiMsgIndex = chatMsgList.value.length - 1;
|
||||
if (aiMsgIndex >= 0 && chatMsgList.value[aiMsgIndex].msgType === MessageRole.AI) {
|
||||
chatMsgList.value[aiMsgIndex].msg = connected ? "" : "发送消息失败,请重试";
|
||||
chatMsgList.value[aiMsgIndex].isLoading = connected;
|
||||
}
|
||||
if (connected) {
|
||||
// 连接成功后重新发送消息
|
||||
sendChat(message, isInstruct);
|
||||
} else {
|
||||
console.error("WebSocket重新初始化失败");
|
||||
isSessionActive.value = false;
|
||||
// 更新AI消息状态为失败
|
||||
const aiMsgIndex = chatMsgList.value.length - 1;
|
||||
if (aiMsgIndex >= 0 && chatMsgList.value[aiMsgIndex].msgType === MessageRole.AI) {
|
||||
chatMsgList.value[aiMsgIndex].msg = "发送消息失败,请重试";
|
||||
chatMsgList.value[aiMsgIndex].isLoading = false;
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user