import Toc from './Toc' import { useImperativeHandle, useState } from 'react' import { useGlobal } from '@/lib/global' /** * 目录抽屉栏 * @param toc * @param post * @returns {JSX.Element} * @constructor */ const TocDrawer = ({ post, cRef }) => { // 暴露给父组件 通过cRef.current.handleMenuClick 调用 useImperativeHandle(cRef, () => { return { handleSwitchVisible: () => switchVisible() } }) const [showDrawer, switchShowDrawer] = useState(false) const switchVisible = () => { switchShowDrawer(!showDrawer) } const { locale } = useGlobal() return <>