28524b4128712b3ddc4d33416179f686bdd9ce5a
- src/storage/state.rs: AppState 加 last_theme (string "system" /
"light" / "dark") + last_message_id (i64);#[serde(default)]
让 legacy state.json(只有 window width/height)也能 forward-
compat parse;3 个 test(含 legacy round-trip)
- src/gotify/api.rs: messages() 加 since: Option<i64> 参数,
since>0 时拼 ?since=N&limit=M
- src/models.rs: try_fetch_initial_data 加 since 参数透传
- src/lib.rs: state_rc: Rc<RefCell<AppState>> 替代只读 initial_state
· 启动读 last_theme 应用到 MainWindow.theme + appearance_index
· HTTP catch-up 用 since=last_message_id;返回的 msgs 推
watermark
· WS drain closure 同步更新 last_message_id(共享 Rc 进 UI
线程 closure)
· on_close_requested 把整个 state clone 一份再 save(state_for_
save Rc 也被 drain 用,不能 hold borrow 同时 serialize)
· 新 callback appearance-changed-persist:Settings → Appearance
radio 改 theme 时立刻写 state.last_theme
- ui/app.slint: MainWindow 加 appearance-changed-persist callback;
SettingsPage 的 appearance-changed 调它
避坑:
- VecModel 不是 Send → last_message_id 维护必须放在 UI 线程的
timer drain closure 里(不是 WS worker),所以走 Rc<RefCell>
共享 + 不需要锁
- on_close_requested 之前用 state_for_save.borrow_mut() 修改然后
borrow() save——drain 也在 borrow_mut() 会死锁(同一 RefCell)。
改成"修改 borrow_mut + save clone",避免同时持有两个 borrow
- AppearanceMode::Dark 的 parse fallback:state.json 写错时不
锁死在 Light
- legacy state.json 没 last_theme / last_message_id 也能正常
parse + 用 default(serde(default) + 1 个测试覆盖)
验证:cargo build / build --release 都 exit 0,0 warning
- cargo test: 15 passed (6 storage unit + 6 api + 3 websocket); 0 failed
- debug 35.56 MB, subsystem = WINDOWS_CUI
- release 9.77 MB, subsystem = WINDOWS_GUI
Windows-Gotify-Client-Rust
轻量、现代、Windows 原生体验良好的 Gotify 桌面客户端,使用 Rust + Slint 构建。
详细的产品定位、技术栈约束、架构、UI 规范与分阶段实施计划全部记录在
AGENTS.md。本文档只做项目导览。
状态
🚧 从 0 起步 —— 当前仓库只有目录骨架与占位 Cargo.toml,尚未进入 Phase 1(Bootstrap)。
完整 8 阶段路线图见 AGENTS.md §57。
目标平台
- Windows 10 x64
- Windows 11 x64(ARM64 条件允许时支持)
- 后台常驻、托盘型客户端
技术栈
| 层 | 选型 |
|---|---|
| 语言 | Rust stable |
| UI | Slint 1.17.x |
| HTTP | reqwest(blocking + rustls) |
| WebSocket | tungstenite |
| Windows 集成 | windows-rs focused crates(按需引入) |
| 配置 / 状态 | JSON 文件(%APPDATA%/WindowsGotify/) |
| 日志 | tracing + tracing-subscriber |
显式禁用:Tauri / Wails / Electron / WebView2 / WPF / WinUI 3 / Node 运行时。
理由见 AGENTS.md §2。
仓库布局
Windows-Gotify-Client-Rust/
├── Cargo.toml # 占位 — 见 AGENTS.md §44
├── AGENTS.md # AI Agent 实施计划(1363 行)
├── README.md
├── LICENSE # MIT(占位)
├── .gitignore
├── assets/ # 图标、字体等
├── ui/ # Slint 视图
├── src/ # Rust 业务代码
│ ├── gotify/ # HTTP + WebSocket
│ ├── storage/ # config.json / state.json
│ ├── windows/ # 托盘 / Toast / 启动 / 单实例 / URL
│ └── services/ # 生命周期
├── tests/ # 集成测试
└── scripts/ # PowerShell 构建脚本
开发环境
本仓库目前还没有源码,本节将在 Phase 1 完成后补全具体的
cargo run/cargo build --release步骤。
隐私与安全
- App Token 默认以 JSON 明文存储在
%APPDATA%/WindowsGotify/config.json,仅当前用户可访问 - 日志永不打印完整
Authorization头 - 通知点击的
click.url仅允许http:///https://,拒绝file:///javascript:/ 自定义 scheme - 详细策略见
AGENTS.md§13 / §20 / §38 / §51
License
MIT(见 LICENSE)。