From d5b83a00752b0e85860f3e1900b4c985ecd159f9 Mon Sep 17 00:00:00 2001 From: grabbit Date: Thu, 19 Feb 2026 17:30:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SSE=20=E5=AE=9E=E6=97=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=90=8C=E6=AD=A5=E7=8A=B6=E6=80=81=E6=8C=87=E7=A4=BA?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sync-status 区域未包含在 SSE OOB swap 中,导致页面加载后 状态永远不会更新。新增 SyncStatusPartial 模板并加入 SSE payload,使 dirty count 归零时 UI 能实时切换。 Co-Authored-By: Claude Sonnet 4.6 --- src/web/sse.rs | 14 ++++++++++++++ templates/web/partials/sync_status.html | 13 +++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 templates/web/partials/sync_status.html diff --git a/src/web/sse.rs b/src/web/sse.rs index 0e6c207..553e49c 100644 --- a/src/web/sse.rs +++ b/src/web/sse.rs @@ -119,6 +119,10 @@ fn render_sse_payload( webdav_running: status.webdav_running, }; + let sync_status = SyncStatusPartial { + all_synced: status.all_synced, + }; + let mut html = String::new(); // Primary target: dashboard stats if let Ok(s) = stats.render() { @@ -132,6 +136,10 @@ fn render_sse_payload( if let Ok(s) = badges.render() { html.push_str(&s); } + // OOB: sync status indicator + if let Ok(s) = sync_status.render() { + html.push_str(&s); + } html } @@ -205,3 +213,9 @@ struct ProtocolBadgesPartial { nfs_exported: bool, webdav_running: bool, } + +#[derive(Template)] +#[template(path = "web/partials/sync_status.html")] +struct SyncStatusPartial { + all_synced: bool, +} diff --git a/templates/web/partials/sync_status.html b/templates/web/partials/sync_status.html new file mode 100644 index 0000000..d2e9133 --- /dev/null +++ b/templates/web/partials/sync_status.html @@ -0,0 +1,13 @@ +{% if all_synced %} +
+ + 已全部同步 — 可以断网 + All synced — safe to disconnect +
+{% else %} +
+ + 同步进行中 — 请勿断网 + Sync in progress — do not disconnect +
+{% endif %}