Show total/free ram in about page (#924)

This commit is contained in:
Chenlei Hu
2024-09-22 17:40:40 +09:00
committed by GitHub
parent 39eeda8430
commit 9aa976fdf0
4 changed files with 29 additions and 8 deletions

View File

@@ -59,3 +59,15 @@ export function formatNumberWithSuffix(
return `${formattedNum}${suffixes[exp]}`
}
export function formatMemory(value?: number) {
if (value === null || value === undefined) {
return '-'
}
const mb = Math.round(value / (1024 * 1024))
if (mb >= 1024) {
return `${(mb / 1024).toFixed(2)} GB`
}
return `${mb} MB`
}