fix(host): 起浮窗不再经 cmd/start(那个黑控制台窗口);feat(shell): 相机按钮一键切换截图隐藏 + 标准齿轮设置图标
- 黑窗根因:spawnShell 用 cmd /c start 跑 .cmd,start 会新建控制台,批处理里的中文还被按 GBK 解析成乱码报错。
改成 spawn('powershell.exe', [-WindowStyle Hidden -File ...]) detached + windowsHide,无窗启动
- 标题栏新增相机按钮:一键切换『截图时隐藏本窗』(高亮=隐藏生效),设置面板里那项同步;
开发期要截图给别人看,点一下就可见
- 设置图标从'小太阳'换成标准齿轮
This commit is contained in:
+8
-14
@@ -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) } }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user