From 6d8dcd0b6967628932911b10639d668309122b0d Mon Sep 17 00:00:00 2001 From: luoxiaoxin123 <139680427+luoxiaoxin123@users.noreply.github.com> Date: Sun, 13 Sep 2026 22:32:58 +0800 Subject: [PATCH] =?UTF-8?q?install=20=E6=94=AF=E6=8C=81=E5=9C=A8=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E7=9B=AE=E5=BD=95=E5=86=85=E8=BF=90=E8=A1=8C=EF=BC=88?= =?UTF-8?q?src=3D=3Ddest=20=E8=B7=B3=E8=BF=87=E5=A4=8D=E5=88=B6=EF=BC=89?= =?UTF-8?q?=EF=BC=8C=E5=8D=95=E6=96=87=E4=BB=B6=E5=A4=8D=E5=88=B6=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E4=B8=8D=E5=86=8D=E4=B8=AD=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gatekeeper/control.mjs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/gatekeeper/control.mjs b/gatekeeper/control.mjs index 6391cc3..60a177d 100644 --- a/gatekeeper/control.mjs +++ b/gatekeeper/control.mjs @@ -65,15 +65,23 @@ function pingDaemon(port, timeoutMs = 400) { // ---------------------------------------------------------------- 安装 ------ async function cmdInstall() { + const sameDir = SCRIPT_DIR.toLowerCase() === TARGET_DIR.toLowerCase(); + if (sameDir) out('提示:当前就在安装目录内运行,文件视为最新,仅重新注册 hooks。'); mkdirSync(TARGET_DIR, { recursive: true }); let copied = 0; for (const f of INSTALL_FILES) { const src = path.join(SCRIPT_DIR, f); if (!existsSync(src)) continue; - // 升级安装时保留用户已调好的配置,只在首次安装时带入 - if (f === 'config.json' && existsSync(path.join(TARGET_DIR, f))) continue; - cpSync(src, path.join(TARGET_DIR, f)); - copied++; + const dest = path.join(TARGET_DIR, f); + // 升级安装时保留用户已调好的配置,只在首次安装时带入;从安装目录运行时跳过自身复制 + if (f === 'config.json' && existsSync(dest)) continue; + if (path.resolve(src).toLowerCase() === path.resolve(dest).toLowerCase()) continue; + try { + cpSync(src, dest); + copied++; + } catch (e) { + out(`⚠ 复制失败(文件被占用?关掉相关程序后重跑 install):${f} — ${e?.message || e}`); + } } out(`✓ 已复制 ${copied} 个文件 → ${TARGET_DIR}`);