v2.0.4 Add ComfyUI menu integration

This commit is contained in:
artstich
2026-01-03 04:10:36 +08:00
parent a7bc7bcbc2
commit 2037f562cf
3 changed files with 105 additions and 378 deletions
+6
View File
@@ -0,0 +1,6 @@
[.ShellClassInfo]
IconResource=C:\WINDOWS\System32\SHELL32.dll,45
[ViewState]
Mode=
Vid=
FolderType=Generic
+18 -62
View File
@@ -778,7 +778,7 @@
if (dragOption1 && dragOption2) { dragOption1.classList.toggle('selected', this.linkMode === 1); dragOption2.classList.toggle('selected', this.linkMode === 0); }
},
saveModeToStorage() { localStorage.setItem('NodeAlignProRunButtonLink', this.linkMode.toString()); },
loadModeFromStorage() { const saved = localStorage.getItem('NodeAlignProRunButtonLink'); if (saved) { this.linkMode = parseInt(saved); this.linkMode === 1 && setTimeout(() => this.syncRunButtonPosition(), 100); } return this.linkMode; }
loadModeFromStorage() { const saved = localStorage.getItem('NodeAlignProRunButtonLink'); if (saved) { this.linkMode = parseInt(saved); if (this.linkMode === 1) { setTimeout(() => this.syncRunButtonPosition(), 100); } this.updateDropdownText(); } return this.linkMode; } // 关键:加载后也要更新菜单显示
};
// 【== 解耦式容器控制器 ==】
@@ -2023,6 +2023,7 @@
case 'hDispMode1_Follow': window.__hMgr_DisplayMode && window.__hMgr_DisplayMode.setFollowingMode(); break;
}
};
window.__hMenu_Selection = __hMenu_Selection; // 暴露到全局
// 【== 初始化流程 ==】
const __hInit_hNAP = () => {
@@ -2030,6 +2031,7 @@
setTimeout(() => {
hLog.debug('NodeAlignPro核心组件初始化完毕! 请等待其它插件加载...</br>🔥v2.0.3_rc新版教程文档请点击:右键菜单>【使用教程】查看...');
window.containerController = new __hController_hNAPKit(container), window.__hMgr_PopEl__Position = new __hMgr_PopEl__Position(), window.__hMgr_PopEl__Position.init(container), window.__hMgr_MenuHide = new __hMgr_MenuHide(); __hInit_AllIcons(), __hInit_MainInterface(), __hInit_hMenu__Dropdown(); window.__hColor_Module = new __hColor_Module(); __hInit_ColorPicker(); window.NodeAlignProSettingsManager = new __hMgr_Settings(); // 初始化设置管理器
window.__hMenu_Selection = __hMenu_Selection; window.__hMgr_ACbar = __hMgr_ACbar; // 确保关键函数暴露
window.__hMgr_DisplayMode = new __hMgr_DisplayMode(); const savedDisplayMode = localStorage.getItem('NodeAlignProDisplayMode'); savedDisplayMode === 'following' ? (window.__hMgr_DisplayMode.setFollowingMode(), hLog.info('显示模式: 跟随选框')) : (window.__hMgr_DisplayMode.setPermanentMode(), hLog.info('显示模式: 常驻显示'));
hLog.log('NodeAlignPro 插件初始化完成'); setTimeout(() => { __hMgr_ACbar.loadModeFromStorage(); hLog.info('联动模式: 已禁用'); __hMgr_ACbar.linkMode === 1 && __hMgr_ACbar.syncRunButtonPosition(); hLog.info('联动模式: 已启用'); }, 500);
setTimeout(() => { const debugInfo = document.querySelector('.hDebugInfo'); if (debugInfo) debugInfo.style.display = 'none'; hLog.info('debugInfo 已自动隐藏 (24秒超时)'); }, 3000); window.hScreenColorPicker = window.__hColor_Module?.screenColorPicker;
@@ -2044,22 +2046,15 @@
// =========== NodeAlignPro 设置管理器 ===========
class __hMgr_Settings {
constructor() {
this.settings = {};
this.init();
}
init() {
// 从localStorage加载保存的设置
this.loadSettingsFromStorage();
}
constructor() { this.settings = {}; this.init(); }
init() { this.loadSettingsFromStorage(); setTimeout(() => this.checkAndFixLinkMode(), 1000); }
// 加载本地存储的设置
loadSettingsFromStorage() {
try {
const showLog = localStorage.getItem('NodeAlignPro_ShowOperationLog'); if (showLog !== null) this.setShowOperationLog(showLog === 'true'); // 操作日志显示
const linkMode = localStorage.getItem('NodeAlignProRunButtonLink'); if (linkMode !== null) this.setLinkMode(parseInt(linkMode)); // 拖拽方式
const linkMode = localStorage.getItem('NodeAlignProRunButtonLink');
if (linkMode !== null) { this.setLinkMode(parseInt(linkMode)); hLog.debug('--@hSetting', `从存储加载拖拽方式: ${parseInt(linkMode)}`); } //拖拽模式
const displayMode = localStorage.getItem('NodeAlignProDisplayMode'); if (displayMode !== null) { this.setDisplayMode(displayMode === 'permanent' ? 'hDispMode0_Always' : 'hDispMode1_Follow'); } // 显示模式
const colorMode = localStorage.getItem('NodeAlignPro_ColorApplyMode'); if (colorMode !== null) this.setColorApplyMode(parseInt(colorMode)); // 上色模式
const newVersionTips = localStorage.getItem('NodeAlignPro_NewVersionTips'); if (newVersionTips !== null) this.setNewVersionTips(newVersionTips === 'true'); // 新版说明
@@ -2074,59 +2069,35 @@
// 设置操作日志显示
setShowOperationLog(show) {
const debugElement = document.getElementById('hDebugInfo_V2');
if (debugElement) {
debugElement.style.setProperty('display', show ? 'block' : 'none', 'important');
}
localStorage.setItem('NodeAlignPro_ShowOperationLog', show.toString());
hLog.info('--@hSetting', `操作日志${show ? '已开启' : '已关闭'}`);
const debugElement = document.getElementById('hDebugInfo_V2'); if (debugElement) { debugElement.style.setProperty('display', show ? 'block' : 'none', 'important'); }
localStorage.setItem('NodeAlignPro_ShowOperationLog', show.toString()); hLog.info('--@hSetting', `操作日志${show ? '已开启' : '已关闭'}`);
}
// 设置拖拽方式
setLinkMode(mode) {
if (window.__hMgr_ACbar) {
__hMgr_ACbar.setLinkMode(mode);
// 同步更新右键菜单显示
const dragBtn = document.querySelector('[data-target="hCMP-hSel__drag-options"]');
const dragOption1 = document.querySelector('[data-value="hDragMode0_Link"]');
const dragOption2 = document.querySelector('[data-value="hDragMode1_Split"]');
if (dragBtn) dragBtn.textContent = mode === 1 ? '联 动' : '解 耦';
if (dragOption1 && dragOption2) { dragOption1.classList.toggle('selected', mode === 1); dragOption2.classList.toggle('selected', mode === 0); }
try {
const value = mode === 1 ? 'hDragMode0_Link' : 'hDragMode1_Split', __hMenu_Selection = window.__hMenu_Selection; // 直接调用现有的右键菜单处理函数。如果找不到函数,直接调用联动管理器
if (typeof __hMenu_Selection === 'function') __hMenu_Selection(value); else if (window.__hMgr_ACbar) window.__hMgr_ACbar.setLinkMode(mode);
hLog.info('--@hSetting', `拖拽方式已设置为: ${mode === 1 ? '联动' : '解耦'}`);
}
} catch (error) { hLog.error('--@hSetting', '设置拖拽方式失败:', error); }
}
// 设置UI缩放
setUIScale(scaleValue) {
const scaleMapping = {
'hUIScale_0_5x': 0.5,
'hUIScale_0_75x': 0.75,
'hUIScale_1x': 1.0,
'hUIScale_1_25x': 1.25,
'hUIScale_1_5x': 1.5,
'hUIScale_2x': 2.0
};
const scaleMapping = { 'hUIScale_0_5x': 0.5, 'hUIScale_0_75x': 0.75, 'hUIScale_1x': 1.0, 'hUIScale_1_25x': 1.25, 'hUIScale_1_5x': 1.5, 'hUIScale_2x': 2.0 };
const targetScale = scaleMapping[scaleValue];
if (targetScale && window.containerController) {
const container = document.getElementById('hNodeAlignKit');
if (container) {
const containerRect = container.getBoundingClientRect();
const centerX = containerRect.left + containerRect.width / 2;
const centerY = containerRect.top + containerRect.height / 2;
const containerRect = container.getBoundingClientRect(), centerX = containerRect.left + containerRect.width / 2, centerY = containerRect.top + containerRect.height / 2;
window.containerController.zoomToScale(targetScale, centerX, centerY);
// 同步更新右键菜单显示
const scaleBtn = document.querySelector('[data-target="hCMP-hSel__scale-options"]');
if (scaleBtn) {
const scaleText = { 'hUIScale_0_5x': '0.5x', 'hUIScale_0_75x': '0.75x', 'hUIScale_1x': '1x', 'hUIScale_1_25x': '1.25x', 'hUIScale_1_5x': '1.5x', 'hUIScale_2x': '2x' }[scaleValue];
scaleBtn.textContent = scaleText;
}
hLog.info('--@hSetting', `UI缩放已设置为: ${targetScale}x`);
}
}
@@ -2140,8 +2111,6 @@
} else if (mode === "hDispMode1_Follow") {
window.__hMgr_DisplayMode.setFollowingMode(); hLog.info('--@hSetting', '显示模式已设置为: 跟随选框');
}
const displayBtn = document.querySelector('[data-target="hCMP-hSel__display-options"]'); // 同步更新右键菜单显示
if (displayBtn) { displayBtn.textContent = mode === "hDispMode0_Always" ? '常驻显示' : '跟随选框'; }
}
@@ -2165,32 +2134,21 @@
// 设置对齐按钮颜色
setAlignButtonColor(hexColor) {
const r = parseInt(hexColor.substr(0, 2), 16);
const g = parseInt(hexColor.substr(2, 2), 16);
const b = parseInt(hexColor.substr(4, 6), 16);
const rgbValue = `${r}, ${g}, ${b}`;
const r = parseInt(hexColor.substr(0, 2), 16), g = parseInt(hexColor.substr(2, 2), 16), b = parseInt(hexColor.substr(4, 6), 16), rgbValue = `${r}, ${g}, ${b}`;
document.documentElement.style.setProperty('--hC_hBtn_svg', rgbValue);
localStorage.setItem('NodeAlignPro_AlignButtonColor', hexColor); hLog.info('--@hSetting', `对齐按钮颜色已更新为: #${hexColor} (RGB: ${rgbValue})`);
}
// 设置工具栏背景色
setToolbarBgColor(hexColor) {
const r = parseInt(hexColor.substr(0, 2), 16);
const g = parseInt(hexColor.substr(2, 2), 16);
const b = parseInt(hexColor.substr(4, 6), 16);
const rgbValue = `${r}, ${g}, ${b}`;
const r = parseInt(hexColor.substr(0, 2), 16), g = parseInt(hexColor.substr(2, 2), 16), b = parseInt(hexColor.substr(4, 6), 16), rgbValue = `${r}, ${g}, ${b}`;
document.documentElement.style.setProperty('--hC_Bg', rgbValue);
localStorage.setItem('NodeAlignPro_ToolbarBgColor', hexColor); hLog.info('--@hSetting', `工具栏背景色已更新为: #${hexColor} (RGB: ${rgbValue})`);
}
// 设置工具栏透明度
setToolbarOpacity(opacity) {
const alignProElement = document.getElementById('h2__hNodeAlignPro'); if (alignProElement) { alignProElement.style.opacity = (opacity / 100).toString(); }
localStorage.setItem('NodeAlignPro_ToolbarOpacity', opacity.toString()); hLog.info('--@hSetting', `工具栏透明度已设置为: ${opacity}%`);
}
@@ -2199,12 +2157,10 @@
const debugInfo = document.querySelector('.hDebugInfo');
if (debugInfo) {
debugInfo.style.display = show ? 'block' : 'none';
if (show) { setTimeout(() => { if (debugInfo.style.display !== 'none') { debugInfo.style.display = 'none'; this.setNewVersionTips(false); } }, 3000); } // 如果开启,3秒后自动隐藏
}
localStorage.setItem('NodeAlignPro_NewVersionTips', show.toString());
hLog.info('--@hSetting', `新版说明已${show ? '显示' : '隐藏'}`);
localStorage.setItem('NodeAlignPro_NewVersionTips', show.toString()); hLog.info('--@hSetting', `新版说明已${show ? '显示' : '隐藏'}`);
}
}
+81 -316
View File
@@ -2,424 +2,189 @@ import { app } from "../../scripts/app.js";
const NodeAlignProSettings = [
{
id: "hNodeAlignPro.ShowOperationLog",
name: "显示操作日志",
type: "boolean",
id: "hNodeAlignPro.ShowOperationLog", name: "显示操作日志", type: "boolean",
defaultValue: false,
category: ["🔥 NodeAlignPro", "开发人员选项", "显示操作日志"],
category: ["🔥 NodeAlignPro", "Z开发人员选项", "显示操作日志"],
tooltip: "开启后,插件操作日志将输出到页面左上角,方便进阶用户调试",
onChange: (value) => { try { if (window.NodeAlignProSettingsManager) { window.NodeAlignProSettingsManager.setShowOperationLog(value); } } catch (error) { console.error('设置操作日志显示失败:', error); } }
},
{
id: "hNodeAlignPro.hReset", name: "⚠强制重置NodeAlignPro插件", type: "boolean",
defaultValue: false,
category: ["🔥 NodeAlignPro", "Z开发人员选项", "⚠强制重置NodeAlignPro插件"],
tooltip: "⚠此操作会强制刷新页面,请务必先保存工作流! 开启后会强制重建NodeAlignPro插件,仅在插件异常时使用! ",
onChange: (value) => {
try {
if (window.NodeAlignProSettingsManager) {
window.NodeAlignProSettingsManager.setShowOperationLog(value);
}
} catch (error) { console.error('设置操作日志显示失败:', error); }
if (value) try {
if (typeof __hReset__hNAP_State === 'function') __hReset__hNAP_State(); else resetNodeAlignProManually(); // 1. 调用核心文件中的重置函数。如果核心重置函数不存在,执行手动重置
resetAllSettings(); clearAllStorage(); // 2. 重置所有设置;3. 清除所有本地存储
setTimeout(() => { // 4. 刷新页面以完全重置插件
const isResetEnabled = app.ui?.settings?.getSettingValue?.("hNodeAlignPro.hReset"); // 检查开关是否处于关闭状态
if (isResetEnabled === true) location.reload(); // 只有当开关处于开启状态时才刷新
else { if (hLog) hLog.info('--@hSetting', '重置操作已完成,开关已自动关闭,无需刷新页面'); console.log('重置操作已完成,开关已自动关闭,无需刷新页面'); } // 如果开关已关闭,则不刷新,仅记录日志
}, 500);
if (hLog) hLog.info('--@hSetting', '插件已通过设置菜单强制重置,页面将重新加载...');
} catch (error) { console.error('重置插件失败:', error); if (hLog) hLog.error('--@hSetting', '重置失败:', error); }
}
},
/* {
id: "hNodeAlignPro.hReset",
name: "⚠强制重置NodeAlignPro插件",
type: "boolean",
defaultValue: false,
category: ["🔥 NodeAlignPro", "开发人员选项", "⚠强制重置NodeAlignPro插件"],
tooltip: "⚠此操作会强制刷新页面,请务必先保存工作流! 开启后会强制重建NodeAlignPro插件,仅在插件异常时使用! ",
onChange: (value) => {
if (value && window.NodeAlignProSettingsManager) {
window.NodeAlignProSettingsManager.resetPlugin();
}
}
}, */
{
id: "hNodeAlignPro.hReset",
name: "⚠强制重置NodeAlignPro插件",
type: "boolean",
defaultValue: false,
category: ["🔥 NodeAlignPro", "开发人员选项", "⚠强制重置NodeAlignPro插件"],
tooltip: "⚠此操作会强制刷新页面,请务必先保存工作流! 开启后会强制重建NodeAlignPro插件,仅在插件异常时使用! ",
onChange: (value) => {
if (value) {
try {
// 1. 调用核心文件中的重置函数
if (typeof __hReset__hNAP_State === 'function') {
__hReset__hNAP_State();
} else {
// 如果核心重置函数不存在,执行手动重置
resetNodeAlignProManually();
}
resetAllSettings();
clearAllStorage();
// 4. 刷新页面以完全重置插件
/* setTimeout(() => {
location.reload();
}, 500); */
// 4. 刷新页面以完全重置插件 - 添加条件判断
setTimeout(() => {
// 检查开关是否处于关闭状态
const isResetEnabled = app.ui?.settings?.getSettingValue?.("hNodeAlignPro.hReset");
// 只有当开关处于开启状态时才刷新
if (isResetEnabled === true) {
location.reload();
} else {
// 如果开关已关闭,则不刷新,仅记录日志
if (hLog) {
hLog.info('--@hSetting', '重置操作已完成,开关已自动关闭,无需刷新页面');
}
console.log('重置操作已完成,开关已自动关闭,无需刷新页面');
}
}, 500);
hLog && hLog.info('--@hSetting', '插件已通过设置菜单强制重置,页面将重新加载...');
} catch (error) { console.error('重置插件失败:', error); hLog && hLog.error('--@hSetting', '重置失败:', error); }
}
}
},
/* {
id: "hNodeAlignPro.button_test",
name: "测试",
type: "input",
defaultValue: "测试文本",
category: ["🔥 NodeAlignPro", "NodeAlignPro预置颜色", "测试"],
onChange: (newVal) => {
// 相关逻辑待实现...
}
}, */
// { id: "hNodeAlignPro.button_test", name: "测试", type: "input", defaultValue: "测试文本", category: ["🔥 NodeAlignPro", "NodeAlignPro预置颜色", "测试"], onChange: (newVal) => { } },
{
id: "hNodeAlignPro.linkMode",
name: "拖拽方式",
type: "combo",
options: [
{ value: "hDragMode1_Split", text: "解 耦(默认)" },
{ value: "hDragMode0_Link", text: "联 动" }
],
id: "hNodeAlignPro.linkMode", name: "拖拽方式", type: "combo",
options: [{ value: "hDragMode1_Split", text: "解 耦(默认)" }, { value: "hDragMode0_Link", text: "联 动" }],
defaultValue: "hDragMode1_Split",
category: ["🔥 NodeAlignPro", "NodeAlignPro基本设置", "拖拽方式"],
tooltip: "切换是否联动[运行/Action]按钮到插件面板(与插件右键菜单设置同步)",
onChange: (value) => {
try {
if (window.NodeAlignProSettingsManager) {
const mode = value === "hDragMode0_Link" ? 1 : 0;
window.NodeAlignProSettingsManager.setLinkMode(mode);
}
const mode = value === "hDragMode0_Link" ? 1 : 0; // 直接调用全局的处理函数。或者通过设置管理器。或者直接调用联动管理器
(typeof __hMenu_Selection === 'function' && __hMenu_Selection(value)) || (window.NodeAlignProSettingsManager && window.NodeAlignProSettingsManager.setLinkMode(mode)) || (window.__hMgr_ACbar && window.__hMgr_ACbar.setLinkMode(mode)) || console.error('无法找到拖拽方式处理函数');
} catch (error) { console.error('设置拖拽方式失败:', error); }
}
},
{
id: "hNodeAlignPro.UIScale",
name: "UI缩放",
type: "combo",
options: [
{ value: "hUIScale_0_5x", text: "0.5x" },
{ value: "hUIScale_0_75x", text: "0.75x" },
{ value: "hUIScale_1x", text: "1x(默认)" },
{ value: "hUIScale_1_25x", text: "1.25x" },
{ value: "hUIScale_1_5x", text: "1.5x" },
{ value: "hUIScale_2x", text: "2x" }
],
id: "hNodeAlignPro.UIScale", name: "UI缩放", type: "combo",
options: [{ value: "hUIScale_0_5x", text: "0.5x" }, { value: "hUIScale_0_75x", text: "0.75x" }, { value: "hUIScale_1x", text: "1x(默认)" }, { value: "hUIScale_1_25x", text: "1.25x" }, { value: "hUIScale_1_5x", text: "1.5x" }, { value: "hUIScale_2x", text: "2x" }],
defaultValue: "hUIScale_1x",
category: ["🔥 NodeAlignPro", "NodeAlignPro基本设置", "UI缩放"],
tooltip: "调整插件UI缩放比例(与插件右键菜单设置同步)",
onChange: (value) => {
try {
if (window.NodeAlignProSettingsManager) {
window.NodeAlignProSettingsManager.setUIScale(value);
}
} catch (error) { console.error('设置UI缩放失败:', error); }
}
onChange: (value) => { try { if (window.NodeAlignProSettingsManager) { window.NodeAlignProSettingsManager.setUIScale(value); } } catch (error) { console.error('设置UI缩放失败:', error); } }
},
/* {
id: "hNodeAlignPro.UIScale_v2",
name: "UI缩放v2",
type: "combo",
options: [
{ value: "hUIScale_0_5x", text: "0.5x" },
{ value: "hUIScale_0_75x", text: "0.75x" },
{ value: "hUIScale_1x", text: "1x(默认)" },
{ value: "hUIScale_1_25x", text: "1.25x" },
{ value: "hUIScale_1_5x", text: "1.5x" },
{ value: "hUIScale_2x", text: "2x" }
],
defaultValue: "hUIScale_1x",
category: ["🔥 NodeAlignPro", "NodeAlignPro基本设置", "UI缩放v2"],
attrs: {
editable: true,
filter: true,
filterPlaceholder: "输入/选择缩放比例...",
showClear: true,
loading: false,
loadingIcon: "pi pi-spinner pi-spin"
},
onChange: (newVal, oldVal) => {
try {
if (window.containerController && oldVal !== newVal) {
const scaleMapping = {
'hUIScale_0_5x': 0.5,
'hUIScale_0_75x': 0.75,
'hUIScale_1x': 1.0,
'hUIScale_1_25x': 1.25,
'hUIScale_1_5x': 1.5,
'hUIScale_2x': 2.0
};
const targetScale = scaleMapping[newVal];
if (targetScale) {
const container = document.getElementById('hNodeAlignKit');
if (container) {
const containerRect = container.getBoundingClientRect();
const centerX = containerRect.left + containerRect.width / 2;
const centerY = containerRect.top + containerRect.height / 2;
window.containerController.zoomToScale(targetScale, centerX, centerY);
hLog && hLog.info('--@hSetting', `UI缩放v2已设置为: ${targetScale}x`);
}
/* {
id: "hNodeAlignPro.UIScale_v2", name: "UI缩放v2", type: "combo",
options: [{ value: "hUIScale_0_5x", text: "0.5x" }, { value: "hUIScale_0_75x", text: "0.75x" }, { value: "hUIScale_1x", text: "1x(默认)" }, { value: "hUIScale_1_25x", text: "1.25x" }, { value: "hUIScale_1_5x", text: "1.5x" }, { value: "hUIScale_2x", text: "2x" }],
defaultValue: "hUIScale_1x",
category: ["🔥 NodeAlignPro", "NodeAlignPro基本设置", "UI缩放v2"],
attrs: { editable: true, filter: true, filterPlaceholder: "输入/选择缩放比例...", showClear: true, loading: false, loadingIcon: "pi pi-spinner pi-spin" },
onChange: (newVal, oldVal) => {
try {
if (window.containerController && oldVal !== newVal) {
const scaleMapping = { 'hUIScale_0_5x': 0.5, 'hUIScale_0_75x': 0.75, 'hUIScale_1x': 1.0, 'hUIScale_1_25x': 1.25, 'hUIScale_1_5x': 1.5, 'hUIScale_2x': 2.0 }, targetScale = scaleMapping[newVal];
if (targetScale) {
const container = document.getElementById('hNodeAlignKit');
if (container) {
const containerRect = container.getBoundingClientRect(), centerX = containerRect.left + containerRect.width / 2, centerY = containerRect.top + containerRect.height / 2;
window.containerController.zoomToScale(targetScale, centerX, centerY); if (hLog) hLog.info('--@hSetting', `UI缩放v2已设置为: ${targetScale}x`);
}
}
} catch (error) {
console.error('设置UI缩放v2失败:', error);
}
},
}, */
// ??????
} catch (error) { console.error('设置UI缩放v2失败:', error); }
},
}, */
{
id: "hNodeAlignPro.WorkMode",
name: "工作模式",
type: "combo",
options: [
{ value: "hApBar2_Align", text: "-对 齐-" }
],
id: "hNodeAlignPro.WorkMode", name: "工作模式", type: "combo",
options: [{ value: "hApBar2_Align", text: "-对 齐-" }],
defaultValue: "hApBar2_Align",
category: ["🔥 NodeAlignPro", "NodeAlignPro基本设置", "工作模式"],
tooltip: "切换插件工作模式(与插件右键菜单设置同步)",
onChange: (value) => {
try {
if (window.NodeAlignProSettingsManager) {
window.NodeAlignProSettingsManager.setWorkMode(value);
}
} catch (error) { console.error('设置工作模式失败:', error); }
}
onChange: (value) => { try { if (window.NodeAlignProSettingsManager) { window.NodeAlignProSettingsManager.setWorkMode(value); } } catch (error) { console.error('设置工作模式失败:', error); } }
},
{
id: "hNodeAlignPro.DisplayMode",
name: "显示模式",
type: "combo",
options: [
{ value: "hDispMode0_Always", text: "常驻显示(默认)" },
{ value: "hDispMode1_Follow", text: "跟随选框" }
],
id: "hNodeAlignPro.DisplayMode", name: "显示模式", type: "combo",
options: [{ value: "hDispMode0_Always", text: "常驻显示(默认)" }, { value: "hDispMode1_Follow", text: "跟随选框" }],
defaultValue: "hDispMode0_Always",
category: ["🔥 NodeAlignPro", "NodeAlignPro基本设置", "显示模式"],
tooltip: "切换插件面板的显示模式(与插件右键菜单设置同步)",
onChange: (value) => {
try {
if (window.NodeAlignProSettingsManager) {
window.NodeAlignProSettingsManager.setDisplayMode(value);
}
} catch (error) { console.error('设置显示模式失败:', error); }
}
onChange: (value) => { try { if (window.NodeAlignProSettingsManager) { window.NodeAlignProSettingsManager.setDisplayMode(value); } } catch (error) { console.error('设置显示模式失败:', error); } }
},
{
id: "hNodeAlignPro.hColor_SVG",
name: "对齐按钮颜色",
type: "color",
id: "hNodeAlignPro.hColor_SVG", name: "对齐按钮颜色", type: "color",
defaultValue: "6B6B70",
category: ["🔥 NodeAlignPro", "NodeAlignPro预置颜色", "对齐按钮颜色"],
tooltip: "控制对齐按钮颜色,修改CSS变量--hC_hBtn_svg",
onChange: (newVal) => {
try {
if (window.NodeAlignProSettingsManager) {
window.NodeAlignProSettingsManager.setAlignButtonColor(newVal);
}
} catch (error) { console.error('设置对齐按钮颜色失败:', error); }
}
onChange: (newVal) => { try { if (window.NodeAlignProSettingsManager) { window.NodeAlignProSettingsManager.setAlignButtonColor(newVal); } } catch (error) { console.error('设置对齐按钮颜色失败:', error); } }
},
{
id: "hNodeAlignPro.hColor_bg",
name: "工具栏背景色",
type: "color",
id: "hNodeAlignPro.hColor_bg", name: "工具栏背景色", type: "color",
defaultValue: "18181B",
category: ["🔥 NodeAlignPro", "NodeAlignPro预置颜色", "工具栏背景色"],
tooltip: "控制对齐组件的背景色",
onChange: (newVal) => {
try {
if (window.NodeAlignProSettingsManager) {
window.NodeAlignProSettingsManager.setToolbarBgColor(newVal);
}
} catch (error) { console.error('设置工具栏背景色失败:', error); }
}
onChange: (newVal) => { try { if (window.NodeAlignProSettingsManager) { window.NodeAlignProSettingsManager.setToolbarBgColor(newVal); } } catch (error) { console.error('设置工具栏背景色失败:', error); } }
},
{
id: "hNodeAlignPro.hOpacity",
name: "工具栏透明度",
type: "slider",
id: "hNodeAlignPro.hOpacity", name: "工具栏透明度", type: "slider",
defaultValue: 95,
attrs: { min: 0, max: 100, step: 1 },
category: ["🔥 NodeAlignPro", "NodeAlignPro预置颜色", "工具栏透明度"],
tooltip: "控制对齐组件h2__hNodeAlignPro的透明度",
onChange: (newVal) => {
try {
if (window.NodeAlignProSettingsManager) {
window.NodeAlignProSettingsManager.setToolbarOpacity(newVal);
}
} catch (error) { console.error('设置工具栏透明度失败:', error); }
}
onChange: (newVal) => { try { if (window.NodeAlignProSettingsManager) { window.NodeAlignProSettingsManager.setToolbarOpacity(newVal); } } catch (error) { console.error('设置工具栏透明度失败:', error); } }
},
{
id: "hNodeAlignPro.NewVersionTips",
name: "新版说明",
type: "boolean",
id: "hNodeAlignPro.NewVersionTips", name: "新版说明", type: "boolean",
defaultValue: true,
category: ["🔥 NodeAlignPro", "NodeAlignPro基本设置", "新版说明"],
tooltip: "v2.0.3_rc新版功能:按Shift、Alt、Ctrl Alt切换不同色卡模式... Alt+对齐按钮:对齐到“反向基准”节点^_^",
onChange: (value) => {
try {
if (window.NodeAlignProSettingsManager) {
window.NodeAlignProSettingsManager.setNewVersionTips(value);
}
} catch (error) { console.error('设置新版说明失败:', error); }
}
onChange: (value) => { try { if (window.NodeAlignProSettingsManager) { window.NodeAlignProSettingsManager.setNewVersionTips(value); } } catch (error) { console.error('设置新版说明失败:', error); } }
},
{
id: "hNodeAlignPro.ColorApplyMode",
name: "上色模式",
type: "combo",
options: [
{ value: "1", text: "整体色" },
{ value: "0", text: "仅标题" }
],
id: "hNodeAlignPro.ColorApplyMode", name: "上色模式", type: "combo",
options: [ { value: "1", text: "整体色" }, { value: "0", text: "仅标题" } ],
defaultValue: "1",
category: ["🔥 NodeAlignPro", "NodeAlignPro颜色设置", "上色模式"],
category: ["🔥 NodeAlignPro", "NodeAlignPro节点设置", "上色模式"],
tooltip: "设置节点上色模式:整体色(背景+标题)或仅标题色",
onChange: (value) => {
try {
if (window.NodeAlignProSettingsManager) {
const mode = parseInt(value);
window.NodeAlignProSettingsManager.setColorApplyMode(mode);
}
} catch (error) { console.error('设置上色模式失败:', error); }
}
onChange: (value) => { try { if (window.NodeAlignProSettingsManager) window.NodeAlignProSettingsManager.setColorApplyMode(parseInt(value)); } catch (error) { console.error('设置上色模式失败:', error); } }
}
];
// 初始化函数
function initNodeAlignProSettings() {
try {
// 延迟执行,确保核心文件已加载
setTimeout(() => {
if (window.NodeAlignProSettingsManager) {
// 设置管理器会自动从localStorage加载设置
console.log('NodeAlignPro 设置系统已初始化');
// 如果hLog存在,记录初始化成功
if (window.hLog) {
hLog.info('--@hSetting', 'NodeAlignPro 设置系统已初始化');
}
} else {
console.warn('NodeAlignProSettingsManager 未找到,设置可能未完全加载');
}
setTimeout(() => { // 延迟执行,确保核心文件已加载
if (window.NodeAlignProSettingsManager) { console.log('NodeAlignPro 设置系统已初始化'); if (window.hLog) hLog.info('--@hSetting', 'NodeAlignPro 设置系统已初始化'); } else console.warn('NodeAlignProSettingsManager 未找到,设置可能未完全加载'); // 设置管理器会自动从localStorage加载设置
}, 2000);
} catch (error) { console.error('初始化NodeAlignPro设置失败:', error); }
}
// ==================== 注册扩展 ====================
// 注册扩展
app.registerExtension({
name: "NodeAlignPro.Settings",
settings: NodeAlignProSettings,
name: "NodeAlignPro.Settings", settings: NodeAlignProSettings,
setup() {
if (app.ui?.settings?.addSetting) {
NodeAlignProSettings.forEach((setting) => {
try {
app.ui.settings.addSetting(setting);
} catch (err) {
console.warn(`[NodeAlignPro.Settings] 注册设置项${setting.id}失败:`, err);
}
});
// 初始化设置
initNodeAlignProSettings();
NodeAlignProSettings.forEach(setting => { try { app.ui.settings.addSetting(setting); } catch (err) { console.warn(`[NodeAlignPro.Settings] 注册设置项${setting.id}失败:`, err); } }); initNodeAlignProSettings(); // 注册设置项初始化设置
}
console.info("[NodeAlignPro.Settings] registered", NodeAlignProSettings.map(s => s.id));
},
// 添加beforeconfiguregraph方法,确保在合适时机初始化
beforeConfigureGraph(graph) {
// 延迟初始化,确保DOM已准备好
setTimeout(initNodeAlignProSettings, 2000);
}
beforeConfigureGraph(graph) { setTimeout(initNodeAlignProSettings, 2000); } // 延迟初始化,确保DOM已准备好
});
// 重置所有设置
function resetAllSettings() {
try {
const defaultSettings = {
"hNodeAlignPro.ShowOperationLog": false,
"hNodeAlignPro.hReset": false,
"hNodeAlignPro.button_test": "测试文本",
"hNodeAlignPro.linkMode": "hDragMode1_Split",
"hNodeAlignPro.UIScale": "hUIScale_1x",
"hNodeAlignPro.UIScale_v2": "hUIScale_1x",
"hNodeAlignPro.WorkMode": "hApBar2_Align",
"hNodeAlignPro.DisplayMode": "hDispMode0_Always",
"hNodeAlignPro.hColor_SVG": "6B6B70",
"hNodeAlignPro.hColor_bg": "18181B",
"hNodeAlignPro.hOpacity": 95,
"hNodeAlignPro.NewVersionTips": true
"hNodeAlignPro.ShowOperationLog": false, "hNodeAlignPro.hReset": false, "hNodeAlignPro.button_test": "测试文本",
"hNodeAlignPro.linkMode": "hDragMode1_Split", "hNodeAlignPro.UIScale": "hUIScale_1x", "hNodeAlignPro.UIScale_v2": "hUIScale_1x",
"hNodeAlignPro.WorkMode": "hApBar2_Align", "hNodeAlignPro.DisplayMode": "hDispMode0_Always", "hNodeAlignPro.hColor_SVG": "6B6B70",
"hNodeAlignPro.hColor_bg": "18181B", "hNodeAlignPro.hOpacity": 95, "hNodeAlignPro.NewVersionTips": true
};
// 设置每个配置项到默认值
Object.keys(defaultSettings).forEach(settingId => {
Object.keys(defaultSettings).forEach(settingId => { // 设置每个配置项到默认值
try { app.ui.settings?.setSettingValue?.(settingId, defaultSettings[settingId]); } catch (e) { console.warn(`重置设置 ${settingId} 失败:`, e); }
});
console.log('所有设置项已重置为默认值');
} catch (error) { console.error('重置设置项失败:', error); }
}
// 手动重置插件
function resetNodeAlignProManually() {
try {
// 重置容器位置和缩放
const container = document.getElementById('hNodeAlignKit');
if (container) { container.style.transform = 'translate(0px, 0px) scale(1)'; container.style.left = ''; container.style.top = ''; }
if (window.__hColor_Module) { window.__hColor_Module.reset(); }
if (window.__hMgr_DisplayMode) { window.__hMgr_DisplayMode.reset(); }
if (window.__hMgr_ACbar) { window.__hMgr_ACbar.setLinkMode(0); }
const container = document.getElementById('hNodeAlignKit'); // 重置容器位置和缩放
if (container) container.style.transform = 'translate(0px, 0px) scale(1)', container.style.left = '', container.style.top = '';
if (window.__hColor_Module) window.__hColor_Module.reset();
if (window.__hMgr_DisplayMode) window.__hMgr_DisplayMode.reset();
if (window.__hMgr_ACbar) window.__hMgr_ACbar.setLinkMode(0);
console.log('NodeAlignPro 已手动重置');
} catch (error) { console.error('手动重置失败:', error); }
}
// 清除所有本地存储
function clearAllStorage() {
try {
const storageKeys = [
'NodeAlignPro_ShowOperationLog',
'NodeAlignPro_WorkMode',
'NodeAlignPro_AlignButtonColor',
'NodeAlignPro_ToolbarBgColor',
'NodeAlignPro_ToolbarOpacity',
'NodeAlignPro_NewVersionTips',
'NodeAlignPro_LinkMode',
'NodeAlignProPosition',
'NodeAlignProRunButtonLink',
'NodeAlignProDisplayMode',
'NodeAlignPro_ColorApplyMode'
];
const storageKeys = ['NodeAlignPro_ShowOperationLog', 'NodeAlignPro_WorkMode', 'NodeAlignPro_AlignButtonColor', 'NodeAlignPro_ToolbarBgColor', 'NodeAlignPro_ToolbarOpacity', 'NodeAlignPro_NewVersionTips', 'NodeAlignPro_LinkMode', 'NodeAlignProPosition', 'NodeAlignProRunButtonLink', 'NodeAlignProDisplayMode', 'NodeAlignPro_ColorApplyMode'];
storageKeys.forEach(key => { localStorage.removeItem(key); }); console.log('所有相关localStorage项已清除');
} catch (error) { console.error('清除localStorage失败:', error); }
}