From 88918677c002f0061f98f4e20aaaf306c366aabf Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Wed, 13 May 2026 20:33:59 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E6=8E=A7=E9=A1=B5=E9=9D=A2=EF=BC=9A?= =?UTF-8?q?=E8=8B=B1=E6=96=87=E5=9F=8E=E5=B8=82=E5=90=8D=20+=20=E6=96=B0?= =?UTF-8?q?=E9=AB=98=E6=B5=8F=E8=A7=88=E5=99=A8=E6=8F=90=E9=86=92=EF=BC=88?= =?UTF-8?q?=E5=8F=AF=E5=BC=80=E5=85=B3=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 卡片标题改为英文名(Seoul/Busan/Tokyo 等) - 温度突破今日最高 0.3°C 时触发浏览器 Notification - 右上角 🔔 按钮开关提醒,状态存 localStorage - 同日同城同一温度不重复提醒(notify_highs 去重) - 页面标题和标签全英文化 Tested: cargo build --release 通过 --- monitoring-web/src/main.rs | 38 +++++------ monitoring-web/src/model.rs | 2 +- monitoring-web/static/style.css | 16 +++++ monitoring-web/templates/monitor.html | 92 ++++++++++++++++++++++----- 4 files changed, 110 insertions(+), 38 deletions(-) diff --git a/monitoring-web/src/main.rs b/monitoring-web/src/main.rs index 2e97d7c7..be28eaf9 100644 --- a/monitoring-web/src/main.rs +++ b/monitoring-web/src/main.rs @@ -17,19 +17,19 @@ use tower_http::services::ServeDir; use tracing_subscriber; // ── city config ── -// (city_key, display_name, icao, airport_en, utc_offset_hours, threshold, tz_abbr) -const CITIES: &[(&str, &str, &str, &str, i32, f64, &str)] = &[ - ("seoul", "首尔", "RKSI", "Incheon", 9, 3.0, "KST"), - ("busan", "釜山", "RKPK", "Gimhae", 9, 2.0, "KST"), - ("tokyo", "东京", "44166", "Haneda", 9, 2.0, "JST"), - ("ankara", "安卡拉", "17128", "Esenboğa", 3, 3.0, "TRT"), - ("helsinki", "赫尔辛基", "EFHK", "Vantaa", 3, 2.0, "EEST"), - ("amsterdam","阿姆斯特丹","EHAM","Schiphol",2,2.0,"CEST"), - ("istanbul","伊斯坦布尔","17058","Airport",3,3.0,"TRT"), - ("paris", "巴黎", "LFPB", "Le Bourget", 2, 3.0, "CEST"), - ("hong kong","香港","HKO","Observatory",8,1.5,"HKT"), - ("lau fau shan","流浮山","LFS","Lau Fau Shan",8,1.5,"HKT"), - ("taipei", "台北", "466920", "Songshan", 8, 1.5, "TST"), +// (key, zh_name, en_name, icao, airport_en, utc_offset_hours, threshold, tz_abbr) +const CITIES: &[(&str, &str, &str, &str, &str, i32, f64, &str)] = &[ + ("seoul", "首尔", "Seoul", "RKSI", "Incheon", 9, 3.0, "KST"), + ("busan", "釜山", "Busan", "RKPK", "Gimhae", 9, 2.0, "KST"), + ("tokyo", "东京", "Tokyo", "44166", "Haneda", 9, 2.0, "JST"), + ("ankara", "安卡拉", "Ankara", "17128", "Esenboğa", 3, 3.0, "TRT"), + ("helsinki", "赫尔辛基", "Helsinki", "EFHK", "Vantaa", 3, 2.0, "EEST"), + ("amsterdam","阿姆斯特丹","Amsterdam","EHAM","Schiphol",2,2.0,"CEST"), + ("istanbul","伊斯坦布尔","Istanbul","17058","Airport",3,3.0,"TRT"), + ("paris", "巴黎", "Paris", "LFPB", "Le Bourget", 2, 3.0, "CEST"), + ("hong kong","香港","Hong Kong","HKO","Observatory",8,1.5,"HKT"), + ("lau fau shan","流浮山","Lau Fau Shan","LFS","Lau Fau Shan",8,1.5,"HKT"), + ("taipei", "台北", "Taipei", "466920", "Songshan", 8, 1.5, "TST"), ]; // ── app state ── @@ -49,7 +49,7 @@ struct MonitorTemplate { // ── data loading ── -fn load_city_snapshot(db_path: &str, (key, display, icao, airport, tz, thresh, tz_abbr): &(&str, &str, &str, &str, i32, f64, &str)) -> CitySnapshot { +fn load_city_snapshot(db_path: &str, (key, _zh, en, icao, airport, tz, thresh, tz_abbr): &(&str, &str, &str, &str, &str, i32, f64, &str)) -> CitySnapshot { let now_utc = Utc::now(); let local = now_utc + chrono::Duration::hours(*tz as i64); let local_time = format!("{} {}", local.format("%H:%M"), tz_abbr); @@ -84,13 +84,9 @@ fn load_city_snapshot(db_path: &str, (key, display, icao, airport, tz, thresh, t _ => false, }; - // For AMOS cities, we'd need runway data from a different DB table. - // Simplified: no runway pairs for now; can be added later. - let runway_pairs: Vec<(String, f64)> = vec![]; - CitySnapshot { name: key.to_string(), - display_name: display.to_string(), + en_name: en.to_string(), airport: airport.to_string(), icao: icao.to_string(), local_time, @@ -99,7 +95,7 @@ fn load_city_snapshot(db_path: &str, (key, display, icao, airport, tz, thresh, t max_time: None, trend, new_high, - runway_pairs, + runway_pairs: vec![], gap: None, threshold: *thresh, time_ok: false, @@ -140,8 +136,6 @@ async fn api_data(State(state): State>) -> impl IntoResponse { Html(tmpl.render().unwrap_or_else(|e| format!("Template error: {e}"))) } -// ── main ── - #[tokio::main] async fn main() { tracing_subscriber::fmt::init(); diff --git a/monitoring-web/src/model.rs b/monitoring-web/src/model.rs index adfc5256..b3bd7421 100644 --- a/monitoring-web/src/model.rs +++ b/monitoring-web/src/model.rs @@ -3,7 +3,7 @@ use serde::Serialize; #[derive(Debug, Clone, Serialize)] pub struct CitySnapshot { pub name: String, - pub display_name: String, + pub en_name: String, pub airport: String, pub icao: String, pub local_time: String, diff --git a/monitoring-web/static/style.css b/monitoring-web/static/style.css index b2f61d91..1eb2a64b 100644 --- a/monitoring-web/static/style.css +++ b/monitoring-web/static/style.css @@ -28,6 +28,22 @@ body { color: #e8eaed; letter-spacing: 0.02em; } +.header-right { + display: flex; + align-items: center; + gap: 12px; +} +.notify-btn { + background: none; + border: 1px solid #2a2e40; + border-radius: 6px; + padding: 3px 8px; + font-size: 16px; + cursor: pointer; + transition: border-color 0.2s; +} +.notify-btn:hover { border-color: #4a5160; } +.notify-btn.muted { opacity: 0.4; } /* ── grid ── */ .card-grid { diff --git a/monitoring-web/templates/monitor.html b/monitoring-web/templates/monitor.html index d08aba8c..da18477e 100644 --- a/monitoring-web/templates/monitor.html +++ b/monitoring-web/templates/monitor.html @@ -4,31 +4,33 @@ -市场监控 — PolyWeather +Market Monitor — PolyWeather
-

🔥 市场监控

- 更新中… +

🔥 Market Monitor

+
+ + 更新中… +
{% endif %}
- + {{ generated_at }} {% for c in cities %} -
+
- {{ c.display_name }} + {{ c.en_name }} / {{ c.airport }} {{ c.local_time }} - {% if c.new_high %} - ◆新高 - {% endif %}
@@ -42,7 +44,7 @@
- 今日最高 + Today High {% match c.today_max %} {% when Some with (m) %} {{ "{:.1}"|format(m) }}°C @@ -52,10 +54,10 @@ {{ c.trend.symbol() }}
- 观测 + Obs {% match c.obs_age_min %} {% when Some with (m) %} - {{ m }} 分钟前 + {{ m }} min ago {% when None %} -- {% endmatch %} @@ -65,12 +67,63 @@ {% endfor %}
-
刷新中…
+
Refreshing…
{% if full_page %}