From 407973655a87a1ad58f904d49adf2a1cdd088a39 Mon Sep 17 00:00:00 2001 From: pan Date: Thu, 6 Aug 2026 11:13:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(HeroBoxComp):=20=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E6=89=8B=E5=8A=A8=E6=A0=BC=E5=BC=8F=E5=8C=96=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=B8=BANumberFormatter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 统一大数值展示格式,使用千分位缩写避免溢出标签,同时保留小数位数的原有逻辑 --- assets/script/game/map/HeroBoxComp.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assets/script/game/map/HeroBoxComp.ts b/assets/script/game/map/HeroBoxComp.ts index ef1a86eb..790c5c46 100644 --- a/assets/script/game/map/HeroBoxComp.ts +++ b/assets/script/game/map/HeroBoxComp.ts @@ -21,7 +21,7 @@ import { GameEvent } from "../common/config/GameEvent"; import { HeroInfo } from "../common/config/heroSet"; import { HeroAttrsComp } from "../hero/HeroAttrsComp"; import { Hero } from "../hero/Hero"; -import { FacSet, FightSet, getLvColor } from "../common/config/GameSet"; +import { FacSet, FightSet, getLvColor, NumberFormatter } from "../common/config/GameSet"; import { buildSkillDesc, ISkillDescSource } from "../common/config/HeroSkillDesc"; import { MissionEconomy } from "./MissionEconomy"; import { UIID } from "../common/config/GameUIConfig"; @@ -592,7 +592,8 @@ export class HeroBoxComp extends CCComp { * @param decimals 保留小数位数(默认 0,取整) */ private setStatRow(allLabel: Label | null, plusLabel: Label | null, total: number, bonus: number, suffix: string = "", decimals: number = 0) { - const fmt = (v: number) => decimals > 0 ? v.toFixed(decimals) : `${Math.floor(v)}`; + // 整数数值统一走 NumberFormatter 千分位缩写(如 12.3k),避免大数值溢出标签 + const fmt = (v: number) => decimals > 0 ? v.toFixed(decimals) : NumberFormatter.formatNumber(Math.floor(v)); if (allLabel && allLabel.isValid) { allLabel.string = `${fmt(total)}${suffix}`; }