mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
服务列表页带宽使用比特代替字节
This commit is contained in:
@@ -42,6 +42,24 @@ func FormatBytes(bytes int64) string {
|
||||
}
|
||||
}
|
||||
|
||||
func FormatBits(bits int64) string {
|
||||
if bits < Pow1024(1) {
|
||||
return FormatInt64(bits) + "Bps"
|
||||
} else if bits < Pow1024(2) {
|
||||
return fmt.Sprintf("%.4fKBps", float64(bits)/float64(Pow1024(1)))
|
||||
} else if bits < Pow1024(3) {
|
||||
return fmt.Sprintf("%.4fMBps", float64(bits)/float64(Pow1024(2)))
|
||||
} else if bits < Pow1024(4) {
|
||||
return fmt.Sprintf("%.4fGBps", float64(bits)/float64(Pow1024(3)))
|
||||
} else if bits < Pow1024(5) {
|
||||
return fmt.Sprintf("%.4fTBps", float64(bits)/float64(Pow1024(4)))
|
||||
} else if bits < Pow1024(6) {
|
||||
return fmt.Sprintf("%.4fPBps", float64(bits)/float64(Pow1024(5)))
|
||||
} else {
|
||||
return fmt.Sprintf("%.4fEBps", float64(bits)/float64(Pow1024(6)))
|
||||
}
|
||||
}
|
||||
|
||||
func FormatCount(count int64) string {
|
||||
if count < 1000 {
|
||||
return types.String(count)
|
||||
|
||||
Reference in New Issue
Block a user