【解决todo】AI 删除对话,不默认选中

This commit is contained in:
cherishsince 2024-05-22 17:08:13 +08:00
parent e7403ba2a4
commit 89deddb9e0
2 changed files with 25 additions and 10 deletions

View File

@ -174,15 +174,15 @@ const getChatConversationList = async () => {
conversationList.value = res conversationList.value = res
// 3 // 3
if (!activeId?.value) { if (!activeId?.value) {
await handleConversationClick(res[0].id) // await handleConversationClick(res[0].id)
} else { } else {
// tip: // tip:
const filterConversationList = conversationList.value.filter(item => { // const filterConversationList = conversationList.value.filter(item => {
return item.id === activeId.value // return item.id === activeId.value
}) // })
if (filterConversationList.length <= 0) { // if (filterConversationList.length <= 0) {
await handleConversationClick(res[0].id) // await handleConversationClick(res[0].id)
} // }
} }
// 4 // 4
if (conversationList.value.length === 0) { if (conversationList.value.length === 0) {
@ -367,6 +367,9 @@ watch(activeId, async (newValue, oldValue) => {
activeConversationId.value = newValue as string activeConversationId.value = newValue as string
}) })
// public
defineExpose({createConversation})
onMounted(async () => { onMounted(async () => {
// //
if (props.activeId != null) { if (props.activeId != null) {

View File

@ -2,6 +2,7 @@
<el-container class="ai-layout"> <el-container class="ai-layout">
<!-- 左侧会话列表 --> <!-- 左侧会话列表 -->
<Conversation :active-id="activeConversationId" <Conversation :active-id="activeConversationId"
ref="conversationRef"
@onConversationClick="handleConversationClick" @onConversationClick="handleConversationClick"
@onConversationClear="handlerConversationClear" @onConversationClear="handlerConversationClear"
@onConversationDelete="handlerConversationDelete" @onConversationDelete="handlerConversationDelete"
@ -11,9 +12,9 @@
<!-- 右顶部 TODO 芋艿右对齐 --> <!-- 右顶部 TODO 芋艿右对齐 -->
<el-header class="header"> <el-header class="header">
<div class="title"> <div class="title">
{{ activeConversation?.title }} {{ activeConversation?.title ? activeConversation?.title : '对话' }}
</div> </div>
<div class="btns"> <div class="btns" v-if="activeConversation">
<!-- TODO @fan样式改下这里我已经改成点击后弹出了 --> <!-- TODO @fan样式改下这里我已经改成点击后弹出了 -->
<el-button type="primary" bg text="plain" size="small" @click="openChatConversationUpdateForm"> <el-button type="primary" bg text="plain" size="small" @click="openChatConversationUpdateForm">
<span v-html="activeConversation?.modelName"></span> <span v-html="activeConversation?.modelName"></span>
@ -32,11 +33,12 @@
<div > <div >
<div class="message-container" > <div class="message-container" >
<MessageLoading v-if="listLoading" /> <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" <Message v-if="!listLoading && list.length > 0"
ref="messageRef" ref="messageRef"
:list="list" :list="list"
@on-delete-success="handlerMessageDelete" /> @on-delete-success="handlerMessageDelete" />
<ChatEmpty v-if="!listLoading && list.length === 0" @on-prompt="doSend"/>
</div> </div>
</div> </div>
</el-main> </el-main>
@ -93,6 +95,7 @@ import Conversation from './Conversation.vue'
import Message from './Message.vue' import Message from './Message.vue'
import ChatEmpty from './ChatEmpty.vue' import ChatEmpty from './ChatEmpty.vue'
import MessageLoading from './MessageLoading.vue' import MessageLoading from './MessageLoading.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'
@ -126,6 +129,7 @@ const listLoadingTime = ref<any>() // time定时器如果加载速度很快
// () // ()
const messageRef = ref() const messageRef = ref()
const conversationRef = ref()
const isComposing = ref(false) // const isComposing = ref(false) //
// role // role
@ -490,6 +494,14 @@ const getConversation = async (id: string | null) => {
} }
} }
/**
* 对话 - 新建
*/
const handlerNewChat = async () => {
//
await conversationRef.value.createConversation()
}
// ============ message =========== // ============ message ===========
/** /**