فهرست منبع

【解决todo】Chat 聊天,新建对话清空输入框

cherishsince 1 سال پیش
والد
کامیت
bebf1e7ae3
2فایلهای تغییر یافته به همراه17 افزوده شده و 1 حذف شده
  1. 8 1
      src/views/ai/chat/Conversation.vue
  2. 9 0
      src/views/ai/chat/index.vue

+ 8 - 1
src/views/ai/chat/Conversation.vue

@@ -122,7 +122,12 @@ const props = defineProps({
 })
 
 // 定义钩子
-const emits = defineEmits(['onConversationClick', 'onConversationClear', 'onConversationDelete'])
+const emits = defineEmits([
+  'onConversationCreate',
+  'onConversationClick',
+  'onConversationClear',
+  'onConversationDelete'
+])
 
 /**
  * 对话 - 搜索
@@ -256,6 +261,8 @@ const createConversation = async () => {
   await getChatConversationList()
   // 3、选中对话
   await handleConversationClick(conversationId)
+  // 4、回调
+  emits('onConversationCreate')
 }
 
 /**

+ 9 - 0
src/views/ai/chat/index.vue

@@ -3,6 +3,7 @@
     <!-- 左侧:会话列表 -->
     <Conversation :active-id="activeConversationId"
                   ref="conversationRef"
+                  @onConversationCreate="handleConversationCreate"
                   @onConversationClick="handleConversationClick"
                   @onConversationClear="handlerConversationClear"
                   @onConversationDelete="handlerConversationDelete"
@@ -440,6 +441,14 @@ const handlerTitleSuccess = async () => {
   await getConversation(activeConversationId.value)
 }
 
+/**
+ * 对话 - 创建
+ */
+const handleConversationCreate = async () => {
+  // 创建新的对话,清空输入框
+  prompt.value = ''
+}
+
 /**
  * 对话 - 点击
  */