feat(menu): 右键菜单改为「入队 + 单 worker」,多选只弹一个窗口

- 新增 scripts/scenemarshal-enqueue.vbs:经 wscript 隐藏调用,点击后只入队,
  不再闪控制台窗口
- explorer-media-rename.ps1 支持三种模式:-Enqueue 入队并确保 worker 在跑;
  -Worker 串行消费队列;都不带则为原来的直接执行(调试用)
- worker 用 worker.lock 独占,保证同一时刻只有一个窗口;队列空 20 秒后自动退出
- 队列在 %LOCALAPPDATA%\\SceneMarshal\\queue.jsonl,处理记录写 worker.log
- 修复子脚本输出混进函数返回值、导致 worker 把成功误判成失败的问题(Out-Host)
- 实测:快速连续入队 3 项 → 1 个 worker 顺序处理完;含空格/中文/方括号的
  路径原样传递;退出码判定正确
This commit is contained in:
ali
2026-11-19 18:07:56 +08:00
parent f2d1986ff1
commit 65fe02f705
3 changed files with 249 additions and 37 deletions
+8 -1
View File
@@ -37,6 +37,9 @@ $ErrorActionPreference = 'Stop'
$runner = Join-Path $PSScriptRoot 'explorer-media-rename.ps1'
if (-not (Test-Path -LiteralPath $runner)) { throw "找不到 $runner" }
$enqueueVbs = Join-Path $PSScriptRoot 'scenemarshal-enqueue.vbs'
if (-not (Test-Path -LiteralPath $enqueueVbs)) { throw "找不到 $enqueueVbs" }
$alias = Join-Path $env:LOCALAPPDATA 'Microsoft\WindowsApps\pwsh.exe'
if (Test-Path -LiteralPath $alias) {
# 应用执行别名,跨 PowerShell 版本升级保持稳定
@@ -77,7 +80,11 @@ $locations = @(
)
function New-MenuCommand([string]$Action, [string]$Token) {
'"' + $pwsh + '" -NoLogo -NoProfile -File "' + $runner + '" -Action ' + $Action + ' -Pause "' + $Token + '"'
# 经 wscript 调 VBS:无控制台窗口,只把任务写进队列,
# 由唯一的 worker 窗口按顺序处理(多选时不会弹多个终端)
$vbs = Join-Path $PSScriptRoot 'scenemarshal-enqueue.vbs'
$wscript = Join-Path $env:SystemRoot 'System32\wscript.exe'
'"' + $wscript + '" //nologo "' + $vbs + '" ' + $Action + ' "' + $pwsh + '" "' + $Token + '"'
}
function Get-RegPath([string]$relative) {