From 8932f0b27ce942f8036382b14782c1639d917b40 Mon Sep 17 00:00:00 2001 From: suzmii Date: Wed, 2 Sep 2026 18:40:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B3=A5=E7=82=B9=E7=B4=A7?= =?UTF-8?q?=E5=87=91=E6=98=BE=E7=A4=BA=E5=90=91=E4=B8=8A=E8=88=8D=E5=85=A5?= =?UTF-8?q?=20(#255)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 变更内容 - 将泥点紧凑显示从四舍五入改为按一位小数向下截断; - “万”和“亿”两个紧凑单位分支使用一致规则,不会再显示出高于实际余额的数值; - `12,999` 由 `1.3万` 改为 `1.2万`,`19,999` 由 `2.0万` 改为 `1.9万`; - 低于 `1万` 的完整数字显示和非紧凑模式保持不变。 ## 前后对照 | 实际泥点 | 修改前 | 修改后 | | --- | --- | --- | | `9,999` | `9,999` | `9,999` | | `12,999` | `1.3万` | `1.2万` | | `19,999` | `2.0万` | `1.9万` | ## 排查范围 - 仓库内泥点紧凑缩写只有 `formatMudPointCount` 一处; - 该函数仅包含“万”和“亿”两个单位分支,本次均已修改; - 其它泥点展示使用完整整数,不存在同类单位舍入问题。 ## 验证 - `npm run check:encoding` - `git diff --check` - 按需求未新增测试 - 首轮 Frontend CI 唯一失败为 `AdminEditorAssetQueryPage.test.tsx` 既有大量缩略图换签用例超时,与本次格式化改动无关;新提交已触发 CI 重跑 Closes #254 Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/255 Reviewed-by: 段舒康 Co-authored-by: suzmii Co-committed-by: suzmii --- packages/shared/src/utils/format.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/shared/src/utils/format.ts b/packages/shared/src/utils/format.ts index f5e56b534..496516ddc 100644 --- a/packages/shared/src/utils/format.ts +++ b/packages/shared/src/utils/format.ts @@ -1,10 +1,10 @@ export function formatMudPointCount(value: number, compact = false) { const normalizedValue = Math.max(0, Math.round(value)); if (compact && normalizedValue >= 100_000_000) { - return `${(normalizedValue / 100_000_000).toFixed(1)}亿`; + return `${(Math.floor(normalizedValue / 10_000_000) / 10).toFixed(1)}亿`; } if (compact && normalizedValue >= 10_000) { - return `${(normalizedValue / 10_000).toFixed(1)}万`; + return `${(Math.floor(normalizedValue / 1_000) / 10).toFixed(1)}万`; } return normalizedValue.toLocaleString('zh-CN'); }