main #4

Merged
lan merged 8 commits from uNagi/carrotskin:main into main 2026-01-11 18:54:01 +08:00
Showing only changes of commit fb8ae43083 - Show all commits

View File

@@ -24,12 +24,12 @@ export default function Home() {
useEffect(() => {
// 添加防抖处理,减少状态更新频率
let timeoutId: NodeJS.Timeout;
let timeoutId: number | undefined;
const handleMouseMove = (e: MouseEvent) => {
// 使用防抖每16ms更新一次约60fps
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
timeoutId = window.setTimeout(() => {
setMousePosition({ x: e.clientX, y: e.clientY });
}, 16);
};
@@ -38,7 +38,9 @@ export default function Home() {
return () => {
window.removeEventListener('mousemove', handleMouseMove);
clearTimeout(timeoutId);
if (timeoutId) {
clearTimeout(timeoutId);
}
};
}, []);