From 1e8ed1e16fb0865bc53db5c200c91eb2a9ce600b Mon Sep 17 00:00:00 2001 From: Dijkstra Date: Tue, 9 Apr 2024 21:09:44 +0200 Subject: [PATCH] feat: added pyssss's lora view info --- __init__.py | 3 ++- web/js/loraInfo.js | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 web/js/loraInfo.js diff --git a/__init__.py b/__init__.py index fe1e2af..c052538 100644 --- a/__init__.py +++ b/__init__.py @@ -5,4 +5,5 @@ from .nodes_utils import NODE_CLASS_MAPPINGS as nu_NCM NODE_CLASS_MAPPINGS = dict(na_NCM, **nu_NCM) #NODE_DISPLAY_NAME_MAPPINGS = dict(na_NDNM, **nu_NDNM) -__all__ = ["NODE_CLASS_MAPPINGS"]#, "NODE_DISPLAY_NAME_MAPPINGS"] +WEB_DIRECTORY = "./web" +__all__ = ["NODE_CLASS_MAPPINGS", "WEB_DIRECTORY"]#, "NODE_DISPLAY_NAME_MAPPINGS"] diff --git a/web/js/loraInfo.js b/web/js/loraInfo.js new file mode 100644 index 0000000..ca4181a --- /dev/null +++ b/web/js/loraInfo.js @@ -0,0 +1,36 @@ +import { app } from "../../../scripts/app.js"; +import { LoraInfoDialog } from "../../ComfyUI-Custom-Scripts/js/modelInfo.js"; + +const infoHandlers = { + "LoraLoaderVanilla":true, + "LoraLoaderStackedVanilla":true, + "LoraLoaderAdvanced":true, + "LoraLoaderStackedAdvanced":true +} + +app.registerExtension({ + name: "autotrigger.LoraInfo", + beforeRegisterNodeDef(nodeType) { + if (! infoHandlers[nodeType.comfyClass]) { + return; + } + const getExtraMenuOptions = nodeType.prototype.getExtraMenuOptions; + nodeType.prototype.getExtraMenuOptions = function (_, options) { + let value = this.widgets[0].value; + if (!value) { + return; + } + if (value.content) { + value = value.content; + } + options.unshift({ + content: "View info...", + callback: async () => { + new LoraInfoDialog(value).show("loras", value); + }, + }); + + return getExtraMenuOptions?.apply(this, arguments); + }; + } +}); \ No newline at end of file