From 95c38d07b1cad92c2793e1d625c9d9e0256d6545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?code=E7=BE=8A?= Date: Sun, 10 Aug 2025 18:31:07 +0800 Subject: [PATCH] add node menu options function --- README.md | 1 + web/uinodesDoc.js | 60 +++++++++++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index bfeb01d..341f062 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ git clone https://github.com/uinodes/ComfyUI-uinodesDOC.git --- **使用教程** +2025/08/10:BUG:因为ComfyUI_frontend 1.26.1版本,节点标题区过大,无法点击事件,先添加右键节点,可跳转网站。 安装本插件后,每个节点的右上角有一个“回形针”形状,点击即可跳转相应的说明文档界面。 diff --git a/web/uinodesDoc.js b/web/uinodesDoc.js index fef6da3..01efa47 100644 --- a/web/uinodesDoc.js +++ b/web/uinodesDoc.js @@ -63,9 +63,14 @@ function buildNodeUrl(python_module, nodeName) { app.registerExtension({ name: "fsy.Link2uinodesCOM", async beforeRegisterNodeDef(nodeType, nodeData) { - + const cnt = 0; try { addLinkIcon(nodeData, nodeType); + cnt++; + if (cnt == 1) { + console.log("nodeData", nodeData); + console.log("nodeType", nodeType); + } } catch (error) { console.error("Error in registering fsy.Link2uinodesCOM", error); } @@ -73,30 +78,6 @@ app.registerExtension({ }); -/** 获取节点的名字 */ -function getNodeName(nodeData, nodeInstance) { - // 1. 从节点实例获取标题 - if (nodeInstance && nodeInstance.title) { - return nodeInstance.title; - } - - // 2. 从节点数据获取显示名称 - if (nodeData.display_name) { - return nodeData.display_name; - } - - // 3. 从节点数据获取名称 - if (nodeData.name) { - return nodeData.name; - } - - // 4. 从节点类型获取 - if (nodeInstance && nodeInstance.type) { - return nodeInstance.type; - } - - return "Unknown Node"; -} /** 计算图标位置 */ function getIconPosition(nodeSize, iconSize, iconMargin, position) { @@ -219,4 +200,33 @@ export const addLinkIcon = ( return r; } + + + /* + updated: 2025-08-10 + description: 标题过大无法触发点击,添加右键菜单事件进行网站导航 + */ + const original_getExtraMenuOptions = nodeType.prototype.getExtraMenuOptions; + nodeType.prototype.getExtraMenuOptions = function(_, options) { + original_getExtraMenuOptions?.apply(this, arguments); + options.push({ + content: "跳转uinodes.com查看文档", + callback: async () => { + const url = buildNodeUrl(nodeData.python_module, nodeData.name); + if (url) { + const confirmed = confirm(`是否要打开以下链接?\n\n${url}\n\n点击"确定"将在新标签页中打开此链接。`); + if (confirmed) { + window.open(url, '_blank'); + } + } + } + }) + } + + + + + + + } \ No newline at end of file