v0.21.2
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "kaytool"
|
||||
description ="The KayTool custom node toolkit is designed to enhance the efficiency of building ComfyUI workflows. It includes a variety of practical nodes: wireless data transfer (Set & Get), AI translation (Tencent and Baidu), dynamic mathematical operations, image processing (size extraction, color adjustment, background removal, mask blurring and expansion), flexible text handling, precision sliders, advanced image saving with metadata support, and more."
|
||||
version = "0.21.1"
|
||||
version = "0.21.2"
|
||||
license = {file = "LICENSE"}
|
||||
dependencies = ["rembg"]
|
||||
|
||||
|
||||
+18
-7
@@ -1,14 +1,14 @@
|
||||
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { ComfyWidgets } from "../../scripts/widgets.js";
|
||||
|
||||
export function setupGenericDisplay(nodeType, nodeName) {
|
||||
// 定义通用显示逻辑
|
||||
function setupGenericDisplay(nodeType, nodeName) {
|
||||
const onExecuted = nodeType.prototype.onExecuted;
|
||||
nodeType.prototype.onExecuted = function (message) {
|
||||
|
||||
// 调用原始的 onExecuted 方法(如果存在)
|
||||
onExecuted?.apply(this, arguments);
|
||||
|
||||
|
||||
// 清理多余的 widgets
|
||||
if (this.widgets && this.widgets.length > 0) {
|
||||
for (let i = 1; i < this.widgets.length; i++) {
|
||||
this.widgets[i]?.onRemove?.();
|
||||
@@ -16,13 +16,13 @@ export function setupGenericDisplay(nodeType, nodeName) {
|
||||
this.widgets.length = 1;
|
||||
}
|
||||
|
||||
// 查找或创建 "displaytext" widget
|
||||
let textWidget = Array.isArray(this.widgets)
|
||||
? this.widgets.find(w => w && w.name === "displaytext")
|
||||
: null;
|
||||
|
||||
if (!textWidget) {
|
||||
try {
|
||||
|
||||
textWidget = ComfyWidgets["STRING"](this, "displaytext", ["STRING", { multiline: true }], app).widget;
|
||||
if (textWidget && textWidget.inputEl) {
|
||||
textWidget.inputEl.readOnly = true;
|
||||
@@ -34,7 +34,7 @@ export function setupGenericDisplay(nodeType, nodeName) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 更新 "displaytext" widget 的值
|
||||
if (message && message.hasOwnProperty("text")) {
|
||||
const text = message["text"];
|
||||
if (textWidget) {
|
||||
@@ -46,4 +46,15 @@ export function setupGenericDisplay(nodeType, nodeName) {
|
||||
console.warn(`[${nodeName}] Message does not contain a "text" property.`);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// 注册扩展
|
||||
app.registerExtension({
|
||||
name: "KayTool.GenericDisplay",
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
const nodesWithDisplay = ["Display_Any", "To_Int", "Abc_Math"];
|
||||
if (nodesWithDisplay.includes(nodeData.name)) {
|
||||
setupGenericDisplay(nodeType, nodeData.name);
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { setupGenericDisplay } from "./common_display.js";
|
||||
|
||||
app.registerExtension({
|
||||
name: "KayTool.GenericDisplay",
|
||||
async beforeRegisterNodeDef(nodeType, nodeData, app) {
|
||||
|
||||
const nodesWithDisplay = ["Display_Any", "To_Int", "Abc_Math"];
|
||||
if (nodesWithDisplay.includes(nodeData.name)) {
|
||||
setupGenericDisplay(nodeType, nodeData.name);
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user