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
e1e55d9f
Commit
e1e55d9f
authored
Nov 01, 2024
by
tyyin lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore(首页): 消息头像名称动态展示
parent
d57e9fa0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
10 deletions
+43
-10
footer-operation.vue
src/views/home/components/footer-operation.vue
+7
-0
message-item.vue
src/views/home/components/message-item.vue
+11
-7
home.vue
src/views/home/home.vue
+23
-3
types.d.ts
src/views/home/types.d.ts
+2
-0
No files found.
src/views/home/components/footer-operation.vue
View file @
e1e55d9f
...
@@ -112,8 +112,13 @@ function questionSubmit() {
...
@@ -112,8 +112,13 @@ function questionSubmit() {
content
:
questionContent
.
value
.
trim
(),
content
:
questionContent
.
value
.
trim
(),
timestamp
:
Date
.
now
(),
timestamp
:
Date
.
now
(),
isAnswerLoading
:
false
,
isAnswerLoading
:
false
,
avatar
:
''
,
name
:
''
,
})
})
const
agentAvatar
=
currentAgentApplication
.
value
.
agentAvatar
const
agentName
=
currentAgentApplication
.
value
.
agentTitle
nextTick
(()
=>
{
nextTick
(()
=>
{
emit
(
'addMessageItem'
,
latestAssistantMessageKey
,
{
emit
(
'addMessageItem'
,
latestAssistantMessageKey
,
{
role
:
'assistant'
,
role
:
'assistant'
,
...
@@ -121,6 +126,8 @@ function questionSubmit() {
...
@@ -121,6 +126,8 @@ function questionSubmit() {
content
:
''
,
content
:
''
,
timestamp
:
Date
.
now
(),
timestamp
:
Date
.
now
(),
isAnswerLoading
:
true
,
isAnswerLoading
:
true
,
avatar
:
agentAvatar
,
name
:
agentName
,
})
})
emit
(
'messageListScrollToBottom'
)
emit
(
'messageListScrollToBottom'
)
...
...
src/views/home/components/message-item.vue
View file @
e1e55d9f
...
@@ -14,25 +14,29 @@ const props = defineProps<Props>()
...
@@ -14,25 +14,29 @@ const props = defineProps<Props>()
const
{
t
}
=
useI18n
()
const
{
t
}
=
useI18n
()
const
userStore
=
useUserStore
()
const
userStore
=
useUserStore
()
const
agentAvatarUrl
=
readonly
({
url
:
'https://gsst-poe-sit.gz.bcebos.com/icon/agent-avatar.png'
})
const
agent
Default
AvatarUrl
=
readonly
({
url
:
'https://gsst-poe-sit.gz.bcebos.com/icon/agent-avatar.png'
})
const
isAgentMessage
=
computed
(()
=>
{
const
isAgentMessage
=
computed
(()
=>
{
return
props
.
messageItem
.
role
===
'assistant'
return
props
.
messageItem
.
role
===
'assistant'
})
})
const
avatarUrl
=
computed
(()
=>
{
return
isAgentMessage
.
value
?
props
.
messageItem
.
avatar
||
agentDefaultAvatarUrl
.
url
:
userStore
.
userInfo
.
avatarUrl
})
const
name
=
computed
(()
=>
{
return
isAgentMessage
.
value
?
props
.
messageItem
.
name
||
'AI助理'
:
userStore
.
userInfo
.
nickName
})
</
script
>
</
script
>
<
template
>
<
template
>
<div
class=
"mb-[20px] last:mb-0"
>
<div
class=
"mb-[20px] last:mb-0"
>
<div
class=
"flex"
>
<div
class=
"flex"
>
<img
<img
class=
"h-[36px] w-[36px]"
:src=
"avatarUrl"
alt=
"Avatar"
/>
class=
"h-[36px] w-[36px]"
:src=
"isAgentMessage ? agentAvatarUrl.url : userStore.userInfo.avatarUrl"
alt=
"Avatar"
/>
<div
class=
"ml-[11px]"
>
<div
class=
"ml-[11px]"
>
<div
class=
"mb-[7px] text-[12px] text-[#999]"
>
<div
class=
"mb-[7px] text-[12px] text-[#999]"
>
{{
isAgentMessage
?
'AI助理'
:
userStore
.
userInfo
.
nickN
ame
}}
{{
n
ame
}}
</div>
</div>
<div
<div
class=
"box-content min-h-[21px] min-w-[10px] rounded-[10px] border border-[#9EA3FF] px-[15px] py-[14px] text-justify"
class=
"box-content min-h-[21px] min-w-[10px] rounded-[10px] border border-[#9EA3FF] px-[15px] py-[14px] text-justify"
...
...
src/views/home/home.vue
View file @
e1e55d9f
...
@@ -152,11 +152,31 @@ function onGetMessageRecordList(recordId: string) {
...
@@ -152,11 +152,31 @@ function onGetMessageRecordList(recordId: string) {
const
loadingCtl
=
window
.
$message
.
loading
(
t
(
'home_module.switching_over'
))
const
loadingCtl
=
window
.
$message
.
loading
(
t
(
'home_module.switching_over'
))
fetchMessageRecordList
<
MessageItemInterface
[]
>
(
recordId
)
fetchMessageRecordList
<
{
role
:
'user'
|
'assistant'
agentId
:
string
agentAvatar
:
string
agentTitle
:
string
content
:
string
timestamp
:
number
}[]
>
(
recordId
)
.
then
((
res
)
=>
{
.
then
((
res
)
=>
{
if
(
res
.
data
&&
Array
.
isArray
(
res
.
data
))
{
if
(
res
.
data
&&
Array
.
isArray
(
res
.
data
))
{
const
messageListDraft
=
res
.
data
.
map
((
recordItem
)
=>
{
const
messageListDraft
:
(
string
|
MessageItemInterface
)[][]
=
res
.
data
.
map
((
recordItem
)
=>
{
return
[
nanoid
(),
{
...
recordItem
,
isAnswerLoading
:
false
}]
return
[
nanoid
(),
{
role
:
recordItem
.
role
,
agentId
:
recordItem
.
agentId
,
content
:
recordItem
.
content
,
isAnswerLoading
:
false
,
name
:
recordItem
.
agentTitle
,
avatar
:
recordItem
.
agentAvatar
,
timestamp
:
recordItem
.
timestamp
,
},
]
})
})
messageList
.
value
=
new
Map
(
messageListDraft
as
any
)
messageList
.
value
=
new
Map
(
messageListDraft
as
any
)
...
...
src/views/home/types.d.ts
View file @
e1e55d9f
...
@@ -13,4 +13,6 @@ export interface MessageItemInterface {
...
@@ -13,4 +13,6 @@ export interface MessageItemInterface {
content
:
string
content
:
string
timestamp
:
number
timestamp
:
number
isAnswerLoading
:
boolean
isAnswerLoading
:
boolean
avatar
:
string
name
:
string
}
}
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