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 <>
{/* 侧边菜单 */}
{post && <>
{locale.COMMON.TABLE_OF_CONTENTS}
}
{/* 背景蒙版 */}
} export default TocDrawer