From 1091b430c568d9417569f9f8d623a8c423741d3f Mon Sep 17 00:00:00 2001 From: liuyanxi975 Date: Mon, 30 May 2022 17:51:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复负值显示错误 改进页面显示 --- cmd/dashboard/controller/controller.go | 3 +++ resource/template/theme-default/service.html | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/dashboard/controller/controller.go b/cmd/dashboard/controller/controller.go index 500a629..f655620 100644 --- a/cmd/dashboard/controller/controller.go +++ b/cmd/dashboard/controller/controller.go @@ -150,6 +150,9 @@ var funcMap = template.FuncMap{ }, "Transleft": func(a, b float64) (n float64) { n, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", (100-(a/b)*100)), 64) + if n < 0 { + n = 0 + } return }, "UintToFloat": func(a uint64) (n float64) { diff --git a/resource/template/theme-default/service.html b/resource/template/theme-default/service.html index e0bdd3d..b7d03ce 100644 --- a/resource/template/theme-default/service.html +++ b/resource/template/theme-default/service.html @@ -69,7 +69,7 @@ {{$stats.Min|bf}} {{(index $stats.NextUpdate $innerId)|sft}} {{$transfer|bf}} -
{{Transleft (UintToFloat $transfer) (UintToFloat $stats.Max)}} %
+
{{Transleft (UintToFloat $transfer) (UintToFloat $stats.Max)}} %
{{end}} {{end}}