Merge pull request #1 from uinodes/fixed
add node menu options function
This commit is contained in:
@@ -14,6 +14,7 @@ git clone https://github.com/uinodes/ComfyUI-uinodesDOC.git
|
|||||||
---
|
---
|
||||||
|
|
||||||
**使用教程**
|
**使用教程**
|
||||||
|
2025/08/10:BUG:因为ComfyUI_frontend 1.26.1版本,节点标题区过大,无法点击事件,先添加右键节点,可跳转网站。
|
||||||
|
|
||||||
安装本插件后,每个节点的右上角有一个“回形针”形状,点击即可跳转相应的说明文档界面。
|
安装本插件后,每个节点的右上角有一个“回形针”形状,点击即可跳转相应的说明文档界面。
|
||||||
|
|
||||||
|
|||||||
+35
-25
@@ -63,9 +63,14 @@ function buildNodeUrl(python_module, nodeName) {
|
|||||||
app.registerExtension({
|
app.registerExtension({
|
||||||
name: "fsy.Link2uinodesCOM",
|
name: "fsy.Link2uinodesCOM",
|
||||||
async beforeRegisterNodeDef(nodeType, nodeData) {
|
async beforeRegisterNodeDef(nodeType, nodeData) {
|
||||||
|
const cnt = 0;
|
||||||
try {
|
try {
|
||||||
addLinkIcon(nodeData, nodeType);
|
addLinkIcon(nodeData, nodeType);
|
||||||
|
cnt++;
|
||||||
|
if (cnt == 1) {
|
||||||
|
console.log("nodeData", nodeData);
|
||||||
|
console.log("nodeType", nodeType);
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error in registering fsy.Link2uinodesCOM", 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) {
|
function getIconPosition(nodeSize, iconSize, iconMargin, position) {
|
||||||
@@ -219,4 +200,33 @@ export const addLinkIcon = (
|
|||||||
|
|
||||||
return r;
|
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');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user