移除不准确的今日最高,改为按当前温度从高到低排序

- airport_obs_log 仅保留 2h 数据,max_so_far 不准确
- 去掉卡片 Today High 行,趋势箭头移到 Obs 同行
- 卡片按 current_temp 降序排列,无数据沉底
- 通知文案简化
This commit is contained in:
2569718930@qq.com
2026-05-13 20:44:09 +08:00
parent 067ee63ba4
commit e734c93b34
2 changed files with 13 additions and 17 deletions
+9 -2
View File
@@ -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<CitySnapshot> {
CITIES
let mut cities: Vec<CitySnapshot> = 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 ──
+4 -15
View File
@@ -43,16 +43,6 @@
</div>
<div class="card-meta">
<div class="meta-row">
<span class="label">Today High</span>
{% match c.today_max %}
{% when Some with (m) %}
<span class="value">{{ "{:.1}"|format(m) }}°C</span>
{% when None %}
<span class="value na">--</span>
{% endmatch %}
<span class="trend {{ c.trend.css_class() }}">{{ c.trend.symbol() }}</span>
</div>
<div class="meta-row">
<span class="label">Obs</span>
{% match c.obs_age_min %}
@@ -61,6 +51,7 @@
{% when None %}
<span class="value na">--</span>
{% endmatch %}
<span class="trend {{ c.trend.css_class() }}">{{ c.trend.symbol() }}</span>
</div>
</div>
</div>
@@ -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);
}
});
});