The feature was presented as customising "the ComfyUI Logo", so people expected the logo at the top left of the interface to change. It only ever replaced link[rel=icon], the browser tab icon. That logo is an inline SVG rendered by the frontend and is not something this setting touches. Rename the setting, its category and the README section accordingly, and say in the tooltips that the interface logo is unaffected. No behaviour change. Also drops a duplicate KayTool_EnableCustomWebLogo key that the previous commit left in every locale file.
52 lines
2.1 KiB
JavaScript
52 lines
2.1 KiB
JavaScript
import { app } from "../../../scripts/app.js";
|
|
|
|
app.registerExtension({
|
|
name: "KayTool.CustomWebLogo",
|
|
async setup() {
|
|
// setup 跑在页面加载时、任何任务开始之前,此刻的图标就是 ComfyUI 的常态图标,
|
|
// 记下来供关闭开关时还原。不要退回写死的 /favicon.ico —— 新版 ComfyUI 上它是 404。
|
|
const originalFavicon = document.querySelector("link[rel='icon']")?.href || null;
|
|
|
|
function updateFavicon(dataUrl) {
|
|
const href = dataUrl || originalFavicon;
|
|
if (!href) return; // 没有可还原的目标就别乱动,交给 ComfyUI 自己管
|
|
let link = document.querySelector("link[rel='icon']");
|
|
if (!link) {
|
|
link = document.createElement("link");
|
|
link.rel = "icon";
|
|
document.head.appendChild(link);
|
|
}
|
|
link.href = href;
|
|
}
|
|
|
|
function applyLogo() {
|
|
const enabled = app.ui.settings.getSettingValue("KayTool.EnableCustomWebLogo");
|
|
const logo = app.ui.settings.getSettingValue("KayTool.CustomWebLogo");
|
|
const usable = enabled && typeof logo === "string" && logo.startsWith("data:image/");
|
|
updateFavicon(usable ? logo : null);
|
|
}
|
|
|
|
app.ui.settings.addSetting({
|
|
id: "KayTool.EnableCustomWebLogo",
|
|
name: "Use a custom browser tab icon",
|
|
type: "boolean",
|
|
defaultValue: true,
|
|
tooltip: "Only affects the browser tab icon (favicon). Turn this off to keep ComfyUI's own icon.",
|
|
category: ["KayTool", "Browser Tab Icon", "EnableCustomWebLogo"],
|
|
onChange: () => applyLogo(),
|
|
});
|
|
|
|
app.ui.settings.addSetting({
|
|
id: "KayTool.CustomWebLogo",
|
|
name: "Icon image (must be < 1MB)",
|
|
type: "image",
|
|
tooltip: "Replaces the browser tab icon only, not the ComfyUI logo in the interface. File must be < 1MB.",
|
|
defaultValue: null,
|
|
category: ["KayTool", "Browser Tab Icon", "CustomWebLogo"],
|
|
onChange: () => applyLogo(),
|
|
});
|
|
|
|
applyLogo();
|
|
},
|
|
});
|