diff --git a/deploy/watchdog.ps1 b/deploy/watchdog.ps1 index ecb3943..f37a68d 100644 --- a/deploy/watchdog.ps1 +++ b/deploy/watchdog.ps1 @@ -25,12 +25,15 @@ function Write-Log($msg) { function Send-Alert($title, $msg) { if (-not $FeishuWebhook) { return } - $body = @{ + $json = @{ msg_type = "text" content = @{ text = "[$title] $msg" } } | ConvertTo-Json -Depth 3 try { - Invoke-RestMethod -Uri $FeishuWebhook -Method Post -Body $body -ContentType "application/json" -TimeoutSec 10 + # PS5 的 Invoke-RestMethod 对字符串 body 默认按 Latin-1 编码,中文会变成 ???, + # 必须手动转 UTF-8 字节数组发送 + $bytes = [System.Text.Encoding]::UTF8.GetBytes($json) + Invoke-RestMethod -Uri $FeishuWebhook -Method Post -Body $bytes -ContentType "application/json; charset=utf-8" -TimeoutSec 10 } catch { Write-Log "飞书告警发送失败: $_" }