fix: 复制工具集后若取消编辑则移除临时副本
parent
7f5b7f0537
commit
c02c83083d
|
|
@ -236,6 +236,10 @@ export function useAgentEditor({ id, isNew, form, message, navigate }: UseAgentE
|
||||||
|
|
||||||
const handleDeletePlugin = async (pluginId: string) => {
|
const handleDeletePlugin = async (pluginId: string) => {
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
|
if (pluginId.startsWith('temp_')) {
|
||||||
|
setAgent((prev) => prev ? { ...prev, plugins: (prev.plugins || []).filter((plugin) => plugin.id !== pluginId) } : prev);
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await AgentAPI.deletePlugin(id, pluginId);
|
await AgentAPI.deletePlugin(id, pluginId);
|
||||||
setAgent((prev) => prev ? { ...prev, plugins: (prev.plugins || []).filter((plugin) => plugin.id !== pluginId) } : prev);
|
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;
|
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) => {
|
const beforeUploadKnowledge = async (file: any) => {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
message.warning('请先保存智能体基础信息后再上传');
|
message.warning('请先保存智能体基础信息后再上传');
|
||||||
|
|
@ -381,6 +395,7 @@ export function useAgentEditor({ id, isNew, form, message, navigate }: UseAgentE
|
||||||
handleDeleteSkill,
|
handleDeleteSkill,
|
||||||
handleDeletePlugin,
|
handleDeletePlugin,
|
||||||
handleCopyPlugin,
|
handleCopyPlugin,
|
||||||
|
cleanupTempPlugins,
|
||||||
liveAgent,
|
liveAgent,
|
||||||
currentName,
|
currentName,
|
||||||
markDirty,
|
markDirty,
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,7 @@ export default function AgentEditor() {
|
||||||
handleDeleteSkill,
|
handleDeleteSkill,
|
||||||
handleDeletePlugin,
|
handleDeletePlugin,
|
||||||
handleCopyPlugin,
|
handleCopyPlugin,
|
||||||
|
cleanupTempPlugins,
|
||||||
liveAgent,
|
liveAgent,
|
||||||
currentName,
|
currentName,
|
||||||
markDirty,
|
markDirty,
|
||||||
|
|
@ -166,11 +167,12 @@ export default function AgentEditor() {
|
||||||
open={externalToolEditorOpen}
|
open={externalToolEditorOpen}
|
||||||
agentId={id!}
|
agentId={id!}
|
||||||
plugin={agent?.plugins?.find((plugin) => plugin.id === editingPluginId)}
|
plugin={agent?.plugins?.find((plugin) => plugin.id === editingPluginId)}
|
||||||
onClose={() => {
|
onClose={() => {
|
||||||
setExternalToolEditorOpen(false);
|
setExternalToolEditorOpen(false);
|
||||||
setEditingPluginId(null);
|
setEditingPluginId(null);
|
||||||
}}
|
cleanupTempPlugins();
|
||||||
onSaved={refresh}
|
}}
|
||||||
|
onSaved={refresh}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue