fix: 复制工具集后若取消编辑则移除临时副本
parent
7f5b7f0537
commit
c02c83083d
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ export default function AgentEditor() {
|
|||
handleDeleteSkill,
|
||||
handleDeletePlugin,
|
||||
handleCopyPlugin,
|
||||
cleanupTempPlugins,
|
||||
liveAgent,
|
||||
currentName,
|
||||
markDirty,
|
||||
|
|
@ -169,6 +170,7 @@ export default function AgentEditor() {
|
|||
onClose={() => {
|
||||
setExternalToolEditorOpen(false);
|
||||
setEditingPluginId(null);
|
||||
cleanupTempPlugins();
|
||||
}}
|
||||
onSaved={refresh}
|
||||
/>
|
||||
|
|
|
|||
Loading…
Reference in New Issue