import React from 'react' import type { TOCItem } from '@/lib/utils' import { useWallpaper } from '@/stores' export interface TOCProps { isOpen: boolean onClose: () => void tocItems: TOCItem[] width: number onResizeStart: (e: React.MouseEvent) => void onTOCItemClick: (id: string) => void } const renderTOCItem = (item: TOCItem, onTOCItemClick: (id: string) => void) => { const indent = (item.level - 1) * 16 return (
onTOCItemClick(item.id)} > {item.text}
{item.children.length > 0 && (
{item.children.map(child => renderTOCItem(child, onTOCItemClick))}
)}
) } export const TOC: React.FC = ({ isOpen, onClose, tocItems, width, onResizeStart, onTOCItemClick }) => { const { opacity } = useWallpaper() return (
目录
{tocItems.length > 0 ? (
{tocItems.map(item => renderTOCItem(item, onTOCItemClick))}
) : (
)}
) }