diff --git a/src/views/ai/chat/Conversation.vue b/src/views/ai/chat/Conversation.vue index 46988a63..f735252c 100644 --- a/src/views/ai/chat/Conversation.vue +++ b/src/views/ai/chat/Conversation.vue @@ -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) { diff --git a/src/views/ai/chat/index.vue b/src/views/ai/chat/index.vue index 999e1736..0aaa164c 100644 --- a/src/views/ai/chat/index.vue +++ b/src/views/ai/chat/index.vue @@ -2,6 +2,7 @@
- {{ activeConversation?.title }} + {{ activeConversation?.title ? activeConversation?.title : '对话' }}
-
+
@@ -32,11 +33,12 @@
+ + -
@@ -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() // 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 =========== /**