|
@@ -743,6 +743,7 @@
|
|
|
console.error('提交答案失败:', error);
|
|
console.error('提交答案失败:', error);
|
|
|
message.error('提交失败,请重试');
|
|
message.error('提交失败,请重试');
|
|
|
lastMsg.isLoading = false;
|
|
lastMsg.isLoading = false;
|
|
|
|
|
+ lastMsg.durationMs = (lastMsg.baseDurationMs || 0) + (lastMsg.generateStartTime ? Date.now() - lastMsg.generateStartTime : 0);
|
|
|
if (!lastMsg.content) {
|
|
if (!lastMsg.content) {
|
|
|
lastMsg.content = '抱歉,提交请求失败,请稍后重试。';
|
|
lastMsg.content = '抱歉,提交请求失败,请稍后重试。';
|
|
|
}
|
|
}
|
|
@@ -772,6 +773,8 @@
|
|
|
const lastMsg = taskMessages[taskMessages.length - 1];
|
|
const lastMsg = taskMessages[taskMessages.length - 1];
|
|
|
if (!lastMsg || !lastMsg.isPendingApproval) return;
|
|
if (!lastMsg || !lastMsg.isPendingApproval) return;
|
|
|
|
|
|
|
|
|
|
+ // 冻结累计耗时到 durationMs,避免取消后计时消失
|
|
|
|
|
+ lastMsg.durationMs = (lastMsg.baseDurationMs || 0) + (lastMsg.generateStartTime ? Date.now() - lastMsg.generateStartTime : 0);
|
|
|
lastMsg.isPendingApproval = false;
|
|
lastMsg.isPendingApproval = false;
|
|
|
lastMsg.pendingApprovalData = undefined;
|
|
lastMsg.pendingApprovalData = undefined;
|
|
|
lastMsg.isLoading = false;
|
|
lastMsg.isLoading = false;
|
|
@@ -1110,7 +1113,7 @@
|
|
|
currentTask.messages = [...messages.value];
|
|
currentTask.messages = [...messages.value];
|
|
|
}
|
|
}
|
|
|
} finally {
|
|
} finally {
|
|
|
- await scrollToBottom();
|
|
|
|
|
|
|
+ await scrollToBottom(true);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -1450,7 +1453,8 @@
|
|
|
createdAt: now.toISOString(),
|
|
createdAt: now.toISOString(),
|
|
|
};
|
|
};
|
|
|
messages.value.push(userMsg);
|
|
messages.value.push(userMsg);
|
|
|
- await scrollToBottom();
|
|
|
|
|
|
|
+ await nextTick();
|
|
|
|
|
+ chatMessagesRef.value?.forceScrollToBottom();
|
|
|
|
|
|
|
|
const aiMsgIndex = messages.value.length;
|
|
const aiMsgIndex = messages.value.length;
|
|
|
const aiMsg: Message = {
|
|
const aiMsg: Message = {
|
|
@@ -1558,7 +1562,8 @@
|
|
|
attachedFile: file,
|
|
attachedFile: file,
|
|
|
};
|
|
};
|
|
|
messages.value.push(userMsg);
|
|
messages.value.push(userMsg);
|
|
|
- await scrollToBottom();
|
|
|
|
|
|
|
+ await nextTick();
|
|
|
|
|
+ chatMessagesRef.value?.forceScrollToBottom();
|
|
|
|
|
|
|
|
const aiMsgIndex = messages.value.length;
|
|
const aiMsgIndex = messages.value.length;
|
|
|
const aiMsg: Message = {
|
|
const aiMsg: Message = {
|
|
@@ -1653,12 +1658,12 @@
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const scrollToBottom = async () => {
|
|
|
|
|
|
|
+ const scrollToBottom = async (force = false) => {
|
|
|
await nextTick();
|
|
await nextTick();
|
|
|
- if (!chatMessagesRef.value?.isAtBottom) return;
|
|
|
|
|
|
|
+ if (!force && !chatMessagesRef.value?.isAtBottom) return;
|
|
|
const el = chatMessagesRef.value?.messagesRef;
|
|
const el = chatMessagesRef.value?.messagesRef;
|
|
|
if (el) {
|
|
if (el) {
|
|
|
- el.scrollTop = el.scrollHeight;
|
|
|
|
|
|
|
+ el.scrollTop = el.scrollHeight - el.clientHeight;
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|