// ============================================================ // 📋 帖子列表 // ============================================================ let currentSort = 'latest'; let totalPages = 1; const PAGE_SIZE = 20; // 当前搜索关键词。为空表示处于普通列表模式。 let currentSearch = ''; // 翻页后滚回列表顶部。分页控件在列表末尾,不回到顶部的话用户看到的 // 仍是新一页的底部。 // 尊重系统的「减少动画」设置:开启时直接跳转,不做平滑滚动。 function scrollFeedToTop() { const reduceMotion = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches; window.scrollTo({ top: 0, behavior: reduceMotion ? 'auto' : 'smooth', }); } function renderFeed() { const container = document.getElementById('postList'); const keyword = currentSearch; // 骨架屏只在首次加载时显示。翻页时列表已有内容,再画一遍骨架会 // 造成明显的闪动,反而比直接留白更糟。 const isFirstLoad = container.dataset.loaded !== '1'; container.innerHTML = isFirstLoad ? Skeleton.postList(3) : '