dsh-notify-say 0.4.30 → 0.4.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dsh-notify.ps1 +26 -3
- package/lib/client.js +1696 -1530
- package/lib/config-schema.js +339 -321
- package/lib/config-store.js +5 -0
- package/lib/index.js +1871 -1852
- package/lib/log-privacy.js +171 -0
- package/lib/voice-pack-download.js +382 -0
- package/lib/voice-pack-route.js +258 -0
- package/lib/voice-pack-store.js +188 -170
- package/package.json +1 -1
- package/test/client-contract.test.mjs +43 -0
- package/test/log-privacy.test.mjs +196 -0
- package/test/voice-pack-download.test.mjs +374 -0
- package/test/voice-pack-route.test.mjs +184 -0
- package/test/voice-pack-store.test.mjs +170 -142
package/dsh-notify.ps1
CHANGED
|
@@ -52,6 +52,12 @@ param(
|
|
|
52
52
|
[string]$VoiceRoot = '',
|
|
53
53
|
# 用户语音包根目录(可写),仅用于诊断日志。
|
|
54
54
|
[string]$UserVoiceRoot = '',
|
|
55
|
+
# v0.4.34:日志级别。info(默认)= 只记元数据;debug = 记标题与正文。
|
|
56
|
+
#
|
|
57
|
+
# 为什么需要:日志会写进 %TEMP%,用户提 Issue 时经常直接上传。
|
|
58
|
+
# 标题与正文可能含项目名、人名,对诊断「为什么不响」却没帮助。
|
|
59
|
+
[ValidateSet('info', 'debug')]
|
|
60
|
+
[string]$LogLevel = 'info',
|
|
55
61
|
# v0.4.16:数字增益倍数(1.0 = 原样;2.0 = 放大一倍)。
|
|
56
62
|
#
|
|
57
63
|
# 为什么需要:实测本包 247 个语音包峰值中位仅 **40.4%**
|
|
@@ -281,6 +287,23 @@ try {
|
|
|
281
287
|
$logDir = Join-Path ([System.IO.Path]::GetTempPath()) 'dsh-notify-say'
|
|
282
288
|
if (-not (Test-Path -LiteralPath $logDir)) { New-Item -ItemType Directory -Force -Path $logDir | Out-Null }
|
|
283
289
|
$logFile = Join-Path $logDir 'notify.log'
|
|
290
|
+
|
|
291
|
+
# v0.4.34:写一行日志。$detail = 含用户内容(标题/正文),只在 debug 档写。
|
|
292
|
+
#
|
|
293
|
+
# 用函数而不是内联 Add-Content:三处调用点都要同样判断,
|
|
294
|
+
# 内联会让"某处忘了判断"这种遗漏很难看出来。
|
|
295
|
+
function Write-NotifyLog([string]$KindTag, [string]$Extra, [string]$Detail) {
|
|
296
|
+
if (-not $logFile) { return }
|
|
297
|
+
try {
|
|
298
|
+
$ts = Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
|
|
299
|
+
$parts = @($ts, "[$KindTag]", $Extra)
|
|
300
|
+
if ($Detail) {
|
|
301
|
+
if ($LogLevel -eq 'debug') { $parts += $Detail }
|
|
302
|
+
else { $parts += '(内容已隐藏,需 -LogLevel debug)' }
|
|
303
|
+
}
|
|
304
|
+
Add-Content -Path $logFile -Value (($parts -join ' ').Trim()) -Encoding utf8
|
|
305
|
+
} catch { }
|
|
306
|
+
}
|
|
284
307
|
# 审查建议采纳:容量护栏——超过 512KB 整文件重建(best-effort 诊断日志,不做轮转)
|
|
285
308
|
if ((Test-Path -LiteralPath $logFile) -and ((Get-Item -LiteralPath $logFile -ErrorAction SilentlyContinue).Length -gt 524288)) {
|
|
286
309
|
Remove-Item -LiteralPath $logFile -Force -ErrorAction SilentlyContinue
|
|
@@ -475,16 +498,16 @@ $pickedName = if ($script:playFile) { Split-Path $script:playFile -Leaf } else {
|
|
|
475
498
|
if ($Preview) {
|
|
476
499
|
if (-not $NoSound) { Play-VoiceLine }
|
|
477
500
|
$soundTag = if ($NoSound) { '(静音)' } elseif ($script:lastSound) { " + 音效 $script:lastSound" } else { ' + 兜底提示音' }
|
|
478
|
-
|
|
501
|
+
Write-NotifyLog 'preview' ("-Voice $Voice pick=$pickedName$soundTag") ''
|
|
479
502
|
Write-Host ("[dsh-notify-say] OK 试听 [$Kind] pick=" + $pickedName + $soundTag) -ForegroundColor Green
|
|
480
503
|
} elseif ($shown) {
|
|
481
504
|
if (-not $NoSound) { Play-VoiceLine }
|
|
482
505
|
$soundTag = if ($NoSound) { '(静音)' } elseif ($script:lastSound) { " + 音效 $script:lastSound" } else { ' + 兜底提示音' }
|
|
483
|
-
|
|
506
|
+
Write-NotifyLog 'toast' ("pick=$pickedName$soundTag") ("title=$Title body=$Body")
|
|
484
507
|
Write-Host ("[dsh-notify-say] OK Toast [$Kind] pick=" + $pickedName + $soundTag) -ForegroundColor Green
|
|
485
508
|
} else {
|
|
486
509
|
if (-not $NoSound) { Play-VoiceLine }
|
|
487
510
|
$soundTag = if ($NoSound) { '(静音)' } elseif ($script:lastSound) { " + 音效 $script:lastSound" } else { ' + 兜底提示音' }
|
|
488
|
-
|
|
511
|
+
Write-NotifyLog 'FALLBACK' ("pick=$pickedName$soundTag") ("title=$Title body=$Body")
|
|
489
512
|
Write-Host ("[dsh-notify-say] (Toast 不可用,走兜底) [$Kind] pick=" + $pickedName + $soundTag) -ForegroundColor Yellow
|
|
490
513
|
}
|