Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-fe
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poc
poc-fe
Commits
ad2150ea
Commit
ad2150ea
authored
Apr 16, 2025
by
tyyin lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(首页): 消息列表滚动置底
parent
2bb401e2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
25 deletions
+58
-25
index.html
index.html
+1
-1
footer-operation.vue
src/views/home/components/footer-operation.vue
+7
-6
message-list.vue
src/views/home/components/message-list.vue
+48
-7
home.vue
src/views/home/home.vue
+2
-11
No files found.
index.html
View file @
ad2150ea
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
name=
"viewport"
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
content=
"width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
/>
<link
rel=
"stylesheet"
href=
"//at.alicdn.com/t/c/font_4711453_
j0r9s4e1cc9
.css"
/>
<link
rel=
"stylesheet"
href=
"//at.alicdn.com/t/c/font_4711453_
t9t0ftzqft
.css"
/>
<link
<link
rel=
"preload"
rel=
"preload"
href=
"https://gsst-poe-sit.gz.bcebos.com/front/SourceHanSansCN-Medium.otf"
href=
"https://gsst-poe-sit.gz.bcebos.com/front/SourceHanSansCN-Medium.otf"
...
...
src/views/home/components/footer-operation.vue
View file @
ad2150ea
...
@@ -19,6 +19,7 @@ import type { SelectRenderLabel, SelectRenderTag } from 'naive-ui'
...
@@ -19,6 +19,7 @@ import type { SelectRenderLabel, SelectRenderTag } from 'naive-ui'
interface
Props
{
interface
Props
{
currentSessionId
:
string
currentSessionId
:
string
messageListLength
:
number
messageListLength
:
number
isNotShowBackBottomBtn
:
boolean
|
undefined
}
}
const
props
=
defineProps
<
Props
>
()
const
props
=
defineProps
<
Props
>
()
...
@@ -87,7 +88,7 @@ const messageListScrollToBottomThrottle = throttle(
...
@@ -87,7 +88,7 @@ const messageListScrollToBottomThrottle = throttle(
()
=>
{
()
=>
{
emit
(
'messageListScrollToBottom'
)
emit
(
'messageListScrollToBottom'
)
},
},
5
00
,
1
00
,
{
leading
:
true
,
trailing
:
true
},
{
leading
:
true
,
trailing
:
true
},
)
)
...
@@ -203,7 +204,7 @@ function questionSubmit() {
...
@@ -203,7 +204,7 @@ function questionSubmit() {
reasoningContent
:
reasoningContent
,
reasoningContent
:
reasoningContent
,
})
})
messageListScrollToBottomThrottle
()
props
.
isNotShowBackBottomBtn
&&
messageListScrollToBottomThrottle
()
}
}
// 回复消息
// 回复消息
...
@@ -214,7 +215,7 @@ function questionSubmit() {
...
@@ -214,7 +215,7 @@ function questionSubmit() {
content
:
messageContent
,
content
:
messageContent
,
})
})
messageListScrollToBottomThrottle
()
props
.
isNotShowBackBottomBtn
&&
messageListScrollToBottomThrottle
()
}
}
// 插件
// 插件
...
@@ -223,7 +224,7 @@ function questionSubmit() {
...
@@ -223,7 +224,7 @@ function questionSubmit() {
pluginName
:
data
.
function
.
name
,
pluginName
:
data
.
function
.
name
,
})
})
messageListScrollToBottomThrottle
()
props
.
isNotShowBackBottomBtn
&&
messageListScrollToBottomThrottle
()
}
}
},
},
onend
:
()
=>
{
onend
:
()
=>
{
...
@@ -232,8 +233,8 @@ function questionSubmit() {
...
@@ -232,8 +233,8 @@ function questionSubmit() {
isAnswerLoading
:
false
,
isAnswerLoading
:
false
,
})
})
messageListScrollToBottomThrottle
()
props
.
isNotShowBackBottomBtn
&&
messageListScrollToBottomThrottle
()
},
5
00
)
},
1
00
)
},
},
onclose
:
()
=>
{
onclose
:
()
=>
{
isAgentResponding
.
value
=
false
isAgentResponding
.
value
=
false
...
...
src/views/home/components/message-list.vue
View file @
ad2150ea
...
@@ -4,6 +4,8 @@ import type { MessageItemInterface } from '../types'
...
@@ -4,6 +4,8 @@ import type { MessageItemInterface } from '../types'
import
{
ref
,
useTemplateRef
}
from
'vue'
import
{
ref
,
useTemplateRef
}
from
'vue'
import
{
ScrollbarInst
}
from
'naive-ui'
import
{
ScrollbarInst
}
from
'naive-ui'
import
EditorDrawer
from
'@/components/editor-drawer/editor-drawer.vue'
import
EditorDrawer
from
'@/components/editor-drawer/editor-drawer.vue'
import
{
useElementVisibility
}
from
'@vueuse/core'
import
{
throttle
}
from
'lodash-es'
interface
Props
{
interface
Props
{
messageList
:
Map
<
string
,
MessageItemInterface
>
messageList
:
Map
<
string
,
MessageItemInterface
>
...
@@ -11,11 +13,10 @@ interface Props {
...
@@ -11,11 +13,10 @@ interface Props {
defineProps
<
Props
>
()
defineProps
<
Props
>
()
defineExpose
({
scrollToBottom
,
})
const
scrollbarRef
=
useTemplateRef
<
ScrollbarInst
|
null
>
(
'scrollbarRef'
)
const
scrollbarRef
=
useTemplateRef
<
ScrollbarInst
|
null
>
(
'scrollbarRef'
)
const
backBottomBtnFlagRef
=
useTemplateRef
<
HTMLDivElement
|
null
>
(
'backBottomBtnFlagRef'
)
const
isNotShowBackBottomBtn
=
useElementVisibility
(
backBottomBtnFlagRef
)
const
isShowEditorDrawer
=
ref
(
false
)
const
isShowEditorDrawer
=
ref
(
false
)
const
contentEdit
=
ref
(
''
)
const
contentEdit
=
ref
(
''
)
...
@@ -31,21 +32,61 @@ function onContentedit(content: string) {
...
@@ -31,21 +32,61 @@ function onContentedit(content: string) {
isShowEditorDrawer
.
value
=
true
isShowEditorDrawer
.
value
=
true
}
}
const
handleBackBottom
=
throttle
(()
=>
{
scrollToBottom
()
},
500
)
defineExpose
({
scrollToBottom
,
isNotShowBackBottomBtn
,
})
</
script
>
</
script
>
<
template
>
<
template
>
<div
class=
"flex-1 overflow-hidden overflow-y-auto py-[20px]"
>
<div
class=
"
relative
flex-1 overflow-hidden overflow-y-auto py-[20px]"
>
<n-scrollbar
ref=
"scrollbarRef"
>
<n-scrollbar
ref=
"scrollbarRef"
content-class=
"content-class"
>
<div
class=
"mx-auto w-[750px] pr-[10px]"
>
<div
class=
"
relative
mx-auto w-[750px] pr-[10px]"
>
<MessageItem
<MessageItem
v-for=
"[key, messageItem] in messageList"
v-for=
"[key, messageItem] in messageList"
:key=
"key"
:key=
"key"
:message-item=
"messageItem"
:message-item=
"messageItem"
@
contentedit=
"onContentedit"
@
contentedit=
"onContentedit"
/>
/>
<div
ref=
"backBottomBtnFlagRef"
class=
"-z-1 absolute bottom-0 h-[40px] w-full"
></div>
</div>
</div>
</n-scrollbar>
</n-scrollbar>
<Transition
name=
"back-bottom-btn"
mode=
"out-in"
>
<div
v-show=
"!isNotShowBackBottomBtn"
class=
"absolute bottom-[30px] left-1/2 w-[750px] text-end"
style=
"translate: calc(-50% + 30px)"
>
<button
class=
"flex-center flex-center inline-flex h-[26px] w-[26px] rounded-full bg-[#ECEFFF]"
@
click=
"handleBackBottom"
>
<i
class=
"iconfont icon-huidaodibu text-[12px]"
/>
</button>
</div>
</Transition>
<EditorDrawer
v-model:is-show-editor-drawer=
"isShowEditorDrawer"
v-model:content-edit=
"contentEdit"
/>
<EditorDrawer
v-model:is-show-editor-drawer=
"isShowEditorDrawer"
v-model:content-edit=
"contentEdit"
/>
</div>
</div>
</
template
>
</
template
>
<
style
lang=
"scss"
scoped
>
.back-bottom-btn-enter-active
,
.back-bottom-btn-leave-active
{
transition-timing-function
:
ease-in-out
;
transition-duration
:
0
.2s
;
transition-property
:
opacity
;
}
.back-bottom-btn-enter-from
,
.back-bottom-btn-leave-to
{
opacity
:
0
;
}
</
style
>
src/views/home/home.vue
View file @
ad2150ea
<
script
setup
lang=
"ts"
>
<
script
setup
lang=
"ts"
>
import
{
onMounted
,
ref
,
useTemplateRef
,
watch
}
from
'vue'
import
{
ref
,
useTemplateRef
,
watch
}
from
'vue'
import
AgentAbout
from
'./components/agent-about.vue'
import
AgentAbout
from
'./components/agent-about.vue'
import
FooterOperation
from
'./components/footer-operation.vue'
import
FooterOperation
from
'./components/footer-operation.vue'
import
HistoryMenuSidebar
from
'./components/history-menu-sidebar.vue'
import
HistoryMenuSidebar
from
'./components/history-menu-sidebar.vue'
...
@@ -92,12 +92,6 @@ watch(
...
@@ -92,12 +92,6 @@ watch(
createSessionId
()
createSessionId
()
})()
})()
onMounted
(()
=>
{
setTimeout
(()
=>
{
messageListScrollToBottom
()
},
700
)
})
function
createSessionId
()
{
function
createSessionId
()
{
fetchCreateSessionId
<
string
>
().
then
((
res
)
=>
{
fetchCreateSessionId
<
string
>
().
then
((
res
)
=>
{
currentSessionId
.
value
=
res
.
data
currentSessionId
.
value
=
res
.
data
...
@@ -192,10 +186,6 @@ function onGetMessageRecordList(recordId: string) {
...
@@ -192,10 +186,6 @@ function onGetMessageRecordList(recordId: string) {
})
})
messageList
.
value
=
new
Map
(
messageListDraft
as
any
)
messageList
.
value
=
new
Map
(
messageListDraft
as
any
)
setTimeout
(()
=>
{
messageListScrollToBottom
()
},
500
)
}
}
})
})
.
catch
(()
=>
{
.
catch
(()
=>
{
...
@@ -234,6 +224,7 @@ function onClearSessionReferenceFile() {
...
@@ -234,6 +224,7 @@ function onClearSessionReferenceFile() {
v-model:current-fetch-event-source-controller=
"currentFetchEventSourceController"
v-model:current-fetch-event-source-controller=
"currentFetchEventSourceController"
:current-session-id=
"currentSessionId"
:current-session-id=
"currentSessionId"
:message-list-length=
"messageList.size"
:message-list-length=
"messageList.size"
:is-not-show-back-bottom-btn=
"messageListRef?.isNotShowBackBottomBtn"
@
message-list-scroll-to-bottom=
"messageListScrollToBottom"
@
message-list-scroll-to-bottom=
"messageListScrollToBottom"
@
add-message-item=
"onAddMessageItem"
@
add-message-item=
"onAddMessageItem"
@
update-specify-message-item=
"onUpdateSpecifyMessageItem"
@
update-specify-message-item=
"onUpdateSpecifyMessageItem"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment