-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: file size unit #1320
fix: file size unit #1320
Conversation
摘要Walkthrough这次的变更主要涉及在 Changes
诗歌
Note Summarized by CodeRabbit FreeYour organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://coderabbit.ai TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
@@ -447,7 +447,7 @@ pub fn write_stats(stats: &StatsJsonMap, compiler: &Compiler) { | |||
|
|||
// 文件大小转换 | |||
pub fn human_readable_size(size: u64) -> String { | |||
let units = ["kB", "mB", "gB"]; | |||
let units = ["kB", "MB", "GB"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为啥 kB 不一起大写了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
浏览器 network 显示的是 kB MB , webpack 也是这样显示的
k 是 kilo,M 是 mega,G 是 giga
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kB 和 KB 是用来表示计算机数据存储容量的单位,它们的区别在于所代表的容量大小不同:
-
kB (kilobyte):
- 在计算机科学中,1 kB 通常等于 1024 字节 (bytes)。这是因为计算机是基于二进制系统的,1024 是 2 的 10 次方。
- 有时在某些上下文中,特别是国际标准组织(ISO)推荐的使用下,1 kB 也可以表示 1000 字节。为了避免混淆,这种情况下更常使用 "kB" 表示 1000 字节,而使用 "KiB"(kibibyte)表示 1024 字节。
-
KB (Kilobyte):
- 通常用来表示 1000 字节,这是根据国际单位制(SI)前缀定义的。SI 前缀 “Kilo” 表示 1000。
- 然而在很多实际应用中,KB 和 kB 都常被混用来表示 1024 字节,特别是在传统计算机领域。
为了更清晰的区分,国际电工委员会(IEC)推荐使用二进制前缀:
- KiB (kibibyte): 1 KiB = 1024 字节 (2¹⁰ bytes)
- KB (kilobyte): 1 KB = 1000 字节 (10³ bytes)
总结:
- kB 或 KiB 通常用于表示 1024 字节。
- KB 通常用于表示 1000 字节,但在某些情况下,可能也表示 1024 字节。
在使用过程中,了解上下文和具体用法是很重要的,以避免混淆。
Summary by CodeRabbit
human_readable_size
函数中用于人类可读大小转换的单位,从"kB"、"mB"、"gB"调整为"kB"、"MB"、"GB"。