@
添加市场监控 Rust 网页版:Axum+Askama+HTMX,直读 SQLite - 11 城市卡片网格,暗色主题,响应式布局 - 60s HTMX 轮询局部刷新 - 当前温度、今日最高、趋势箭头(线性回归) - 首尔/釜山跑道温度(预留) - 零 Python 依赖,编译后 ~3MB 二进制 Constraint: 读 POLYWEATHER_DB_PATH 指向的 SQLite @
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct CitySnapshot {
|
||||
pub name: String,
|
||||
pub display_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,
|
||||
}
|
||||
|
||||
#[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 => "",
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user