// import Image from 'next/image' import LazyImage from '@/components/LazyImage' import { siteConfig } from '@/lib/config' import { useGlobal } from '@/lib/global' import { loadExternalResource } from '@/lib/utils' import { useEffect, useState } from 'react' import CONFIG from '../config' let wrapperTop = 0 /** * 首页英雄区 * 是一张大图,带个居中按钮 * @returns 头图 */ const Hero = props => { const [typed, changeType] = useState() const { siteInfo } = props const { locale } = useGlobal() const GREETING_WORDS = siteConfig('GREETING_WORDS').split(',') useEffect(() => { updateHeaderHeight() if (!typed && window && document.getElementById('typed')) { loadExternalResource('/js/typed.min.js', 'js').then(() => { if (window.Typed) { changeType( new window.Typed('#typed', { strings: GREETING_WORDS, typeSpeed: 200, backSpeed: 100, backDelay: 400, showCursor: true, smartBackspace: true }) ) } }) } window.addEventListener('resize', updateHeaderHeight) return () => { window.removeEventListener('resize', updateHeaderHeight) } }, []) function updateHeaderHeight() { requestAnimationFrame(() => { const wrapperElement = document.getElementById('wrapper') wrapperTop = wrapperElement?.offsetTop }) } return ( ) } export default Hero