import { useGlobal } from '@/lib/global' import { faArrowDown } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import throttle from 'lodash.throttle' import { useCallback, useEffect, useState } from 'react' import Typed from 'typed.js' /** * * @returns 头图 */ export default function Header () { const [typed, changeType] = useState() useEffect(() => { if (!typed) { changeType(new Typed('#typed', { stringsElement: '#typed-strings', typeSpeed: 200, showCursor: false })) } }) const scrollToCenter = () => { document.getElementById('wrapper').scrollIntoView({ behavior: 'smooth' }) } const { theme } = useGlobal() // 监听滚动自动分页加载 const scrollTrigger = useCallback(throttle(() => { if (theme !== 'dark') { const stickyNavElement = document.getElementById('sticky-nav') if (window.scrollY < window.innerHeight) { stickyNavElement.classList.add('dark') } else { stickyNavElement.classList.remove('dark') } } }, 500)) // 监听滚动 useEffect(() => { scrollTrigger() window.addEventListener('scroll', scrollTrigger) return () => { window.removeEventListener('scroll', scrollTrigger) } }) return

唐风集里,收卷波澜。

}