From e5b57203fb7f9cceeb2a1aa2ac59bec040386f17 Mon Sep 17 00:00:00 2001 From: becomer Date: Wed, 21 Oct 2026 17:35:28 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=AE=E9=A1=B6=E5=85=AC=E5=91=8A=EF=BC=9A?= =?UTF-8?q?=E5=9B=9E=E5=88=B0=E5=89=8D=E5=8F=B0=E6=97=B6=E9=87=8D=E6=96=B0?= =?UTF-8?q?=E6=B5=8B=E9=87=8F=E6=96=87=E6=9C=AC=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit onVisibility 原先只调 schedule(),不重新测量。后台期间若发生尺寸变化 (横竖屏切换、系统字体缩放、页面布局重排),overflow 仍是旧值, 长文本的滚动距离会算错,表现为「还没滚完就翻页」或「滚过头留白」, 而 measure() 本身只在挂载和 resize 时执行。 改为回到前台先 measure() 再 schedule(),与 resize 处理保持一致。 审查同类边界,以下均已正确处理,未改动: - items 为空:模板用 v-if="current" 不渲染 - 只有 1 条且不溢出:schedule 直接 return,不空转定时器 - items 长度变化:watch 中把越界索引归零 - 滚动时长:Math.min(9, Math.max(3, ...)) 有上下限, 不会出现 NaN/Infinity 导致 setTimeout 异常 npm run build 与 vue-tsc 均通过。 --- frondend/src/components/PinnedNotice.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frondend/src/components/PinnedNotice.vue b/frondend/src/components/PinnedNotice.vue index 41472bd..eede1d8 100644 --- a/frondend/src/components/PinnedNotice.vue +++ b/frondend/src/components/PinnedNotice.vue @@ -74,8 +74,14 @@ watch( ) function onVisibility() { - if (document.visibilityState === 'visible') schedule() - else clearTimer() + if (document.visibilityState === 'visible') { + // 回到前台时重新测量:后台期间可能发生过尺寸变化(横竖屏切换、 + // 系统字体缩放等),若沿用旧的 overflow,长文本的滚动距离会算错, + // 出现「还没滚完就翻页」或「滚过头留白」。 + void measure().then(schedule) + } else { + clearTimer() + } } function openAll() {