feat: initialize new React application structure with TypeScript, ESLint, and Prettier configurations, while removing legacy files and adding new components and pages for enhanced functionality

This commit is contained in:
Supra4E8C
2025-12-07 11:32:31 +08:00
parent 8e4132200d
commit 450964fb1a
144 changed files with 14223 additions and 21647 deletions

24
src/hooks/useInterval.ts Normal file
View File

@@ -0,0 +1,24 @@
/**
* 定时器 Hook
*/
import { useEffect, useRef } from 'react';
export function useInterval(callback: () => void, delay: number | null) {
const savedCallback = useRef<(() => void) | null>(null);
useEffect(() => {
savedCallback.current = callback;
}, [callback]);
useEffect(() => {
if (delay === null) return;
const tick = () => {
savedCallback.current?.();
};
const id = setInterval(tick, delay);
return () => clearInterval(id);
}, [delay]);
}