From eba7d400e10385bb2a95c2a780db39dfa7964729 Mon Sep 17 00:00:00 2001 From: Zhou Weidong <502333560@qq.com> Date: Mon, 2 Nov 2026 14:52:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(deploy):=20=E7=9C=8B=E9=97=A8=E7=8B=97?= =?UTF-8?q?=E9=A3=9E=E4=B9=A6=E5=91=8A=E8=AD=A6=E4=B8=AD=E6=96=87=E4=B9=B1?= =?UTF-8?q?=E7=A0=81=E6=94=B9=20UTF-8=20=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PS5 Invoke-RestMethod 对字符串 body 默认按 Latin-1 编码导致中文变 ???, 改为手动转 UTF-8 字节数组并声明 charset=utf-8。 --- deploy/watchdog.ps1 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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 "飞书告警发送失败: $_" }