Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ac18d871
authored
May 24, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
https://gitee.com/yudaocode/yudao-ui-admin-vue3
into dev
# Conflicts: # src/views/ai/chat/index.vue
parents
8764c6c4
24c45955
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
26 deletions
+23
-26
src/views/ai/chat/Conversation.vue
+2
-0
src/views/ai/chat/index.vue
+21
-26
No files found.
src/views/ai/chat/Conversation.vue
View file @
ac18d871
...
@@ -387,6 +387,8 @@ onMounted(async () => {
...
@@ -387,6 +387,8 @@ onMounted(async () => {
// 首次默认选中第一个
// 首次默认选中第一个
if
(
conversationList
.
value
.
length
)
{
if
(
conversationList
.
value
.
length
)
{
activeConversationId
.
value
=
conversationList
.
value
[
0
].
id
activeConversationId
.
value
=
conversationList
.
value
[
0
].
id
// 回调 onConversationClick
await
emits
(
'onConversationClick'
,
conversationList
.
value
[
0
])
}
}
}
}
})
})
...
...
src/views/ai/chat/index.vue
View file @
ac18d871
...
@@ -36,11 +36,10 @@
...
@@ -36,11 +36,10 @@
<div
class=
"message-container"
>
<div
class=
"message-container"
>
<MessageLoading
v-if=
"listLoading"
/>
<MessageLoading
v-if=
"listLoading"
/>
<MessageNewChat
v-if=
"!activeConversation"
@
on-new-chat=
"handlerNewChat"
/>
<MessageNewChat
v-if=
"!activeConversation"
@
on-new-chat=
"handlerNewChat"
/>
<ChatEmpty
v-if=
"!listLoading &&
messageL
ist.length === 0 && activeConversation"
@
on-prompt=
"doSend"
/>
<ChatEmpty
v-if=
"!listLoading &&
l
ist.length === 0 && activeConversation"
@
on-prompt=
"doSend"
/>
<Message
v-if=
"!listLoading &&
messageL
ist.length > 0"
<Message
v-if=
"!listLoading &&
l
ist.length > 0"
ref=
"messageRef"
ref=
"messageRef"
:conversation=
"activeConversation"
:list=
"list"
:list=
"messageList"
@
on-delete-success=
"handlerMessageDelete"
@
on-delete-success=
"handlerMessageDelete"
@
on-edit=
"handlerMessageEdit"
@
on-edit=
"handlerMessageEdit"
@
on-refresh=
"handlerMessageRefresh"
/>
@
on-refresh=
"handlerMessageRefresh"
/>
...
@@ -103,12 +102,14 @@ import MessageLoading from './MessageLoading.vue'
...
@@ -103,12 +102,14 @@ import MessageLoading from './MessageLoading.vue'
import
MessageNewChat
from
'./MessageNewChat.vue'
import
MessageNewChat
from
'./MessageNewChat.vue'
import
{
ChatMessageApi
,
ChatMessageVO
}
from
'@/api/ai/chat/message'
import
{
ChatMessageApi
,
ChatMessageVO
}
from
'@/api/ai/chat/message'
import
{
ChatConversationApi
,
ChatConversationVO
}
from
'@/api/ai/chat/conversation'
import
{
ChatConversationApi
,
ChatConversationVO
}
from
'@/api/ai/chat/conversation'
import
{
getUserProfile
,
ProfileVO
}
from
'@/api/system/user/profile'
import
{
getUserProfile
,
ProfileVO
}
from
'@/api/system/user/profile'
import
{
useClipboard
}
from
'@vueuse/core'
import
ChatConversationUpdateForm
from
"@/views/ai/chat/components/ChatConversationUpdateForm.vue"
;
import
ChatConversationUpdateForm
from
"@/views/ai/chat/components/ChatConversationUpdateForm.vue"
;
import
{
Download
,
Top
}
from
"@element-plus/icons-vue"
;
import
{
Download
,
Top
}
from
"@element-plus/icons-vue"
;
const
route
=
useRoute
()
// 路由
const
route
=
useRoute
()
// 路由
const
message
=
useMessage
()
// 消息弹窗
const
message
=
useMessage
()
// 消息弹窗
const
{
copy
}
=
useClipboard
()
// 初始化 copy 到粘贴板
// ref 属性定义
// ref 属性定义
const
activeConversationId
=
ref
<
string
|
null
>
(
null
)
// 选中的对话编号
const
activeConversationId
=
ref
<
string
|
null
>
(
null
)
// 选中的对话编号
...
@@ -338,8 +339,14 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
...
@@ -338,8 +339,14 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
userMessage
.
content
,
userMessage
.
content
,
conversationInAbortController
.
value
,
conversationInAbortController
.
value
,
enableContext
.
value
,
enableContext
.
value
,
async
(
message
)
=>
{
async
(
res
)
=>
{
const
data
=
JSON
.
parse
(
message
.
data
)
// TODO 芋艿:类型处理;
console
.
log
(
'res'
,
res
)
const
{
code
,
data
,
msg
}
=
JSON
.
parse
(
res
.
data
)
if
(
code
!==
0
)
{
message
.
alert
(
`对话异常!
${
msg
}
`
)
return
}
// 如果内容为空,就不处理。
// 如果内容为空,就不处理。
if
(
data
.
receive
.
content
===
''
)
{
if
(
data
.
receive
.
content
===
''
)
{
return
return
...
@@ -360,14 +367,13 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
...
@@ -360,14 +367,13 @@ const doSendStream = async (userMessage: ChatMessageVO) => {
await
scrollToBottom
()
await
scrollToBottom
()
},
},
(
error
)
=>
{
(
error
)
=>
{
console
.
log
(
'onError'
)
message
.
alert
(
`对话异常!
${
error
}
`
)
// 标记对话结束
// 标记对话结束
conversationInProgress
.
value
=
false
conversationInProgress
.
value
=
false
// 结束 stream 对话
// 结束 stream 对话
conversationInAbortController
.
value
.
abort
()
conversationInAbortController
.
value
.
abort
()
},
},
()
=>
{
()
=>
{
console
.
log
(
'onClose'
)
// 标记对话结束
// 标记对话结束
conversationInProgress
.
value
=
false
conversationInProgress
.
value
=
false
// 结束 stream 对话
// 结束 stream 对话
...
@@ -390,23 +396,6 @@ const stopStream = async () => {
...
@@ -390,23 +396,6 @@ const stopStream = async () => {
// ============== message 数据 =================
// ============== message 数据 =================
/** 消息列表 */
const
messageList
=
computed
(()
=>
{
if
(
list
.
value
.
length
>
0
)
{
return
list
.
value
}
// 没有消息时,如果有 systemMessage 则展示它
// TODO add by 芋艿:这个消息下面,不能有复制、删除按钮
if
(
activeConversation
.
value
?.
systemMessage
)
{
return
[{
id
:
0
,
type
:
'system'
,
content
:
activeConversation
.
value
.
systemMessage
}]
}
return
[]
})
/**
/**
* 获取 - message 列表
* 获取 - message 列表
*/
*/
...
@@ -486,6 +475,8 @@ const handleConversationClick = async (conversation: ChatConversationVO) => {
...
@@ -486,6 +475,8 @@ const handleConversationClick = async (conversation: ChatConversationVO) => {
await
getMessageList
()
await
getMessageList
()
// 滚动底部
// 滚动底部
scrollToBottom
(
true
)
scrollToBottom
(
true
)
// 清空输入框
prompt
.
value
=
''
return
true
return
true
}
}
...
@@ -536,6 +527,10 @@ const handlerNewChat = async () => {
...
@@ -536,6 +527,10 @@ const handlerNewChat = async () => {
* 删除 message
* 删除 message
*/
*/
const
handlerMessageDelete
=
async
()
=>
{
const
handlerMessageDelete
=
async
()
=>
{
if
(
conversationInProgress
.
value
)
{
message
.
alert
(
'回答中,不能删除!'
)
return
}
// 刷新 message
// 刷新 message
await
getMessageList
()
await
getMessageList
()
}
}
...
...
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