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
36beffe1
authored
May 16, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【增加】清空 Chat 对话
parent
f21991f4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
5 deletions
+28
-5
src/api/ai/chat/conversation/index.ts
+5
-0
src/api/ai/chat/message/index.ts
+1
-1
src/views/ai/chat/index.vue
+22
-4
No files found.
src/api/ai/chat/conversation/index.ts
View file @
36beffe1
...
@@ -42,6 +42,11 @@ export const ChatConversationApi = {
...
@@ -42,6 +42,11 @@ export const ChatConversationApi = {
return
await
request
.
delete
({
url
:
`/ai/chat/conversation/delete-my?id=
${
id
}
`
})
return
await
request
.
delete
({
url
:
`/ai/chat/conversation/delete-my?id=
${
id
}
`
})
},
},
// 删除【我的】所有对话,置顶除外
deleteMyAllExceptPinned
:
async
()
=>
{
return
await
request
.
delete
({
url
:
`/ai/chat/conversation/delete-my-all-except-pinned`
})
},
// 获得【我的】聊天会话列表
// 获得【我的】聊天会话列表
getChatConversationMyList
:
async
()
=>
{
getChatConversationMyList
:
async
()
=>
{
return
await
request
.
get
({
url
:
`/ai/chat/conversation/my-list`
})
return
await
request
.
get
({
url
:
`/ai/chat/conversation/my-list`
})
...
...
src/api/ai/chat/message/index.ts
View file @
36beffe1
...
@@ -25,7 +25,7 @@ export interface ChatMessageSendVO {
...
@@ -25,7 +25,7 @@ export interface ChatMessageSendVO {
// AI chat 聊天
// AI chat 聊天
export
const
ChatMessageApi
=
{
export
const
ChatMessageApi
=
{
// 消息列表
// 消息列表
messageList
:
async
(
conversationId
:
number
)
=>
{
messageList
:
async
(
conversationId
:
number
|
null
)
=>
{
return
await
request
.
get
({
return
await
request
.
get
({
url
:
`/ai/chat/message/list-by-conversation-id?conversationId=
${
conversationId
}
`
url
:
`/ai/chat/message/list-by-conversation-id?conversationId=
${
conversationId
}
`
})
})
...
...
src/views/ai/chat/index.vue
View file @
36beffe1
...
@@ -59,7 +59,7 @@
...
@@ -59,7 +59,7 @@
<Icon
icon=
"ep:user"
/>
<Icon
icon=
"ep:user"
/>
<el-text
size=
"small"
>
角色仓库
</el-text>
<el-text
size=
"small"
>
角色仓库
</el-text>
</div>
</div>
<div>
<div
@
click=
"handleClearConversation"
>
<Icon
icon=
"ep:delete"
/>
<Icon
icon=
"ep:delete"
/>
<el-text
size=
"small"
>
清空未置顶对话
</el-text>
<el-text
size=
"small"
>
清空未置顶对话
</el-text>
</div>
</div>
...
@@ -233,7 +233,7 @@ const {copy} = useClipboard()
...
@@ -233,7 +233,7 @@ const {copy} = useClipboard()
const
drawer
=
ref
<
boolean
>
(
false
)
// 角色仓库抽屉
const
drawer
=
ref
<
boolean
>
(
false
)
// 角色仓库抽屉
const
searchName
=
ref
(
''
)
// 查询的内容
const
searchName
=
ref
(
''
)
// 查询的内容
const
inputTimeout
=
ref
<
any
>
()
// 处理输入中回车的定时器
const
inputTimeout
=
ref
<
any
>
()
// 处理输入中回车的定时器
const
conversationId
=
ref
<
number
>
(
-
1
)
// 选中的对话编号
const
conversationId
=
ref
<
number
|
null
>
(
null
)
// 选中的对话编号
const
conversationInProgress
=
ref
(
false
)
// 对话进行中
const
conversationInProgress
=
ref
(
false
)
// 对话进行中
const
conversationInAbortController
=
ref
<
any
>
()
// 对话进行中 abort 控制器(控制 stream 对话)
const
conversationInAbortController
=
ref
<
any
>
()
// 对话进行中 abort 控制器(控制 stream 对话)
...
@@ -247,7 +247,7 @@ const isComposing = ref(false) // 判断用户是否在输入
...
@@ -247,7 +247,7 @@ const isComposing = ref(false) // 判断用户是否在输入
/** chat message 列表 */
/** chat message 列表 */
// defineOptions({ name: 'chatMessageList' })
// defineOptions({ name: 'chatMessageList' })
const
list
=
ref
<
ChatMessageVO
[]
>
([])
// 列表的数据
const
list
=
ref
<
ChatMessageVO
[]
>
([])
// 列表的数据
const
useConversation
=
ref
<
ChatConversationVO
>
(
)
// 使用的 Conversation
const
useConversation
=
ref
<
ChatConversationVO
|
null
>
(
null
)
// 使用的 Conversation
/** 新建对话 */
/** 新建对话 */
const
createConversation
=
async
()
=>
{
const
createConversation
=
async
()
=>
{
...
@@ -521,7 +521,10 @@ const onPromptInput = (event) => {
...
@@ -521,7 +521,10 @@ const onPromptInput = (event) => {
},
400
)
},
400
)
}
}
const
getConversation
=
async
(
conversationId
:
number
)
=>
{
const
getConversation
=
async
(
conversationId
:
number
|
null
)
=>
{
if
(
!
conversationId
)
{
return
}
// 获取对话信息
// 获取对话信息
useConversation
.
value
=
await
ChatConversationApi
.
getChatConversationMy
(
conversationId
)
useConversation
.
value
=
await
ChatConversationApi
.
getChatConversationMy
(
conversationId
)
console
.
log
(
'useConversation.value'
,
useConversation
.
value
)
console
.
log
(
'useConversation.value'
,
useConversation
.
value
)
...
@@ -602,6 +605,21 @@ const handleRoleRepository = async () => {
...
@@ -602,6 +605,21 @@ const handleRoleRepository = async () => {
drawer
.
value
=
!
drawer
.
value
drawer
.
value
=
!
drawer
.
value
}
}
// 清空对话
const
handleClearConversation
=
async
()
=>
{
await
ChatConversationApi
.
deleteMyAllExceptPinned
()
ElMessage
({
message
:
'操作成功!'
,
type
:
'success'
})
// 清空选中的对话
useConversation
.
value
=
null
conversationId
.
value
=
null
// 获得聊天会话列表
await
getChatConversationList
()
}
/** 初始化 **/
/** 初始化 **/
onMounted
(
async
()
=>
{
onMounted
(
async
()
=>
{
// 设置当前对话
// 设置当前对话
...
...
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