import CommonHead from '@/components/CommonHead' import { useCallback, useEffect, useState } from 'react' import Footer from './components/Footer' import JumpToTopButton from './components/JumpToTopButton' import TopNav from './components/TopNav' import Live2D from '@/components/Live2D' import LoadingCover from './components/LoadingCover' import { useGlobal } from '@/lib/global' import BLOG from '@/blog.config' import FloatDarkModeButton from './components/FloatDarkModeButton' import throttle from 'lodash.throttle' import { isBrowser, loadExternalResource } from '@/lib/utils' import SocialButton from './components/SocialButton' /** * 基础布局 采用左右两侧布局,移动端使用顶部导航栏 * @param props * @returns {JSX.Element} * @constructor */ const LayoutBase = props => { const { children, headerSlot, meta, siteInfo } = props const [show, switchShow] = useState(false) const { onLoading } = useGlobal() const throttleMs = 200 const scrollListener = useCallback(throttle(() => { const scrollY = window.pageYOffset const shouldShow = scrollY > 300 if (shouldShow !== show) { switchShow(shouldShow) } }, throttleMs)) useEffect(() => { document.addEventListener('scroll', scrollListener) return () => document.removeEventListener('scroll', scrollListener) }, []) if (isBrowser()) { loadExternalResource('/css/theme-matery.css', 'css') } return (