Răsfoiți Sursa

【解决todo】Chat 对话默认选中第一个

cherishsince 1 an în urmă
părinte
comite
8fb54dbb7c
1 a modificat fișierele cu 7 adăugiri și 2 ștergeri
  1. 7 2
      src/views/ai/chat/Conversation.vue

+ 7 - 2
src/views/ai/chat/Conversation.vue

@@ -378,12 +378,17 @@ watch(activeId, async (newValue, oldValue) => {
 defineExpose({createConversation})
 
 onMounted(async () => {
+  // 获取 对话列表
+  await getChatConversationList()
   // 默认选中
   if (props.activeId != null) {
     activeConversationId.value = props.activeId
+  } else {
+    // 首次默认选中第一个
+    if (conversationList.value.length) {
+      activeConversationId.value = conversationList.value[0].id
+    }
   }
-  // 获取 对话列表
-  await getChatConversationList()
 })
 
 </script>