import { useEffect } from 'react';  
import { useLocation } from 'react-router-dom';  

const useScrollToTop = () => {  
    const { pathname } = useLocation();  

    useEffect(() => {  
        window.scrollTo(0, 0); // 跳转到顶部  
    }, [pathname]); // 每次 pathname 变化时重置滚动位置  
};  

export default useScrollToTop;