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
89deddb9
authored
May 22, 2024
by
cherishsince
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【解决todo】AI 删除对话,不默认选中
parent
e7403ba2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
10 deletions
+25
-10
src/views/ai/chat/Conversation.vue
+10
-7
src/views/ai/chat/index.vue
+15
-3
No files found.
src/views/ai/chat/Conversation.vue
View file @
89deddb9
...
...
@@ -174,15 +174,15 @@ const getChatConversationList = async () => {
conversationList
.
value
=
res
// 3、默认选中
if
(
!
activeId
?.
value
)
{
await
handleConversationClick
(
res
[
0
].
id
)
//
await handleConversationClick(res[0].id)
}
else
{
// tip: 删除的刚好是选中的,那么需要重新挑选一个来进行选中
const
filterConversationList
=
conversationList
.
value
.
filter
(
item
=>
{
return
item
.
id
===
activeId
.
value
})
if
(
filterConversationList
.
length
<=
0
)
{
await
handleConversationClick
(
res
[
0
].
id
)
}
//
const filterConversationList = conversationList.value.filter(item => {
//
return item.id === activeId.value
//
})
//
if (filterConversationList.length
<=
0
)
{
//
await handleConversationClick(res[0].id)
//
}
}
// 4、没有 任何对话情况
if
(
conversationList
.
value
.
length
===
0
)
{
...
...
@@ -367,6 +367,9 @@ watch(activeId, async (newValue, oldValue) => {
activeConversationId
.
value
=
newValue
as
string
})
// 定义 public 方法
defineExpose
({
createConversation
})
onMounted
(
async
()
=>
{
// 默认选中
if
(
props
.
activeId
!=
null
)
{
...
...
src/views/ai/chat/index.vue
View file @
89deddb9
...
...
@@ -2,6 +2,7 @@
<el-container
class=
"ai-layout"
>
<!-- 左侧:会话列表 -->
<Conversation
:active-id=
"activeConversationId"
ref=
"conversationRef"
@
onConversationClick=
"handleConversationClick"
@
onConversationClear=
"handlerConversationClear"
@
onConversationDelete=
"handlerConversationDelete"
...
...
@@ -11,9 +12,9 @@
<!-- 右顶部 TODO 芋艿:右对齐 -->
<el-header
class=
"header"
>
<div
class=
"title"
>
{{
activeConversation
?.
title
}}
{{
activeConversation
?.
title
?
activeConversation
?.
title
:
'对话'
}}
</div>
<div
class=
"btns"
>
<div
class=
"btns"
v-if=
"activeConversation"
>
<!-- TODO @fan:样式改下;这里我已经改成点击后,弹出了 -->
<el-button
type=
"primary"
bg
text=
"plain"
size=
"small"
@
click=
"openChatConversationUpdateForm"
>
<span
v-html=
"activeConversation?.modelName"
></span>
...
...
@@ -32,11 +33,12 @@
<div
>
<div
class=
"message-container"
>
<MessageLoading
v-if=
"listLoading"
/>
<MessageNewChat
v-if=
"!activeConversation"
@
on-new-chat=
"handlerNewChat"
/>
<ChatEmpty
v-if=
"!listLoading && list.length === 0 && activeConversation"
@
on-prompt=
"doSend"
/>
<Message
v-if=
"!listLoading && list.length > 0"
ref=
"messageRef"
:list=
"list"
@
on-delete-success=
"handlerMessageDelete"
/>
<ChatEmpty
v-if=
"!listLoading && list.length === 0"
@
on-prompt=
"doSend"
/>
</div>
</div>
</el-main>
...
...
@@ -93,6 +95,7 @@ import Conversation from './Conversation.vue'
import
Message
from
'./Message.vue'
import
ChatEmpty
from
'./ChatEmpty.vue'
import
MessageLoading
from
'./MessageLoading.vue'
import
MessageNewChat
from
'./MessageNewChat.vue'
import
{
ChatMessageApi
,
ChatMessageVO
}
from
'@/api/ai/chat/message'
import
{
ChatConversationApi
,
ChatConversationVO
}
from
'@/api/ai/chat/conversation'
import
{
getUserProfile
,
ProfileVO
}
from
'@/api/system/user/profile'
...
...
@@ -126,6 +129,7 @@ const listLoadingTime = ref<any>() // time定时器,如果加载速度很快
// 判断 消息列表 滚动的位置(用于判断是否需要滚动到消息最下方)
const
messageRef
=
ref
()
const
conversationRef
=
ref
()
const
isComposing
=
ref
(
false
)
// 判断用户是否在输入
// 默认 role 头像
...
...
@@ -490,6 +494,14 @@ const getConversation = async (id: string | null) => {
}
}
/**
* 对话 - 新建
*/
const
handlerNewChat
=
async
()
=>
{
// 创建对话
await
conversationRef
.
value
.
createConversation
()
}
// ============ message ===========
/**
...
...
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