From 9b84176a42719b26374a59f4fe444d1f908aafeb Mon Sep 17 00:00:00 2001 From: kangfenmao Date: Tue, 3 Dec 2024 17:45:39 +0800 Subject: [PATCH] wip --- src/renderer/src/pages/agents/AgentsPage.tsx | 45 ++++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/src/renderer/src/pages/agents/AgentsPage.tsx b/src/renderer/src/pages/agents/AgentsPage.tsx index 32e23129..a4497e90 100644 --- a/src/renderer/src/pages/agents/AgentsPage.tsx +++ b/src/renderer/src/pages/agents/AgentsPage.tsx @@ -58,19 +58,21 @@ const AgentsPage: FC = () => { return groups } - Object.entries(agentGroups).forEach(([group, agents]) => { - if (group === '精选') return + const uniqueAgents = new Map() - const filteredAgents = agents.filter( - (agent) => - agent.name.toLowerCase().includes(search.toLowerCase()) || - agent.description?.toLowerCase().includes(search.toLowerCase()) - ) - if (filteredAgents.length > 0) { - groups[group] = filteredAgents - } + Object.entries(agentGroups).forEach(([, agents]) => { + agents.forEach((agent) => { + if ( + (agent.name.toLowerCase().includes(search.toLowerCase()) || + agent.description?.toLowerCase().includes(search.toLowerCase())) && + !uniqueAgents.has(agent.name) + ) { + uniqueAgents.set(agent.name, agent) + } + }) }) - return groups + + return { 搜索结果: Array.from(uniqueAgents.values()) } }, [agentGroups, search]) const getAgentName = (agent: Agent) => { @@ -174,8 +176,25 @@ const AgentsPage: FC = () => { - {tabItems.length > 0 ? ( - + {Object.values(filteredAgentGroups).flat().length > 0 ? ( + search.trim() ? ( + + + {Object.values(filteredAgentGroups) + .flat() + .map((agent, index) => ( + + onAddAgentConfirm(getAgentFromSystemAgent(agent as any))} + agent={agent as any} + /> + + ))} + + + ) : ( + + ) ) : (