mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-25 11:36:34 +08:00
数据看板使用字节代替比特
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/iwind/TeaGo/maps"
|
||||
"math"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
@@ -58,7 +57,7 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
if len(resp.DailyTrafficStats) > 0 {
|
||||
todayTrafficBytes = resp.DailyTrafficStats[len(resp.DailyTrafficStats)-1].Bytes
|
||||
}
|
||||
todayTrafficString := numberutils.FormatBits(todayTrafficBytes * 8)
|
||||
todayTrafficString := numberutils.FormatBytes(todayTrafficBytes)
|
||||
result := regexp.MustCompile(`^(?U)(.+)([a-zA-Z]+)$`).FindStringSubmatch(todayTrafficString)
|
||||
if len(result) > 2 {
|
||||
this.Data["todayTraffic"] = result[1]
|
||||
@@ -73,7 +72,7 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
statMaps := []maps.Map{}
|
||||
for _, stat := range resp.HourlyTrafficStats {
|
||||
statMaps = append(statMaps, maps.Map{
|
||||
"count": math.Ceil((float64(stat.Bytes)*8/1000/1000/1000)*1000) / 1000,
|
||||
"bytes": stat.Bytes,
|
||||
"hour": stat.Hour[8:],
|
||||
})
|
||||
}
|
||||
@@ -85,7 +84,7 @@ func (this *IndexAction) RunGet(params struct{}) {
|
||||
statMaps := []maps.Map{}
|
||||
for _, stat := range resp.DailyTrafficStats {
|
||||
statMaps = append(statMaps, maps.Map{
|
||||
"count": math.Ceil((float64(stat.Bytes)*8/1000/1000/1000)*1000) / 1000,
|
||||
"bytes": stat.Bytes,
|
||||
"day": stat.Day[4:6] + "月" + stat.Day[6:] + "日",
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user