From ed75f3160a3f08c94ceb2a0ac458353bd5e3ed3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E5=8F=89=E6=A0=91=E6=A0=91?= Date: Sun, 25 Jan 2026 20:28:34 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=80=9A=E7=9F=A5=E7=BB=84=E4=BB=B6):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=A5=E7=9C=8B=E6=9B=B4=E6=96=B0=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E7=82=B9=E5=87=BB=E5=A4=B1=E6=95=88=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E6=BB=9A=E5=8A=A8=E6=9D=A1=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 data-diff-toggle 事件委托改为直接 onclick 绑定,解决 Astro 组件重渲染时事件监听失效问题 - 为更新列表添加 overflow-x: hidden 防止水平滚动 - 在组件内定义自定义滚动条样式,统一各浏览器显示效果 - 调整通知级别从 warning 改为 info 以匹配实际使用场景 --- .../widget/NewPostNotification.astro | 51 +++++++++++++++---- src/config.ts | 2 +- src/content/posts/pin.md | 2 + 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/components/widget/NewPostNotification.astro b/src/components/widget/NewPostNotification.astro index 9855f4f72..de52ae69e 100644 --- a/src/components/widget/NewPostNotification.astro +++ b/src/components/widget/NewPostNotification.astro @@ -1,3 +1,26 @@ + +
-
+
@@ -198,7 +221,7 @@ if (isUpdated && post.diff) { diffButton = ` - `; } @@ -329,16 +352,22 @@ }; // Add event delegation for toggles - list.addEventListener('click', (e) => { - const btn = e.target.closest('[data-diff-toggle]'); - if (btn) { - const targetId = btn.getAttribute('data-diff-toggle'); - const target = document.getElementById(targetId); - if (target) { - target.classList.toggle('hidden'); - } + // Remove and re-add to ensure freshness + // Or better, just use one listener on the container that always works + // The previous check if (!list.hasAttribute('data-listening')) might be persisting across re-renders improperly if Astro keeps DOM + // Let's make it robust: + + // Remove existing listener if possible? No easy way without reference. + // Instead, let's use a unique attribute or just replace the node (expensive) + // Or simpler: assign onclick handler to the list container which bubbles up + + // Use a window-level handler for maximum robustness, filtering by ID + window.toggleDiff = function(safeId) { + const target = document.getElementById(safeId); + if (target) { + target.classList.toggle('hidden'); } - }); + }; // Auto-open panel on first load if it's high priority? // Or keep it minimized to be less intrusive? diff --git a/src/config.ts b/src/config.ts index c99d54379..4ea8bb5c8 100644 --- a/src/config.ts +++ b/src/config.ts @@ -13,7 +13,7 @@ import { LinkPreset } from "./types/config"; export const noticeConfig: NoticeConfig = { enable: true, - level: "warning", + level: "info", content: "我们刚刚添加了文章更新系统,自此之后的每次文章更新都会通过右下角的小铃铛提醒您。", }; diff --git a/src/content/posts/pin.md b/src/content/posts/pin.md index dcf2c6586..fa3c254fa 100644 --- a/src/content/posts/pin.md +++ b/src/content/posts/pin.md @@ -25,6 +25,8 @@ description: 关于如何联系二叉树树~ # 非官方 +123123123121231231231212312312312123123123121231231231212312312312123123123121231231231212312312312123123123121231231231212312312312123123123121231231231212312312312123123123121231231231212312312312123123123121231231231212312312312123123123121231231231212312312312123123123121231231231212312312312123123123121231231231212312312312123123123121231231231212312312312123123123121231231231212312312312123123123121231231231212312312312123123123121231231231212312312312 + > 粉丝自建 [Telegram: View @blog2x](https://t.me/blog2x) \ No newline at end of file