diff --git a/internal/web/actions/default/dashboard/index.go b/internal/web/actions/default/dashboard/index.go index 199ee34e..7ac18e64 100644 --- a/internal/web/actions/default/dashboard/index.go +++ b/internal/web/actions/default/dashboard/index.go @@ -92,13 +92,16 @@ func (this *IndexAction) RunPost(params struct{}) { "diskUsageWarning": diskUsageWarning, } - // 今日流量 - todayTrafficBytes := int64(0) + // 今日流量和独立IP数 + var todayTrafficBytes int64 + var todayCountIPs int64 if len(resp.DailyTrafficStats) > 0 { - todayTrafficBytes = resp.DailyTrafficStats[len(resp.DailyTrafficStats)-1].Bytes + var lastDailyTrafficStat = resp.DailyTrafficStats[len(resp.DailyTrafficStats)-1] + todayTrafficBytes = lastDailyTrafficStat.Bytes + todayCountIPs = lastDailyTrafficStat.CountIPs } - todayTrafficString := numberutils.FormatBytes(todayTrafficBytes) - result := regexp.MustCompile(`^(?U)(.+)([a-zA-Z]+)$`).FindStringSubmatch(todayTrafficString) + var todayTrafficString = numberutils.FormatBytes(todayTrafficBytes) + var result = regexp.MustCompile(`^(?U)(.+)([a-zA-Z]+)$`).FindStringSubmatch(todayTrafficString) if len(result) > 2 { this.Data["todayTraffic"] = result[1] this.Data["todayTrafficUnit"] = result[2] @@ -107,6 +110,8 @@ func (this *IndexAction) RunPost(params struct{}) { this.Data["todayTrafficUnit"] = "" } + this.Data["todayCountIPs"] = todayCountIPs + // 24小时流量趋势 { statMaps := []maps.Map{} @@ -137,6 +142,7 @@ func (this *IndexAction) RunPost(params struct{}) { "countAttackRequests": stat.CountAttackRequests, "attackBytes": stat.AttackBytes, "day": stat.Day[4:6] + "月" + stat.Day[6:] + "日", + "countIPs": stat.CountIPs, }) } this.Data["dailyTrafficStats"] = statMaps diff --git a/web/views/@default/dashboard/index.html b/web/views/@default/dashboard/index.html index a0f63c26..f79e5f93 100644 --- a/web/views/@default/dashboard/index.html +++ b/web/views/@default/dashboard/index.html @@ -78,7 +78,7 @@ -
+

API节点

{{dashboard.countAPINodes}}/ {{dashboard.countOfflineAPINodes}}离线{{dashboard.countOfflineAPINodes}}离线 @@ -95,10 +95,19 @@
{{dashboard.countServers}}
-
-

今日流量

+
+

当天独立IP

+
+ {{todayCountIPsFormat}} + 尚无数据 +
+
+ +
+

当天流量

{{todayTraffic}}{{todayTrafficUnit}}
+ diff --git a/web/views/@default/dashboard/index.js b/web/views/@default/dashboard/index.js index 3fd1b18e..ea6b1bc8 100644 --- a/web/views/@default/dashboard/index.js +++ b/web/views/@default/dashboard/index.js @@ -5,6 +5,7 @@ Tea.context(function () { this.dashboard = {} this.localLowerVersionAPINode = null this.countWeakAdmins = 0 + this.todayCountIPsFormat = "0" this.$delay(function () { this.$post("$") @@ -13,6 +14,8 @@ Tea.context(function () { this[k] = resp.data[k] } + this.todayCountIPsFormat = teaweb.formatNumber(this.todayCountIPs) + this.isLoading = false this.$delay(function () {