fix:修复前端时间和字体

This commit is contained in:
fengyarnom 2025-05-15 19:00:11 +08:00
parent 4316701fa3
commit 3166c937ee
2 changed files with 12 additions and 3 deletions

View File

@ -146,6 +146,14 @@ func (h *SensorHandler) GetLatestSensorRawData(w http.ResponseWriter, r *http.Re
return return
} }
// 将时间调整为中国时区(UTC+8)
chinaLoc, err := time.LoadLocation("Asia/Shanghai")
if err != nil {
// 如果无法加载时区手动创建UTC+8的时区
chinaLoc = time.FixedZone("CST", 8*60*60)
}
chinaTime := data.Timestamp.In(chinaLoc)
// 转换为前端友好的格式 // 转换为前端友好的格式
response := struct { response := struct {
ID int64 `json:"id"` ID int64 `json:"id"`
@ -163,7 +171,7 @@ func (h *SensorHandler) GetLatestSensorRawData(w http.ResponseWriter, r *http.Re
}{ }{
ID: data.ID, ID: data.ID,
Timestamp: data.Timestamp, Timestamp: data.Timestamp,
FormattedTime: data.Timestamp.Format("2006-01-02 15:04:05"), FormattedTime: chinaTime.Format("2006-01-02 15:04:05"),
WindSpeed: float64(data.WindSpeed) / 100.0, WindSpeed: float64(data.WindSpeed) / 100.0,
WindForce: data.WindForce, WindForce: data.WindForce,
WindDirection8: data.WindDirection8, WindDirection8: data.WindDirection8,

View File

@ -75,8 +75,9 @@
} }
.data-value { .data-value {
font-size: 18px; font-size: 20px;
color: #007bff; /*color: #007bff;*/
color: #555;
} }
.data-unit { .data-unit {