import { useState, useEffect } from 'react' import { Drawer, Collapse, Badge, Tag, Empty } from 'antd' import { QuestionCircleOutlined, BulbOutlined, WarningOutlined, InfoCircleOutlined, ThunderboltOutlined, } from '@ant-design/icons' import './ActionHelpPanel.css' const { Panel } = Collapse /** * 操作帮助面板组件 * 在页面侧边显示当前操作的详细说明和帮助信息 * @param {Object} props * @param {boolean} props.visible - 是否显示面板 * @param {Function} props.onClose - 关闭回调 * @param {Object} props.currentAction - 当前操作信息 * @param {Array} props.allActions - 所有可用操作列表 * @param {string} props.placement - 面板位置 * @param {Function} props.onActionSelect - 选择操作的回调 */ function ActionHelpPanel({ visible = false, onClose, currentAction = null, allActions = [], placement = 'right', onActionSelect, }) { const [activeKey, setActiveKey] = useState(['current']) // 当 currentAction 变化时,自动展开"当前操作"面板 useEffect(() => { if (currentAction && visible) { setActiveKey(['current']) } }, [currentAction, visible]) // 渲染当前操作详情 const renderCurrentAction = () => { if (!currentAction) { return ( ) } return (
{/* 操作标题 */}
{currentAction.icon}

{currentAction.title}

{currentAction.badge && ( {currentAction.badge.text} )}
{/* 操作描述 */} {currentAction.description && (
功能说明
{currentAction.description}
)} {/* 使用场景 */} {currentAction.scenarios && currentAction.scenarios.length > 0 && (
使用场景
    {currentAction.scenarios.map((scenario, index) => (
  • {scenario}
  • ))}
)} {/* 操作步骤 */} {currentAction.steps && currentAction.steps.length > 0 && (
操作步骤
    {currentAction.steps.map((step, index) => (
  1. {step}
  2. ))}
)} {/* 注意事项 */} {currentAction.warnings && currentAction.warnings.length > 0 && (
注意事项
    {currentAction.warnings.map((warning, index) => (
  • {warning}
  • ))}
)} {/* 快捷键 */} {currentAction.shortcut && (
⌨️ 快捷键
{currentAction.shortcut}
)} {/* 权限要求 */} {currentAction.permission && (
🔐 权限要求
{currentAction.permission}
)}
) } // 渲染所有操作列表 const renderAllActions = () => { if (allActions.length === 0) { return } return (
{allActions.map((action, index) => (
{ if (onActionSelect) { onActionSelect(action) setActiveKey(['current']) } }} >
{action.icon} {action.title} {action.shortcut && ( {action.shortcut} )}
{action.description}
))}
) } return ( 操作帮助 {currentAction && } } placement={placement} width={420} open={visible} onClose={onClose} className="action-help-panel" > 当前操作 {currentAction && ( )} } key="current" > {renderCurrentAction()} {renderAllActions()} ) } export default ActionHelpPanel