Browse Source

fix: 修复历史记录进入页面后无法使用的问题

zhupei@smartai.com 1 năm trước cách đây
mục cha
commit
272dd92e89

+ 1 - 1
src/base/store/use-recent-history-search-type.js

@@ -16,7 +16,7 @@ function recentLocalGet() {
 
   if (result_list === null) {
     // json解析发生了错误
-    return [];
+    return null;
   } else {
     return result_list;
   }

+ 1 - 1
src/modules/conversation-board/use-agent-list-4-history.js

@@ -35,7 +35,7 @@ export default function useAgentList4History(onSuccess) {
     const cache_agents = allAgents.agents;
     if (cache_agents.length !== 0) {
       if (typeof onSuccess === 'function') {
-        onSuccess(cache_agents[0]);
+        onSuccess(cache_agents);
       }
 
       list_agents.value = cache_agents;

+ 15 - 11
src/modules/conversation-history/HistoryTypeDropdown.vue

@@ -34,22 +34,26 @@ const props = defineProps({
 const recentSearchType = useRecentSearchTypeStore();
 
 const { api_status, api_message, list_agents, getAgentList } = useAgentList4History((agent_list) => {
-  const cur_id = recentSearchType?.search_type?.id || '';
+  if (recentSearchType.search_type) {
+    const cur_id = recentSearchType.search_type?.id || '';
 
-  let item = null;
+    let item = null;
 
-  const len = agent_list.length;
-  for (let i = 0; i < len; i++) {
-    const agent = agent_list[i];
+    const len = agent_list.length;
+    for (let i = 0; i < len; i++) {
+      const agent = agent_list[i];
 
-    if (agent.id === cur_id) {
-      item = agent;
-      break;
+      if (agent.id === cur_id) {
+        item = agent;
+        break;
+      }
     }
-  }
 
-  if (item) {
-    handleChatTypeConfirm(item);
+    if (item) {
+      handleChatTypeConfirm(item);
+    } else {
+      handleChatTypeConfirm(agent_list[0]);
+    }
   } else {
     handleChatTypeConfirm(agent_list[0]);
   }