| | |
| | | const bytes = Number(size) |
| | | if (!Number.isFinite(bytes) || bytes <= 0) return '0 B' |
| | | if (bytes < 1024) return `${bytes} B` |
| | | if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1).replace(/\.0$/, '')} KB` |
| | | return `${(bytes / (1024 * 1024)).toFixed(1).replace(/\.0$/, '')} MB` |
| | | if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(4).replace(/\.0$/, '')} KB` |
| | | return `${(bytes / (1024 * 1024)).toFixed(4).replace(/\.0$/, '')} MB` |
| | | } |
| | | |
| | | const createLocalFileSnapshot = (file, index = 0) => { |
| | |
| | | const formatCompactNumber = (value) => { |
| | | const amount = Number(value) || 0 |
| | | if (Math.abs(amount) >= 10000) { |
| | | return `${(amount / 10000).toFixed(2).replace(/\.?0+$/, '')}\u4e07` |
| | | return `${(amount / 10000).toFixed(4).replace(/\.?0+$/, '')}\u4e07` |
| | | } |
| | | return amount.toLocaleString('zh-CN', { maximumFractionDigits: 2 }) |
| | | } |