fix(shell): -NoExclude 只作用于本次运行,不再写回状态文件(避免调试后默认失去抓屏隐身)

This commit is contained in:
2026-09-27 14:04:51 +08:00
parent 472bbe243e
commit 0c730f424c
+8 -1
View File
@@ -213,9 +213,16 @@ if (Test-Path $stateFile) {
$script:state.fullscreen = $false $script:state.fullscreen = $false
} catch { Write-Warning "state file ignored: $($_.Exception.Message)" } } catch { Write-Warning "state file ignored: $($_.Exception.Message)" }
} }
# -NoExclude 只是本次运行的调试开关,不允许被写回状态文件(否则以后默认就不隐身了)
$script:persistExclude = [bool]$script:state.exclude
function Save-State { function Save-State {
try { ($script:state | ConvertTo-Json -Depth 3) | Set-Content -Path $stateFile -Encoding UTF8 } catch {} try {
$out = [ordered]@{}
foreach ($k in $script:state.Keys) { $out[$k] = $script:state[$k] }
if ($NoExclude) { $out.exclude = $script:persistExclude }
($out | ConvertTo-Json -Depth 3) | Set-Content -Path $stateFile -Encoding UTF8
} catch {}
} }
# ---------------------------------------------------------------- 窗口 # ---------------------------------------------------------------- 窗口