移除日期未知和修正页面定位

This commit is contained in:
mtvpls
2026-04-18 09:33:38 +08:00
parent 31af8a6814
commit 897d475ad5
4 changed files with 54 additions and 4 deletions
+27
View File
@@ -0,0 +1,27 @@
'use client';
import { usePathname } from 'next/navigation';
import { useEffect } from 'react';
export default function RouteScrollReset() {
const pathname = usePathname();
useEffect(() => {
if (typeof window === 'undefined' || !pathname?.startsWith('/manga') || pathname === '/manga/read') return;
const reset = () => {
window.scrollTo({ top: 0, left: 0, behavior: 'auto' });
document.documentElement.scrollTop = 0;
document.body.scrollTop = 0;
};
reset();
const rafId = window.requestAnimationFrame(reset);
return () => {
window.cancelAnimationFrame(rafId);
};
}, [pathname]);
return null;
}