Skip to content

Commit 3693950

Browse files
committed
fix(Application Management): Simple applications, advanced applications, embedded assistants, and full-screen mode answers do not scroll
1 parent dab2bb4 commit 3693950

File tree

3 files changed

+35
-21
lines changed

3 files changed

+35
-21
lines changed

frontend/src/views/chat/answer/ChartAnswer.vue

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const emits = defineEmits([
2525
'finish',
2626
'error',
2727
'stop',
28+
'scrollBottom',
2829
'update:loading',
2930
'update:chatList',
3031
'update:currentChat',
@@ -215,13 +216,18 @@ const sendMessage = async () => {
215216
}
216217
217218
function getChatData(recordId?: number) {
218-
chatApi.get_chart_data(recordId).then((response) => {
219-
_currentChat.value.records.forEach((record) => {
220-
if (record.id === recordId) {
221-
record.data = response
222-
}
219+
chatApi
220+
.get_chart_data(recordId)
221+
.then((response) => {
222+
_currentChat.value.records.forEach((record) => {
223+
if (record.id === recordId) {
224+
record.data = response
225+
}
226+
})
227+
})
228+
.finally(() => {
229+
emits('scrollBottom')
223230
})
224-
})
225231
}
226232
function stop() {
227233
stopFlag.value = true

frontend/src/views/chat/answer/PredictAnswer.vue

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const props = withDefaults(
2424
const emits = defineEmits([
2525
'finish',
2626
'error',
27+
'scrollBottom',
2728
'stop',
2829
'update:loading',
2930
'update:chatList',
@@ -215,14 +216,19 @@ function getChatPredictData(recordId?: number) {
215216
}
216217
217218
function getChatData(recordId?: number) {
218-
chatApi.get_chart_data(recordId).then((response) => {
219-
_currentChat.value.records.forEach((record) => {
220-
if (record.id === recordId) {
221-
record.data = response
222-
console.log(record.data)
223-
}
219+
chatApi
220+
.get_chart_data(recordId)
221+
.then((response) => {
222+
_currentChat.value.records.forEach((record) => {
223+
if (record.id === recordId) {
224+
record.data = response
225+
console.log(record.data)
226+
}
227+
})
228+
})
229+
.finally(() => {
230+
emits('scrollBottom')
224231
})
225-
})
226232
}
227233
228234
function stop() {

frontend/src/views/chat/index.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@
216216
:current-chat-id="currentChatId"
217217
:loading="isTyping"
218218
:message="message"
219+
@scrollBottom="scrollToBottom"
219220
:reasoning-name="['sql_answer', 'chart_answer']"
220221
@finish="onChartAnswerFinish"
221222
@error="onChartAnswerError"
@@ -327,6 +328,7 @@
327328
:current-chat-id="currentChatId"
328329
:loading="isTyping"
329330
:message="message"
331+
@scrollBottom="scrollToBottom"
330332
@finish="onPredictAnswerFinish"
331333
@error="onPredictAnswerError"
332334
@stop="onChatStop"
@@ -421,6 +423,8 @@ import icon_send_filled from '@/assets/svg/icon_send_filled.svg'
421423
import { useAssistantStore } from '@/stores/assistant'
422424
import { onClickOutside } from '@vueuse/core'
423425
import { useUserStore } from '@/stores/user'
426+
import { debounce } from 'lodash-es'
427+
424428
import router from '@/router'
425429
const userStore = useUserStore()
426430
const props = defineProps<{
@@ -454,14 +458,14 @@ const chatListRef = ref()
454458
const innerRef = ref()
455459
const chatCreatorRef = ref()
456460
457-
function scrollToBottom() {
461+
const scrollToBottom = debounce(() => {
458462
nextTick(() => {
459463
chatListRef.value?.scrollTo({
460464
top: chatListRef.value.wrapRef.scrollHeight,
461465
behavior: 'smooth',
462466
})
463467
})
464-
}
468+
}, 300)
465469
466470
const loading = ref<boolean>(false)
467471
const chatList = ref<Array<ChatInfo>>([])
@@ -726,12 +730,10 @@ const sendMessage = async ($event: any = {}) => {
726730
727731
loading.value = true
728732
isTyping.value = true
729-
if (isCompletePage.value) {
730-
scrollTopVal = innerRef.value!.clientHeight
731-
scrollTime = setInterval(() => {
732-
scrollBottom()
733-
}, 300)
734-
}
733+
scrollTopVal = innerRef.value!.clientHeight
734+
scrollTime = setInterval(() => {
735+
scrollBottom()
736+
}, 300)
735737
await assistantPrepareSend()
736738
const currentRecord = new ChatRecord()
737739
currentRecord.create_time = new Date()

0 commit comments

Comments
 (0)