From 4df5cc3b271e36c8e56a159e1bc8493f73b45953 Mon Sep 17 00:00:00 2001 From: shy3130 Date: Mon, 13 Jul 2026 22:28:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(voice):=20=E6=B6=A8=E8=B7=8C=E5=B9=85?= =?UTF-8?q?=E6=92=AD=E6=8A=A5=E6=BC=8F=E4=B9=98=20100,=20=E5=87=A0?= =?UTF-8?q?=E4=B9=8E=E6=89=80=E6=9C=89=E8=82=A1=E7=A5=A8=E9=83=BD=E5=BF=B5?= =?UTF-8?q?=E6=88=90=E3=80=8C=E6=B6=A80.0%=E3=80=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fmtPctText 直接 pct.toFixed(1), 但后端 change_pct 是小数制 (0.0366 = 3.66%, 见 quote_service.py「不乘 100」注释)。屏幕显示的 fmtPct (format.ts) 正确 ×100, 但语音的 fmtPctText 单独写漏了。 0.0366 → 旧「涨0.0%」/ 新「涨3.7%」 0.10 → 旧「涨0.1%」/ 新「涨10.0%」 ×100 后再 toFixed, 与 fmtPct 单位约定一致。tsc 通过。 --- frontend/src/lib/voiceBroadcast.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/frontend/src/lib/voiceBroadcast.ts b/frontend/src/lib/voiceBroadcast.ts index a2f86b8..a1918ca 100644 --- a/frontend/src/lib/voiceBroadcast.ts +++ b/frontend/src/lib/voiceBroadcast.ts @@ -95,10 +95,12 @@ export function getCurrentVoiceURI(): string { const MAX_SPEAK = 3 // 单批最多逐条念 3 只, 超出汇总成数量 -/** 涨跌幅用中文习惯念: 5.2% → 涨5.2%, -3.1% → 跌3.1% */ +/** 涨跌幅用中文习惯念: 0.052 → 涨5.2%, -0.031 → 跌3.1%。 + * 入参是小数制 (后端 change_pct, 0.0366 = 3.66%), 需 ×100 再念, 与 format.ts 的 fmtPct 一致。 */ function fmtPctText(pct: number): string { - if (pct >= 0) return `涨${pct.toFixed(1)}%` - return `跌${Math.abs(pct).toFixed(1)}%` + const p = pct * 100 + if (p >= 0) return `涨${p.toFixed(1)}%` + return `跌${Math.abs(p).toFixed(1)}%` } /**