Skip to content

Commit 13a7f42

Browse files
committed
fix(chat): In the blue theme, the click status color value is incorrect
1 parent 314b83c commit 13a7f42

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

frontend/src/views/chat/index.vue

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,14 @@
129129
<div v-else-if="computedMessages.length == 0 && loading" class="welcome-content-block">
130130
<logo />
131131
</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+
>
133138
<div
139+
ref="innerRef"
134140
class="chat-scroll"
135141
:class="{ 'no-sidebar': !isAssistant && !chatListSideBarShow, pad16: isAssistant }"
136142
>
@@ -391,6 +397,7 @@ const { t } = useI18n()
391397
const inputMessage = ref('')
392398
393399
const chatListRef = ref()
400+
const innerRef = ref()
394401
const chatCreatorRef = ref()
395402
396403
function scrollToBottom() {
@@ -444,6 +451,47 @@ const goEmpty = (func?: (...p: any[]) => void, ...param: any[]) => {
444451
stop(func, ...param)
445452
}
446453
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+
447495
const createNewChatSimple = async () => {
448496
currentChat.value = new ChatInfo()
449497
currentChatId.value = undefined
@@ -615,6 +663,10 @@ const sendMessage = async ($event: any = {}) => {
615663
616664
loading.value = true
617665
isTyping.value = true
666+
scrollTopVal = innerRef.value!.clientHeight
667+
scrollTime = setInterval(() => {
668+
scrollBottom()
669+
}, 300)
618670
await assistantPrepareSend()
619671
const currentRecord = new ChatRecord()
620672
currentRecord.create_time = new Date()
@@ -1164,7 +1216,7 @@ onMounted(() => {
11641216
--ed-button-hover-bg-color: var(--ed-color-primary-1a, #1cba901a);
11651217
--ed-button-border-color: rgba(217, 220, 223, 1);
11661218
--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);
11681220
--ed-button-active-border-color: var(--ed-color-primary, rgba(28, 186, 144, 1));
11691221
}
11701222
}

0 commit comments

Comments
 (0)