fix(dashboard): 统一消费金额格式,避免小额显示过长#196
Merged
Merged
Conversation
仪表盘今日消费卡片与排行榜消费列共用一份 formatCost:小于一分从六位小数改为四位小数,常规金额改为两位小数,千/百万级用 K/M 缩写。将 formatCost 提取到 chart-theme.ts 复用,消除两处重复实现,并补充对应单元测试。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
统一仪表盘消费金额的展示格式,修复「今日消费」卡片在小额场景下显示过长的问题(例如
$0.006599占用九个字符,明显长于同排其它卡片)。Related Issue
无
Type of Change
Changes
formatCost提取到src/components/dashboard/chart-theme.ts,仪表盘统计卡片与排行榜共用同一份实现,消除两处重复。K/M缩写。stats-cards与leaderboard-section补充金额格式化单元测试。显示效果对照:
$0.006599→$0.0066,$16.9599→$16.96,$1234.5000→$1.23K,$2500000.0000→$2.50M。Test Plan
pnpm test:run),tests/components/dashboard/共 81 项通过pnpm exec tsc --noEmit)Checklist
Additional Notes
本次仅改动 dashboard 三个源文件与两个测试文件,不涉及接口、数据格式或持久化变更。