fix(voice): 涨跌幅播报漏乘 100, 几乎所有股票都念成「涨0.0%」

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 通过。
This commit is contained in:
shy3130
2026-07-13 22:28:16 +08:00
parent 590de5d694
commit 4df5cc3b27
+5 -3
View File
@@ -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)}%`
}
/**