From c02c83083dce8e0f37cf9ca06f6e834d6572797c Mon Sep 17 00:00:00 2001 From: sp mac bookpro 2605 Date: Wed, 22 Jul 2026 14:13:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A4=8D=E5=88=B6=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E9=9B=86=E5=90=8E=E8=8B=A5=E5=8F=96=E6=B6=88=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=88=99=E7=A7=BB=E9=99=A4=E4=B8=B4=E6=97=B6=E5=89=AF=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/AgentEditor/hooks/useAgentEditor.ts | 15 +++++++++++++++ src/pages/AgentEditor/index.tsx | 12 +++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/pages/AgentEditor/hooks/useAgentEditor.ts b/src/pages/AgentEditor/hooks/useAgentEditor.ts index 3b82dd1..a3f5ebf 100644 --- a/src/pages/AgentEditor/hooks/useAgentEditor.ts +++ b/src/pages/AgentEditor/hooks/useAgentEditor.ts @@ -236,6 +236,10 @@ export function useAgentEditor({ id, isNew, form, message, navigate }: UseAgentE const handleDeletePlugin = async (pluginId: string) => { if (!id) return; + if (pluginId.startsWith('temp_')) { + setAgent((prev) => prev ? { ...prev, plugins: (prev.plugins || []).filter((plugin) => plugin.id !== pluginId) } : prev); + return; + } try { await AgentAPI.deletePlugin(id, pluginId); setAgent((prev) => prev ? { ...prev, plugins: (prev.plugins || []).filter((plugin) => plugin.id !== pluginId) } : prev); @@ -273,6 +277,16 @@ export function useAgentEditor({ id, isNew, form, message, navigate }: UseAgentE return newPlugin; }; + const cleanupTempPlugins = () => { + setAgent((prev) => { + if (!prev) return prev; + return { + ...prev, + plugins: (prev.plugins || []).filter((p) => !p.id.startsWith('temp_')), + }; + }); + }; + const beforeUploadKnowledge = async (file: any) => { if (!id) { message.warning('请先保存智能体基础信息后再上传'); @@ -381,6 +395,7 @@ export function useAgentEditor({ id, isNew, form, message, navigate }: UseAgentE handleDeleteSkill, handleDeletePlugin, handleCopyPlugin, + cleanupTempPlugins, liveAgent, currentName, markDirty, diff --git a/src/pages/AgentEditor/index.tsx b/src/pages/AgentEditor/index.tsx index a2a5475..0c90c63 100644 --- a/src/pages/AgentEditor/index.tsx +++ b/src/pages/AgentEditor/index.tsx @@ -58,6 +58,7 @@ export default function AgentEditor() { handleDeleteSkill, handleDeletePlugin, handleCopyPlugin, + cleanupTempPlugins, liveAgent, currentName, markDirty, @@ -166,11 +167,12 @@ export default function AgentEditor() { open={externalToolEditorOpen} agentId={id!} plugin={agent?.plugins?.find((plugin) => plugin.id === editingPluginId)} - onClose={() => { - setExternalToolEditorOpen(false); - setEditingPluginId(null); - }} - onSaved={refresh} + onClose={() => { + setExternalToolEditorOpen(false); + setEditingPluginId(null); + cleanupTempPlugins(); + }} + onSaved={refresh} /> )}