import { IAction } from '@/types'; import { Button, ConfigProvider } from 'antd'; import { Link } from 'dumi'; import { type FC } from 'react'; import { Center, Flexbox } from 'react-layout-kit'; import HeroButton from './HeroButton'; import { useStyles } from './style'; /** * @title 头图组件属性 */ export interface HeroProps { /** * @title 标题 * @description 头图组件的标题,可选 */ title?: string; /** * @title 描述 * @description 描述,可选 */ description?: string; /** * @title 操作 * @description 操作按钮,可选 * @typedef {Object} Action * @property {string} text - 操作按钮的文本 * @property {string} link - 操作按钮跳转的链接 * @property {boolean} openExternal - 是否打开外部链接 * @type {Action[]} */ actions?: IAction[]; } const Hero: FC = ({ title, description, actions }) => { const { styles, cx } = useStyles(); return (
{title && (

)} {description && (

)} {Boolean(actions?.length) && ( {actions!.map(({ text, link, openExternal }, index) => { const isOutLink = /^(https?:)?\/\//i.test(link); const dom = index === 0 ? ( {text} ) : ( ); return isOutLink ? ( {dom} ) : ( {dom} ); })} )}

); }; export default Hero;