From a4a9c84f0d78fc9d7d5d79658d7bf0f40256d2e2 Mon Sep 17 00:00:00 2001 From: Tenney Date: Wed, 18 Sep 2024 10:45:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A0=B7=E5=BC=8F=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- node_info.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/node_info.js b/node_info.js index 6661905..d170bfb 100644 --- a/node_info.js +++ b/node_info.js @@ -109,8 +109,13 @@ const ButtonManager = { this.isInitialized = true; // 标记已经初始化 this.showContextMenu() - this.isPermanent = localStorage.getItem('NodeAlignerIsPermanent') == '1'; - this.isPermanent ? this.show() : this.hide(); + let isPermanent = localStorage.getItem('NodeAlignerIsPermanent'); + if(isPermanent) { + this.isPermanent = localStorage.getItem('NodeAlignerIsPermanent') == '1'; + this.isPermanent ? this.show() : this.hide(); + } else { + this.show() + } }, // 获取按钮配置 @@ -202,9 +207,6 @@ const ButtonManager = { const rect = this.buttonContainer.getBoundingClientRect(); this.dragStartX = rect.left; this.dragStartY = rect.top; - // 锁定宽度和高度,防止拖拽时改变 - this.buttonContainer.style.width = `${rect.width}px`; - this.buttonContainer.style.height = `${rect.height}px`; } }, @@ -259,10 +261,6 @@ const ButtonManager = { // 保存位置到 localStorage localStorage.setItem('NodeAlignerButtonContainerPosition', JSON.stringify({ top, left, right, bottom })); - - // 恢复自动宽度和高度 - this.buttonContainer.style.width = 'auto'; - this.buttonContainer.style.height = 'auto'; } }, // 恢复位置 @@ -273,6 +271,10 @@ const ButtonManager = { this.buttonContainer.style.bottom = savedPosition.bottom; this.buttonContainer.style.left = savedPosition.left; this.buttonContainer.style.right = savedPosition.right; + } else { + // 如果没有保存的位置信息,则使用默认位置 + this.buttonContainer.style.top = '20px'; + this.buttonContainer.style.right = '20px'; } }, // 获取当前选中的节点 @@ -438,7 +440,6 @@ function pollForCanvas() { // 监听左键单击事件 canvas.addEventListener('click', function (event) { event.preventDefault(); - console.log(event); // console.log(event); // 获取当前的 `LGraphCanvas` 数据 @@ -465,7 +466,7 @@ function pollForCanvas() { ButtonManager.setPosition(event.layerX, event.layerY - 40) } } - + }); } else { setTimeout(pollForCanvas, 1000); // 每隔 1 秒尝试查找一次