mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-21 06:49:37 +00:00
Use browser download in missing model dialog (#1362)
* Remove custom backend download logic * Add download hooks * Download button * Use browser download * Update test
This commit is contained in:
@@ -60,14 +60,15 @@ export function formatNumberWithSuffix(
|
||||
return `${formattedNum}${suffixes[exp]}`
|
||||
}
|
||||
|
||||
export function formatMemory(value?: number) {
|
||||
export function formatSize(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`
|
||||
const bytes = value
|
||||
if (bytes === 0) return '0 B'
|
||||
const k = 1024
|
||||
const sizes = ['B', 'KB', 'MB', 'GB']
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
||||
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(2))} ${sizes[i]}`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user