Files
PolyWeather/monitoring-web/src/model.rs
T
2569718930@qq.com 88918677c0 监控页面:英文城市名 + 新高浏览器提醒(可开关)
- 卡片标题改为英文名(Seoul/Busan/Tokyo 等)
- 温度突破今日最高 0.3°C 时触发浏览器 Notification
- 右上角 🔔 按钮开关提醒,状态存 localStorage
- 同日同城同一温度不重复提醒(notify_highs 去重)
- 页面标题和标签全英文化

Tested: cargo build --release 通过
2026-05-13 20:33:59 +08:00

54 lines
1.2 KiB
Rust

use serde::Serialize;
#[derive(Debug, Clone, Serialize)]
pub struct CitySnapshot {
pub name: String,
pub en_name: String,
pub airport: String,
pub icao: String,
pub local_time: String,
pub current_temp: Option<f64>,
pub today_max: Option<f64>,
pub max_time: Option<String>,
pub trend: Trend,
pub new_high: bool,
pub runway_pairs: Vec<(String, f64)>,
pub gap: Option<f64>,
pub threshold: f64,
pub time_ok: bool,
pub temp_ok: bool,
pub trend_ok: bool,
pub in_window: bool,
pub obs_age_min: Option<i64>,
pub temp_warm: bool,
}
#[derive(Debug, Clone, Copy, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum Trend {
Rising,
Falling,
Flat,
Unknown,
}
impl Trend {
pub fn symbol(&self) -> &str {
match self {
Trend::Rising => "↑",
Trend::Falling => "↓",
Trend::Flat => "→",
Trend::Unknown => "",
}
}
pub fn css_class(&self) -> &str {
match self {
Trend::Rising => "rising",
Trend::Falling => "falling",
Trend::Flat => "flat",
Trend::Unknown => "",
}
}
}