|
129 | 129 | <div v-else-if="computedMessages.length == 0 && loading" class="welcome-content-block"> |
130 | 130 | <logo /> |
131 | 131 | </div> |
132 | | - <el-scrollbar v-if="computedMessages.length > 0" ref="chatListRef" class="no-horizontal"> |
| 132 | + <el-scrollbar |
| 133 | + v-if="computedMessages.length > 0" |
| 134 | + ref="chatListRef" |
| 135 | + class="no-horizontal" |
| 136 | + @scroll="handleScroll" |
| 137 | + > |
133 | 138 | <div |
| 139 | + ref="innerRef" |
134 | 140 | class="chat-scroll" |
135 | 141 | :class="{ 'no-sidebar': !isAssistant && !chatListSideBarShow, pad16: isAssistant }" |
136 | 142 | > |
@@ -391,6 +397,7 @@ const { t } = useI18n() |
391 | 397 | const inputMessage = ref('') |
392 | 398 |
|
393 | 399 | const chatListRef = ref() |
| 400 | +const innerRef = ref() |
394 | 401 | const chatCreatorRef = ref() |
395 | 402 |
|
396 | 403 | function scrollToBottom() { |
@@ -444,6 +451,47 @@ const goEmpty = (func?: (...p: any[]) => void, ...param: any[]) => { |
444 | 451 | stop(func, ...param) |
445 | 452 | } |
446 | 453 |
|
| 454 | +let scrollTime: any |
| 455 | +let scrollingTime: any |
| 456 | +let scrollTopVal = 0 |
| 457 | +let scrolling = false |
| 458 | +const scrollBottom = () => { |
| 459 | + if (scrolling) return |
| 460 | + if (!isTyping.value) { |
| 461 | + clearInterval(scrollTime) |
| 462 | + } |
| 463 | + chatListRef.value!.setScrollTop(innerRef.value!.clientHeight) |
| 464 | +} |
| 465 | +
|
| 466 | +const handleScroll = (val: any) => { |
| 467 | + scrollTopVal = val.scrollTop |
| 468 | + scrolling = true |
| 469 | + clearTimeout(scrollingTime) |
| 470 | + scrollingTime = setTimeout(() => { |
| 471 | + scrolling = false |
| 472 | + }, 400) |
| 473 | + if ( |
| 474 | + scrollTopVal + 200 < |
| 475 | + innerRef.value!.clientHeight - (document.querySelector('.chat-record-list')!.clientHeight - 20) |
| 476 | + ) { |
| 477 | + clearInterval(scrollTime) |
| 478 | + scrollTime = null |
| 479 | + return |
| 480 | + } |
| 481 | +
|
| 482 | + if ( |
| 483 | + !scrollTime && |
| 484 | + isTyping.value && |
| 485 | + scrollTopVal + 30 < |
| 486 | + innerRef.value!.clientHeight - |
| 487 | + (document.querySelector('.chat-record-list')!.clientHeight - 20) |
| 488 | + ) { |
| 489 | + scrollTime = setInterval(() => { |
| 490 | + scrollBottom() |
| 491 | + }, 300) |
| 492 | + } |
| 493 | +} |
| 494 | +
|
447 | 495 | const createNewChatSimple = async () => { |
448 | 496 | currentChat.value = new ChatInfo() |
449 | 497 | currentChatId.value = undefined |
@@ -615,6 +663,10 @@ const sendMessage = async ($event: any = {}) => { |
615 | 663 |
|
616 | 664 | loading.value = true |
617 | 665 | isTyping.value = true |
| 666 | + scrollTopVal = innerRef.value!.clientHeight |
| 667 | + scrollTime = setInterval(() => { |
| 668 | + scrollBottom() |
| 669 | + }, 300) |
618 | 670 | await assistantPrepareSend() |
619 | 671 | const currentRecord = new ChatRecord() |
620 | 672 | currentRecord.create_time = new Date() |
@@ -1164,7 +1216,7 @@ onMounted(() => { |
1164 | 1216 | --ed-button-hover-bg-color: var(--ed-color-primary-1a, #1cba901a); |
1165 | 1217 | --ed-button-border-color: rgba(217, 220, 223, 1); |
1166 | 1218 | --ed-button-hover-border-color: var(--ed-color-primary, rgba(28, 186, 144, 1)); |
1167 | | - --ed-button-active-bg-color: rgba(28, 186, 144, 0.2); |
| 1219 | + --ed-button-active-bg-color: var(--ed-color-primary-33, #1cba9033); |
1168 | 1220 | --ed-button-active-border-color: var(--ed-color-primary, rgba(28, 186, 144, 1)); |
1169 | 1221 | } |
1170 | 1222 | } |
|
0 commit comments