'use client' import React from 'react' export type MenuItem = {key: string, label: string, desc?: string, icon?: string} export type Section = {title: string, items: MenuItem[]} export const MENU: Section[] = [ { title: '官网教程', items: [ {key: 'browser-proxy', label: '浏览器设置代理教程'}, {key: 'code-download', label: '代码下载'}, {key: 'api-docs', label: 'API 文档'}, ], }, { title: '客户端教程', items: [ {key: 'client-install', label: '客户端安装与配置'}, {key: 'client-usage', label: '客户端使用指南'}, ], }, { title: '操作指南', items: [ {key: 'faq', label: '常见问题', desc: '常见问题与解答'}, {key: 'troubleshoot', label: '故障排查', desc: '排查与解决常见故障'}, ], }, ] type Props = { collapsed?: boolean selected?: string onSelect?: (key: string) => void onToggle?: () => void } export default function Sidebar({collapsed = false, selected, onSelect, onToggle}: Props) { const [expanded, setExpanded] = React.useState>(() => { const s: Record = {} MENU.forEach((section, idx) => (s[section.title] = idx === 0)) return s }) const toggleSection = (title: string) => { setExpanded(prev => ({...prev, [title]: !prev[title]})) } return ( ) }