移除不准确的今日最高,改为按当前温度从高到低排序
- airport_obs_log 仅保留 2h 数据,max_so_far 不准确 - 去掉卡片 Today High 行,趋势箭头移到 Obs 同行 - 卡片按 current_temp 降序排列,无数据沉底 - 通知文案简化
This commit is contained in:
@@ -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> {
|
fn load_all_cities(db_path: &str) -> Vec<CitySnapshot> {
|
||||||
CITIES
|
let mut cities: Vec<CitySnapshot> = CITIES
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, c)| load_city_snapshot(db_path, i, c))
|
.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 ──
|
// ── routes ──
|
||||||
|
|||||||
@@ -43,16 +43,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-meta">
|
<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">
|
<div class="meta-row">
|
||||||
<span class="label">Obs</span>
|
<span class="label">Obs</span>
|
||||||
{% match c.obs_age_min %}
|
{% match c.obs_age_min %}
|
||||||
@@ -61,6 +51,7 @@
|
|||||||
{% when None %}
|
{% when None %}
|
||||||
<span class="value na">--</span>
|
<span class="value na">--</span>
|
||||||
{% endmatch %}
|
{% endmatch %}
|
||||||
|
<span class="trend {{ c.trend.css_class() }}">{{ c.trend.symbol() }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -97,7 +88,7 @@ function updateNotifyIcon() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fireNotification(city, enName, temp, todayMax) {
|
function fireNotification(enName, temp) {
|
||||||
if (!NOTIFY_ENABLED) return;
|
if (!NOTIFY_ENABLED) return;
|
||||||
if (Notification.permission !== 'granted') 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));
|
localStorage.setItem('monitor_notified_highs', JSON.stringify(NOTIFIED_HIGHS));
|
||||||
|
|
||||||
new Notification('🔴 New High — ' + enName, {
|
new Notification('🔴 New High — ' + enName, {
|
||||||
body: temp + '°C (was ' + todayMax + '°C)\n' + enName + ' / ' + city,
|
body: temp + '°C\nNew daily high.',
|
||||||
icon: '/static/favicon.png',
|
icon: '/static/favicon.png',
|
||||||
tag: key,
|
tag: key,
|
||||||
requireInteraction: true,
|
requireInteraction: true,
|
||||||
@@ -146,9 +137,7 @@ updateNotifyIcon();
|
|||||||
|
|
||||||
// Notification for new high
|
// Notification for new high
|
||||||
if(card.dataset.newHigh === 'true'){
|
if(card.dataset.newHigh === 'true'){
|
||||||
var maxEl = card.querySelector('.meta-row .value');
|
fireNotification(name, tv);
|
||||||
var maxVal = maxEl ? maxEl.textContent.replace('°C','') : '';
|
|
||||||
fireNotification(name, name, tv, maxVal);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user