import { useState } from 'react' import { UpOutlined, DownOutlined } from '@ant-design/icons' import './SideInfoPanel.css' /** * 侧边信息面板组件 * @param {Object} props * @param {Array} props.sections - 信息区块配置数组 * @param {string} props.className - 自定义类名 */ function SideInfoPanel({ sections = [], className = '' }) { const [collapsedSections, setCollapsedSections] = useState(() => { const initial = {} sections.forEach((section) => { if (section.defaultCollapsed) { initial[section.key] = true } }) return initial }) const toggleSection = (key) => { setCollapsedSections((prev) => ({ ...prev, [key]: !prev[key], })) } return (
{sections.map((section) => { const isCollapsed = collapsedSections[section.key] return (
{/* 区块头部 */}
toggleSection(section.key)}>
{section.icon && {section.icon}} {section.title}
{/* 区块内容 */} {!isCollapsed && (
{section.content}
)}
) })}
) } export default SideInfoPanel