diff --git a/internal/web/ui.go b/internal/web/ui.go index 269511f..01f3e83 100644 --- a/internal/web/ui.go +++ b/internal/web/ui.go @@ -2768,8 +2768,11 @@ func (u *UI) apiAlarmExport(w http.ResponseWriter, r *http.Request) { } } } + if sourceName == "" { + sourceName = a.Channel + } fmt.Fprintf(w, "%s,%s,%s,%s,%s,%s,%s\n", - escapeCSV(a.Timestamp), escapeCSV(devName), escapeCSV(devIP), escapeCSV(sourceName), + escapeCSV(formatAlarmTime(a.Timestamp)), escapeCSV(devName), escapeCSV(devIP), escapeCSV(sourceName), escapeCSV(alarmRuleLabel(a.RuleName)), escapeCSV(a.ObjectLabel), escapeCSV(alarmStatusLabel(a.Status))) } @@ -2814,6 +2817,16 @@ func alarmStatusLabel(v string) string { } } +func formatAlarmTime(t string) string { + // 2026-07-22T13:03:20+08:00 → 2026-07-22 13:03:20 + s := strings.TrimSpace(t) + s = strings.Replace(s, "T", " ", 1) + if idx := strings.Index(s, "+"); idx > 0 { + s = s[:idx] + } + return strings.TrimSpace(s) +} + func (u *UI) pageResources(w http.ResponseWriter, r *http.Request) { u.ensureDevicesLoaded() data := PageData{Title: "资源管理", Devices: u.registry.GetDevices()} diff --git a/internal/web/ui/templates/alarms.html b/internal/web/ui/templates/alarms.html index 35f98c6..8f6fb9d 100644 --- a/internal/web/ui/templates/alarms.html +++ b/internal/web/ui/templates/alarms.html @@ -62,7 +62,7 @@ {{index $.AlarmDeviceNames .DeviceID}}
{{index $.AlarmDeviceIPs .DeviceID}}
- {{index $.AlarmChannelSources .Channel}} + {{if index $.AlarmChannelSources .Channel}}{{index $.AlarmChannelSources .Channel}}{{else}}{{.Channel}}{{end}} {{ruleLabel .RuleName}} diff --git a/safesightd-linux-arm64 b/safesightd-linux-arm64 index 5fc25f4..e807118 100644 Binary files a/safesightd-linux-arm64 and b/safesightd-linux-arm64 differ