From 20fcbb2e48c1880d1da00ad5bc7d74cc64eb9166 Mon Sep 17 00:00:00 2001 From: shanexi Date: Mon, 28 Oct 2024 11:14:05 +0800 Subject: [PATCH] Fix duplicated drag menu item --- web/shellagent.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/web/shellagent.js b/web/shellagent.js index 1754953..629773d 100644 --- a/web/shellagent.js +++ b/web/shellagent.js @@ -335,13 +335,24 @@ app.registerExtension({ }, afterConfigureGraph(missingNodeTypes, app) { - LiteGraph.slot_types_default_in['IMAGE'].unshift('ShellAgentPluginInputImage') - LiteGraph.slot_types_default_out['IMAGE'].unshift('ShellAgentPluginSaveImage') - LiteGraph.slot_types_default_out['IMAGE'].unshift('ShellAgentPluginSaveImages') + function addIn(type, nodeId) { + if (LiteGraph.slot_types_default_in[type].indexOf(nodeId) === -1) { + LiteGraph.slot_types_default_in[type].unshift(nodeId) + } + } - LiteGraph.slot_types_default_out['STRING'].unshift('ShellAgentPluginOutputFloat') - LiteGraph.slot_types_default_out['STRING'].unshift('ShellAgentPluginOutputInteger') - LiteGraph.slot_types_default_out['STRING'].unshift('ShellAgentPluginOutputText') + function addOut(type, nodeId) { + if (LiteGraph.slot_types_default_out[type].indexOf(nodeId) === -1) { + LiteGraph.slot_types_default_out[type].unshift(nodeId) + } + } + + addIn('IMAGE', 'ShellAgentPluginInputImage') + addOut('IMAGE', 'ShellAgentPluginSaveImage') + addOut('IMAGE', 'ShellAgentPluginSaveImages') + addOut('STRING', 'ShellAgentPluginOutputFloat') + addOut('STRING', 'ShellAgentPluginOutputInteger') + addOut('STRING', 'ShellAgentPluginOutputText') } });