From cb57f75577761cd7a5ec6c6d46adf83da88fd4a8 Mon Sep 17 00:00:00 2001
From: jiangchen <1703935164@qq.com>
Date: Sun, 27 Sep 2026 17:07:35 +0800
Subject: [PATCH] =?UTF-8?q?fix(host):=20=E8=B5=B7=E6=B5=AE=E7=AA=97?=
=?UTF-8?q?=E4=B8=8D=E5=86=8D=E7=BB=8F=20cmd/start=EF=BC=88=E9=82=A3?=
=?UTF-8?q?=E4=B8=AA=E9=BB=91=E6=8E=A7=E5=88=B6=E5=8F=B0=E7=AA=97=E5=8F=A3?=
=?UTF-8?q?=EF=BC=89=EF=BC=9Bfeat(shell):=20=E7=9B=B8=E6=9C=BA=E6=8C=89?=
=?UTF-8?q?=E9=92=AE=E4=B8=80=E9=94=AE=E5=88=87=E6=8D=A2=E6=88=AA=E5=9B=BE?=
=?UTF-8?q?=E9=9A=90=E8=97=8F=20+=20=E6=A0=87=E5=87=86=E9=BD=BF=E8=BD=AE?=
=?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=9B=BE=E6=A0=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 黑窗根因:spawnShell 用 cmd /c start 跑 .cmd,start 会新建控制台,批处理里的中文还被按 GBK 解析成乱码报错。
改成 spawn('powershell.exe', [-WindowStyle Hidden -File ...]) detached + windowsHide,无窗启动
- 标题栏新增相机按钮:一键切换『截图时隐藏本窗』(高亮=隐藏生效),设置面板里那项同步;
开发期要截图给别人看,点一下就可见
- 设置图标从'小太阳'换成标准齿轮
---
lib/host.js | 22 ++++++++--------------
shell/ui.html | 14 +++++++++++---
2 files changed, 19 insertions(+), 17 deletions(-)
diff --git a/lib/host.js b/lib/host.js
index 7d2aa6b..b6c249a 100644
--- a/lib/host.js
+++ b/lib/host.js
@@ -613,22 +613,16 @@ export function apply(ctx, config) {
}
async function spawnShell() {
- const cmd = shellPath()
- if (!fs.existsSync(cmd)) return { ok: false, error: `launcher not found: ${cmd}` }
- try {
- const shell = ctx.get('shell')
- const sp = ctx.get('sandboxPolicy')
- const policy = sp?.resolve?.({ mode: 'danger-full-access' })
- if (shell?.resolve && shell?.run) {
- const spec = shell.resolve({ command: `cmd /c start "" "${cmd}"`, ...(policy ? { sandboxPolicy: policy } : {}) })
- await shell.run(spec)
- return { ok: true, via: 'ctx.shell' }
- }
- } catch (e) { log('ctx.shell launch failed, fallback to spawn:', String(e?.message || e)) }
+ // 直接起 powershell(隐藏窗口)。**不要**走 `cmd /c start`:那会弹出一个黑色控制台窗口
+ // (用户已经看到过:标题 C:\WINDOWS\system32\cmd.exe,且批处理里的中文被 GBK 解析成乱码报错)。
+ const ps1 = path.join(REPO, 'shell', 'float-window.ps1')
+ if (!fs.existsSync(ps1)) return { ok: false, error: `shell script not found: ${ps1}` }
try {
const { spawn } = await import('node:child_process')
- spawn('cmd', ['/c', 'start', '', cmd], { detached: true, stdio: 'ignore', windowsHide: true }).unref()
- return { ok: true, via: 'spawn' }
+ spawn('powershell.exe',
+ ['-NoProfile', '-ExecutionPolicy', 'Bypass', '-WindowStyle', 'Hidden', '-File', ps1],
+ { detached: true, stdio: 'ignore', windowsHide: true }).unref()
+ return { ok: true, via: 'spawn powershell (hidden)' }
} catch (e) { return { ok: false, error: String(e?.message || e) } }
}
diff --git a/shell/ui.html b/shell/ui.html
index 96b9027..2dfcec8 100644
--- a/shell/ui.html
+++ b/shell/ui.html
@@ -568,10 +568,16 @@
+