mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
fix(top-menu): use dynamic imports to eliminate deprecation warnings
- Replace static imports of deprecated ComfyButton and ComfyButtonGroup with dynamic imports - Only loads legacy API files when frontend version < 1.33.9 (backward compatibility path) - Frontend >= 1.33.9 users no longer see deprecation warnings since legacy code is never loaded - Preserves full backward compatibility for older ComfyUI frontend versions - All existing tests pass (159 JS + 65 Vue tests)
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import { app } from "../../scripts/app.js";
|
||||
import { ComfyButtonGroup } from "../../scripts/ui/components/buttonGroup.js";
|
||||
import { ComfyButton } from "../../scripts/ui/components/button.js";
|
||||
|
||||
const BUTTON_TOOLTIP = "Launch LoRA Manager (Shift+Click opens in new window)";
|
||||
const LORA_MANAGER_PATH = "/loras";
|
||||
@@ -95,7 +93,9 @@ const fetchVersionInfo = async () => {
|
||||
return "";
|
||||
};
|
||||
|
||||
const createTopMenuButton = () => {
|
||||
const createTopMenuButton = async () => {
|
||||
const { ComfyButton } = await import("../../scripts/ui/components/button.js");
|
||||
|
||||
const button = new ComfyButton({
|
||||
icon: "loramanager",
|
||||
tooltip: BUTTON_TOOLTIP,
|
||||
@@ -117,7 +117,7 @@ const createTopMenuButton = () => {
|
||||
return button;
|
||||
};
|
||||
|
||||
const attachTopMenuButton = (attempt = 0) => {
|
||||
const attachTopMenuButton = async (attempt = 0) => {
|
||||
if (document.querySelector(`.${BUTTON_GROUP_CLASS}`)) {
|
||||
return;
|
||||
}
|
||||
@@ -133,7 +133,9 @@ const attachTopMenuButton = (attempt = 0) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const loraManagerButton = createTopMenuButton();
|
||||
const loraManagerButton = await createTopMenuButton();
|
||||
const { ComfyButtonGroup } = await import("../../scripts/ui/components/buttonGroup.js");
|
||||
|
||||
const buttonGroup = new ComfyButtonGroup(loraManagerButton);
|
||||
buttonGroup.element.classList.add(BUTTON_GROUP_CLASS);
|
||||
|
||||
@@ -158,7 +160,7 @@ const createExtensionObject = (useActionBar) => {
|
||||
|
||||
if (!useActionBar) {
|
||||
console.log("LoRA Manager: using legacy button attachment (frontend version < 1.33.9)");
|
||||
attachTopMenuButton();
|
||||
await attachTopMenuButton();
|
||||
} else {
|
||||
console.log("LoRA Manager: using actionBarButtons API (frontend version >= 1.33.9)");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user