feat: 优化页面切换时的滚动行为,确保用户体验流畅

This commit is contained in:
2025-09-12 13:02:37 +08:00
parent d1d8aa529f
commit d893300cac

View File

@ -68,11 +68,8 @@ export default function BlogHome() {
}; };
const handlePageChange = (page: number) => { const handlePageChange = (page: number) => {
// 修改查询参数和状态 window.scrollTo({ top: 0, behavior: 'smooth' });
setCurrentPage(page); setCurrentPage(page);
// 不滚动到顶部,用户可能在阅读侧边栏
// window.scrollTo({ top: 0, behavior: 'smooth' });
// 修改查询参数
const params = new URLSearchParams(searchParams.toString()); const params = new URLSearchParams(searchParams.toString());
params.set('page', page.toString()); params.set('page', page.toString());
const newUrl = `${window.location.pathname}?${params.toString()}`; const newUrl = `${window.location.pathname}?${params.toString()}`;