From 283d8d287a4b632c0a03c439e46389d813a6bcb6 Mon Sep 17 00:00:00 2001 From: Praveen Bishnoi Date: Tue, 13 Oct 2026 17:21:29 +0530 Subject: [PATCH] =?UTF-8?q?fix(index):=20=E9=81=BF=E5=85=8D=20writeUrl=20?= =?UTF-8?q?=E4=BF=9D=E7=95=99=E6=97=A0=E6=95=88=20hash=20=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=88=B7=E6=96=B0=E4=B8=A2=E5=A4=B1=E6=A3=80=E7=B4=A2?= =?UTF-8?q?=E8=AF=8D=EF=BC=8C=E5=B9=B6=E9=98=B2=E6=AD=A2=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E6=97=B6=E5=BF=AB=E6=8D=B7=E9=94=AE=E6=8A=A2=E7=84=A6=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. writeUrl() 中仅在当前筛选下目标卡片可见时保留 location.hash,并在 replaceState 中传递 history.state 保留历史定位状态,避免 F5 刷新时因 hash 与新筛选条件冲突导致检索词被误重置。2. 全局 keydown 监听在长文弹窗或赞赏弹窗打开时跳过快捷键,避免 / 键窃取焦点破坏模态弹窗体验。 --- index.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 55ccd92..843b4b8 100644 --- a/index.html +++ b/index.html @@ -1157,7 +1157,10 @@ function writeUrl(){ for (const d of DIMS) if (state[d].size) p.set(d, [...state[d]].join(',')); if (state.dispute) p.set('dispute','1'); if (state.todo) p.set('todo','1'); if (PERF.on) p.set('perf','1'); - const qs = p.toString(); history.replaceState(null, '', (qs ? '?'+qs : location.pathname) + location.hash); + const qs = p.toString(); + const hash = location.hash; + const validHash = hash && document.getElementById(hash.slice(1))?.offsetParent ? hash : ''; + history.replaceState(history.state, '', (qs ? '?'+qs : location.pathname) + validHash); } function syncControls(){ document.getElementById('q').value = state.q; @@ -1278,6 +1281,7 @@ function wire(){ document.getElementById('reset').addEventListener('click', reset); document.getElementById('reset2').addEventListener('click', reset); document.addEventListener('keydown', e => { + if (!DM.mask.hidden || !TIP.hidden) return; if (e.key === '/' && !/INPUT|TEXTAREA/.test(document.activeElement.tagName)) { e.preventDefault(); document.getElementById('q').focus(); } if (e.key === 'Escape') { if (document.activeElement.id === 'q') document.activeElement.blur(); setMenu(false); } });