chore: dashboard load optimization

This commit is contained in:
jialin
2024-07-05 18:51:13 +08:00
parent e9d8828dcd
commit 8c66c482b2
10 changed files with 238 additions and 227 deletions
+11 -8
View File
@@ -39,23 +39,26 @@ export default function useWindowResize() {
setIsDesktop(true);
setCurrentPoint('xl');
}, []);
const handleResize = _.throttle(() => {
setSize({
width: window.innerWidth,
height: window.innerHeight
});
}, 200);
const handleResize = useCallback(
_.throttle(() => {
setSize({
width: window.innerWidth,
height: window.innerHeight
});
}, 200),
[]
);
useEffect(() => {
window.addEventListener('resize', handleResize);
return () => {
window.removeEventListener('resize', handleResize);
};
}, []);
}, [handleResize]);
useEffect(() => {
checkBreakpoint(size.width);
}, [size.width]);
}, [size.width, checkBreakpoint]);
return { size, isMobile, isTablet, isDesktop, currentPoint };
}