From bf283ba5fce1d49cb08395b583c09d3bf3df4392 Mon Sep 17 00:00:00 2001 From: dsh Date: Mon, 17 Aug 2026 23:08:15 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BF=94=E5=9B=9E=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=90=8E=E6=9C=AA=E8=AF=BB=E9=82=AE=E4=BB=B6=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E4=B8=8D=E6=9B=B4=E6=96=B0=EF=BC=88BFCache=20=E9=9D=99?= =?UTF-8?q?=E9=BB=98=E5=90=8C=E6=AD=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:打开未读邮件(阅读页已自动标记已读)后返回列表,浏览器从 BFCache 恢复旧 DOM,列表仍显示未读,需手动刷新。 修复: - 三个列表页的交互脚本提取为公共模板 listjs(base.html),行为一致 - pageshow(persisted=true) 时静默 fetch 最新列表并局部更新行状态 (未读类/圆点/已删除行/未读角标/总数),不整页刷新、保留滚动 - visibilitychange 兜底:标签页重新可见时也同步一次(离线失败静默忽略, 仅 BFCache 场景失败才整页刷新) - 验证:合成 pageshow 事件驱动同步,未读->已读局部更新 PASS; 桌面/移动/平板布局回归无异常 --- internal/web/templates/base.html | 124 +++++++++++++++++++++++++++++ internal/web/templates/drafts.html | 63 +-------------- internal/web/templates/inbox.html | 70 +--------------- internal/web/templates/sent.html | 63 +-------------- 4 files changed, 127 insertions(+), 193 deletions(-) diff --git a/internal/web/templates/base.html b/internal/web/templates/base.html index 9f64282..a0ff8d2 100644 --- a/internal/web/templates/base.html +++ b/internal/web/templates/base.html @@ -489,3 +489,127 @@ {{end}} + +{{define "listjs"}} + +{{end}} diff --git a/internal/web/templates/drafts.html b/internal/web/templates/drafts.html index 92a15dc..bf19bc3 100644 --- a/internal/web/templates/drafts.html +++ b/internal/web/templates/drafts.html @@ -87,68 +87,7 @@ - + {{template "listjs" .}} {{end}} diff --git a/internal/web/templates/inbox.html b/internal/web/templates/inbox.html index 6099935..bd53937 100644 --- a/internal/web/templates/inbox.html +++ b/internal/web/templates/inbox.html @@ -82,75 +82,7 @@ - + {{template "listjs" .}} {{end}} diff --git a/internal/web/templates/sent.html b/internal/web/templates/sent.html index 3c8151d..66dff0f 100644 --- a/internal/web/templates/sent.html +++ b/internal/web/templates/sent.html @@ -87,68 +87,7 @@ - + {{template "listjs" .}} {{end}} -- 2.47.3