diff --git a/http/server.go b/http/server.go index 9ef6f37..9b1cc75 100644 --- a/http/server.go +++ b/http/server.go @@ -102,6 +102,9 @@ func (s *Server) handleStats(w http.ResponseWriter, r *http.Request) { // 获取活跃来源IP数量 activeIPCount := len(dnsStats.SourceIPs) + // 格式化平均响应时间为两位小数 + formattedResponseTime := float64(int(dnsStats.AvgResponseTime*100)) / 100 + // 构建响应数据,确保所有字段都反映服务器的真实状态 stats := map[string]interface{}{ "dns": map[string]interface{}{ @@ -110,7 +113,7 @@ func (s *Server) handleStats(w http.ResponseWriter, r *http.Request) { "Allowed": dnsStats.Allowed, "Errors": dnsStats.Errors, "LastQuery": dnsStats.LastQuery, - "AvgResponseTime": dnsStats.AvgResponseTime, + "AvgResponseTime": formattedResponseTime, "TotalResponseTime": dnsStats.TotalResponseTime, "QueryTypes": dnsStats.QueryTypes, "SourceIPs": dnsStats.SourceIPs, @@ -119,7 +122,7 @@ func (s *Server) handleStats(w http.ResponseWriter, r *http.Request) { "shield": shieldStats, "topQueryType": topQueryType, "activeIPs": activeIPCount, - "avgResponseTime": dnsStats.AvgResponseTime, + "avgResponseTime": formattedResponseTime, "cpuUsage": dnsStats.CpuUsage, "time": time.Now(), } diff --git a/static/css/style.css b/static/css/style.css index f5b5ee2..51a0fe6 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -193,6 +193,40 @@ header p { transition: padding-left 0.3s ease; } +/* Tooltip趋势信息颜色类 - 替代内联style */ +.tooltip-trend { + font-weight: 500; +} + +/* 注意:这些颜色值与colors.config.js中的COLOR_CONFIG.colorClassMap保持同步 */ +.tooltip-trend.blue { + color: #1890ff; +} + +.tooltip-trend.green { + color: #52c41a; +} + +.tooltip-trend.orange { + color: #fa8c16; +} + +.tooltip-trend.red { + color: #f5222d; +} + +.tooltip-trend.purple { + color: #722ed1; +} + +.tooltip-trend.cyan { + color: #13c2c2; +} + +.tooltip-trend.teal { + color: #36cfc9; +} + /* 平板设备适配 - 侧边栏折叠时调整内容区域 */ @media (max-width: 992px) { .content { diff --git a/static/index.html b/static/index.html index 7e53a9b..0bcc794 100644 --- a/static/index.html +++ b/static/index.html @@ -150,12 +150,17 @@ -
0
- - - 0% - +0
+ + + 0% + +0
- - - 0% - +0
+ + + 0% + +0
- - - 0% - +0
+ + + 0% + +0
- - - 0% - +0
+ + + 0% + +0ms
- - - 0% - +0ms
+ + + 0% + +0
- - - 0% - +0
+ + + 0% + +0%
- - - 正常 - +0%
+ + + 正常 + +