fix(size): 修复轻量包占用显示为 0 MB 的精度问题

后端 fmtMb 用 toFixed(1) 保留 1 位小数,<0.05MB 的包(几 KB~几十 KB
的轻量组件)被截断为 0。改为保留 KB 级精度;前端统一使用 store 的
fmtSize/fmtBytes(新增 KB 档位),所有包大小显示点(检索/忽略/概览/
卡片/抽屉/清理对话框/Top20)统一替换,消除各组件重复的本地格式化。
This commit is contained in:
陈银军
2026-09-19 22:04:14 +08:00
parent 1793888900
commit a7dc1b7a17
9 changed files with 25 additions and 19 deletions
+2 -1
View File
@@ -65,7 +65,8 @@ function readJson(file) {
}
function fmtMb(bytes) {
return Number((bytes / 1024 / 1024).toFixed(1))
// 保留到 KB 级精度:toFixed(1) 会把 <0.05MB 的轻量包(几 KB~几十 KB)截成 0
return Math.round((bytes / 1024 / 1024) * 1024) / 1024
}
// 目录名 → 包名(支持 scoped:@scope/name)