KennethCheng
|
07317e2890
|
feat(storage): Phase 5 C1 — AppConfig 持久化到 config.json
- src/storage/config.rs: AppConfig + ServerEntry + load_config +
save_config,atomic write(tmp + rename + fsync);多 server
数据结构按 §21 落地但 V1 只 active 一个;3 个 #[cfg(test)]
round-trip + default + missing-field 测试
- src/storage/state.rs: 从 src/storage.rs 拆过来;atomic write + 2
个测试(default 960×680 + JSON round-trip)
- src/storage/mod.rs: pub use re-export 两组 API
- src/config.rs: 重构为 ActiveConfig thin wrapper,调
storage::load_config() 拿到第一个 selected_server;placeholder
hardcoded URL/token 在 §19/§20 意义上不再合适,删掉
- src/gotify/model.rs: ServerConfig 加 Serialize/Deserialize(要
写到 config.json 必须能 serialize;token 仍走 §20 不进日志)
- src/lib.rs: run() 启动用 ActiveConfig::load() 取代 placeholder;
on_test_connection_requested 同样改用 ActiveConfig::load()
- 删除 src/storage.rs(被 src/storage/{config,state}.rs 替代;
同样内容已迁过去)
避坑:
- ServerConfig 之前没 derive Serialize,所以 #[serde(flatten)]
嵌套到 ServerEntry 失败——加 derive 是必要的
- src/storage.rs 和 src/storage/mod.rs 不能并存,否则 Rust 报
ambiguous module;删旧文件就行
- AppConfig 多 vec + serde default 让旧 config 文件(字段缺失)
也能 forward-compat parse(3 个测试覆盖)
验证:cargo build / build --release 都 exit 0,0 warning
- cargo test: 14 passed (5 storage unit + 6 api + 3 websocket); 0 failed
- debug 35.54 MB, subsystem = WINDOWS_CUI
- release 9.76 MB, subsystem = WINDOWS_GUI
|
2026-09-19 06:46:16 +08:00 |
|
KennethCheng
|
0cf7a4eaaa
|
feat(gotify): Phase 3 C2 — UI 接线 + Connection status + 真实数据
- src/config.rs: AppConfig::placeholder() 硬编码 NAS 地址 + 假 token
(§20 token 永不日志;Phase 5 接持久化前占位)
- src/models.rs: gotify_messages_to_items 把 GotifyMessage 列表转
Slint MessageItem[];try_fetch_real_messages 一次完成 health →
applications → messages(50);失败 None 让调用方 fallback mock
- src/gotify/mod.rs: re-export ServerConfig
- src/lib.rs: run() 启动时调 try_fetch_real_messages,成功用真实数
据 + Connected + 服务端 URL,失败 fallback mock + Disconnected;
on_test_connection_requested 重新跑同一路径
- Cargo.toml: 加 chrono 0.4 (RFC3339 解析)
- ui/app.slint: is-connected (绿/灰 dot) + status-text (顶部副标)
- ui/settings-page.slint: Connection section 加 Test Connection 按钮
(in-progress 时禁用显示 "Testing...")
避坑:
- Gotify RFC3339 date 解析失败 silent fallback 到 unix=0(显示
"just now" 而不是崩)
- Gotify priority 0..10 → Slint Priority 4 桶分桶:<=0 Low / <=3
Normal / <=7 High / else Max
- ServerConfig 在 crate::gotify::model 子模块,mod.rs 必须 re-export
验证:cargo build / build --release 都 exit 0,0 warning
- cargo test --test gotify_api: 6 passed
- debug 33.36 MB, subsystem = WINDOWS_CUI
- release 9.43 MB, subsystem = WINDOWS_GUI(chrono +1.3 MB)
|
2026-09-19 05:18:26 +08:00 |
|