fix(shell): 修复页面按钮全失效(param 名不能叫 args)+ -NoExclude 不再成为默认;README 补验证方法与踩坑
This commit is contained in:
+10
-6
@@ -198,7 +198,7 @@ $script:state = [ordered]@{
|
||||
posLock = $false
|
||||
sizeLock = $false
|
||||
opacity = $Opacity
|
||||
exclude = (-not $NoExclude)
|
||||
exclude = $true # 默认抓屏隐身;-NoExclude 只在运行时覆盖,绝不落盘成默认值
|
||||
scale = 1.0
|
||||
fullscreen = $false
|
||||
backdrop = if ($Backdrop) { $Backdrop } else { 'opaque' }
|
||||
@@ -339,19 +339,23 @@ function Send-Endpoint {
|
||||
try {
|
||||
$ep = Get-Content $endpointFile -Raw | ConvertFrom-Json
|
||||
$payload.baseUrl = $ep.baseUrl; $payload.token = $ep.token
|
||||
} catch {}
|
||||
} catch { Log "endpoint parse failed: $($_.Exception.Message)" }
|
||||
}
|
||||
Log "push endpoint -> $($payload.baseUrl)"
|
||||
Send-ToPage $payload
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- 页面消息处理
|
||||
$onWebMessage = {
|
||||
param($sender, $args)
|
||||
# 参数不能叫 $args —— 那是 PowerShell 的自动变量,会被整个事件参数数组占住,
|
||||
# 于是 TryGetWebMessageAsString 找不到(实测:页面全部按钮失效、ready 握手丢失)。
|
||||
param($s, $e)
|
||||
try {
|
||||
$msg = $args.TryGetWebMessageAsString()
|
||||
if (-not $msg) { $msg = $args.WebMessageAsJson }
|
||||
$msg = $e.TryGetWebMessageAsString()
|
||||
if (-not $msg) { $msg = $e.WebMessageAsJson }
|
||||
$m = $msg | ConvertFrom-Json
|
||||
} catch { return }
|
||||
} catch { Log "webmessage parse failed: $($_.Exception.Message)"; return }
|
||||
if ($m.cmd -and $m.cmd -ne 'drag' -and $m.cmd -ne 'resize') { Log "page cmd: $($m.cmd)" }
|
||||
switch ($m.cmd) {
|
||||
'ready' { Push-State; Send-Endpoint }
|
||||
'drag' { if (-not $script:state.posLock) { [void][DshFloat.Native]::ReleaseCapture(); [void][DshFloat.Native]::SendMessage($form.Handle, 0xA1, [IntPtr]2, [IntPtr]::Zero) } }
|
||||
|
||||
Reference in New Issue
Block a user