fix: 对话发送延迟问题

This commit is contained in:
shaohuzhang1 2024-02-23 11:53:53 +08:00
parent b7a406db56
commit 58a88bb56d

View File

@ -390,34 +390,35 @@ const getWrite = (chat: any, reader: any, stream: boolean) => {
return stream ? write_stream : write_json return stream ? write_stream : write_json
} }
function chatMessage() { function chatMessage(chat?: any) {
loading.value = true loading.value = true
if (!chartOpenId.value) { if (!chartOpenId.value) {
getChartOpenId() getChartOpenId()
} else { } else {
const problem_text = inputValue.value if (!chat) {
const chat = reactive({ chat = reactive({
id: randomId(), id: randomId(),
problem_text: problem_text, problem_text: inputValue.value,
answer_text: '', answer_text: '',
buffer: [], buffer: [],
write_ed: false, write_ed: false,
is_stop: false, is_stop: false,
record_id: '', record_id: '',
vote_status: '-1' vote_status: '-1'
}) })
chatList.value.push(chat)
inputValue.value = ''
}
// //
applicationApi applicationApi
.postChatMessage(chartOpenId.value, problem_text) .postChatMessage(chartOpenId.value, chat.problem_text)
.then((response) => { .then((response) => {
console.log(response.status) console.log(response.status)
if (response.status === 401) { if (response.status === 401) {
application.asyncAppAuthentication(accessToken).then(() => { application.asyncAppAuthentication(accessToken).then(() => {
chatMessage() chatMessage(chat)
}) })
} else { } else {
chatList.value.push(chat)
inputValue.value = ''
nextTick(() => { nextTick(() => {
// //
scrollDiv.value.setScrollTop(Number.MAX_SAFE_INTEGER) scrollDiv.value.setScrollTop(Number.MAX_SAFE_INTEGER)
@ -475,7 +476,7 @@ const handleScrollTop = ($event: any) => {
scrollTop.value = $event.scrollTop scrollTop.value = $event.scrollTop
if ( if (
dialogScrollbar.value.scrollHeight - (scrollTop.value + scrollDiv.value.wrapRef.offsetHeight) <= dialogScrollbar.value.scrollHeight - (scrollTop.value + scrollDiv.value.wrapRef.offsetHeight) <=
10 20
) { ) {
scorll.value = true scorll.value = true
} else { } else {