import { useState } from 'react' import { Button, Badge, Modal, Steps, Tag, Divider } from 'antd' import { QuestionCircleOutlined, BulbOutlined, WarningOutlined, CheckCircleOutlined, InfoCircleOutlined, } from '@ant-design/icons' import './ButtonWithGuideBadge.css' /** * 智能引导徽章按钮组件 * 为新功能或复杂按钮添加脉冲动画的徽章,点击后显示详细引导 * @param {Object} props * @param {string} props.label - 按钮文本 * @param {ReactNode} props.icon - 按钮图标 * @param {string} props.type - 按钮类型 * @param {boolean} props.danger - 危险按钮 * @param {boolean} props.disabled - 禁用状态 * @param {Function} props.onClick - 点击回调 * @param {Object} props.guide - 引导配置 * @param {boolean} props.showBadge - 是否显示徽章 * @param {string} props.badgeType - 徽章类型:new, help, warn * @param {string} props.size - 按钮大小 */ function ButtonWithGuideBadge({ label, icon, type = 'default', danger = false, disabled = false, onClick, guide, showBadge = true, badgeType = 'help', size = 'middle', ...restProps }) { const [showGuideModal, setShowGuideModal] = useState(false) const handleBadgeClick = (e) => { e.stopPropagation() if (guide) { setShowGuideModal(true) } } const getBadgeConfig = () => { const configs = { new: { text: 'NEW', color: '#52c41a', icon: , }, help: { text: '?', color: '#1677ff', icon: , }, warn: { text: '!', color: '#faad14', icon: , }, } return configs[badgeType] || configs.help } const badgeConfig = getBadgeConfig() return ( <>
{showBadge && guide && !disabled ? ( {badgeConfig.icon}
} offset={[-5, 5]} > ) : ( )} {/* 引导弹窗 */} {guide && ( {guide.icon || icon} {guide.title} {guide.badge && ( {guide.badge.text} )} } open={showGuideModal} onCancel={() => setShowGuideModal(false)} footer={[ , ]} width={600} className="button-guide-modal" > {/* 功能描述 */} {guide.description && (
功能说明

{guide.description}

)} {/* 使用步骤 */} {guide.steps && guide.steps.length > 0 && (
操作步骤
({ title: `步骤 ${index + 1}`, description: step, status: 'wait', }))} className="guide-steps" />
)} {/* 使用场景 */} {guide.scenarios && guide.scenarios.length > 0 && (
适用场景
    {guide.scenarios.map((scenario, index) => (
  • {scenario}
  • ))}
)} {/* 注意事项 */} {guide.warnings && guide.warnings.length > 0 && (
注意事项
    {guide.warnings.map((warning, index) => (
  • {warning}
  • ))}
)} {/* 快捷键和权限 */} {(guide.shortcut || guide.permission) && (
{guide.shortcut && (
快捷键: {guide.shortcut}
)} {guide.permission && (
权限要求: {guide.permission}
)}
)}
)} ) } export default ButtonWithGuideBadge