diff --git a/monitoring-web/src/main.rs b/monitoring-web/src/main.rs index 3bd1acfe..b3160308 100644 --- a/monitoring-web/src/main.rs +++ b/monitoring-web/src/main.rs @@ -127,11 +127,18 @@ fn load_city_snapshot(db_path: &str, idx: usize, (key, _zh, en, icao, airport, t } fn load_all_cities(db_path: &str) -> Vec { - CITIES + let mut cities: Vec = CITIES .iter() .enumerate() .map(|(i, c)| load_city_snapshot(db_path, i, c)) - .collect() + .collect(); + // 按当前温度从高到低排序,无数据的排最后 + cities.sort_by(|a, b| { + b.current_temp + .partial_cmp(&a.current_temp) + .unwrap_or(std::cmp::Ordering::Less) + }); + cities } // ── routes ── diff --git a/monitoring-web/templates/monitor.html b/monitoring-web/templates/monitor.html index da18477e..7c2cb5f7 100644 --- a/monitoring-web/templates/monitor.html +++ b/monitoring-web/templates/monitor.html @@ -43,16 +43,6 @@
-
- Today High - {% match c.today_max %} - {% when Some with (m) %} - {{ "{:.1}"|format(m) }}°C - {% when None %} - -- - {% endmatch %} - {{ c.trend.symbol() }} -
Obs {% match c.obs_age_min %} @@ -61,6 +51,7 @@ {% when None %} -- {% endmatch %} + {{ c.trend.symbol() }}
@@ -97,7 +88,7 @@ function updateNotifyIcon() { } } -function fireNotification(city, enName, temp, todayMax) { +function fireNotification(enName, temp) { if (!NOTIFY_ENABLED) return; if (Notification.permission !== 'granted') return; @@ -114,7 +105,7 @@ function fireNotification(city, enName, temp, todayMax) { localStorage.setItem('monitor_notified_highs', JSON.stringify(NOTIFIED_HIGHS)); new Notification('🔴 New High — ' + enName, { - body: temp + '°C (was ' + todayMax + '°C)\n' + enName + ' / ' + city, + body: temp + '°C\nNew daily high.', icon: '/static/favicon.png', tag: key, requireInteraction: true, @@ -146,9 +137,7 @@ updateNotifyIcon(); // Notification for new high if(card.dataset.newHigh === 'true'){ - var maxEl = card.querySelector('.meta-row .value'); - var maxVal = maxEl ? maxEl.textContent.replace('°C','') : ''; - fireNotification(name, name, tv, maxVal); + fireNotification(name, tv); } }); });