修复控制台首页的两个问题

1. 修复用户分布显示问题:
   - 后端添加 online 和 offline 字段到用户分布数据
   - 确保前端能正确显示在线和离线用户数

2. 修复 ECharts 初始化报错:
   - 添加 DOM 元素存在性检查
   - 添加异步加载时的卸载检查
   - 在重新初始化前清理旧实例
   - 防止页面切换时的空指针错误
This commit is contained in:
2026-05-08 15:34:00 +08:00
parent 63cc2f80b3
commit 3a734e6dad
2 changed files with 26 additions and 4 deletions
+4 -2
View File
@@ -130,8 +130,10 @@ func handleGetDashboard(c *gin.Context) {
provinces := make([]gin.H, 0, len(deviceCounts))
for _, dc := range deviceCounts {
provinces = append(provinces, gin.H{
"name": dc.DeviceType,
"count": dc.Count,
"name": dc.DeviceType,
"count": dc.Count,
"online": 0,
"offline": dc.Count,
})
}
mu.Lock()