import { css } from '@emotion/react'; import { Button, Space, Typography } from 'antd'; import { Link, useSearchParams } from 'dumi'; import React, { useContext, type FC } from 'react'; import useAdditionalThemeConfig from '../../hooks/useAdditionalThemeConfig'; import useLocaleValue from '../../hooks/useLocaleValue'; import useSiteToken from '../../hooks/useSiteToken'; import SiteContext from '../../slots/SiteContext'; import type { SiteContextProps } from '../../slots/SiteContext'; import { IAction, IBannerConfig } from '../../types'; import { isExternalLinks } from '../../utils'; import Features from './components/Features'; import { GroupMask } from './components/Group'; const bannerConfigDefault: IBannerConfig = { showBanner: true, bannerMobileImgUrl: 'https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*JmlaR5oQn3MAAAAAAAAAAAAADrJ8AQ/original', bannerImgUrl: '' }; const useStyle = () => { const { token } = useSiteToken(); const { isMobile } = useContext(SiteContext); return { mainContent: css` position: relative; text-align: center; flex: 1; `, bannerDisplay: css` display: block; `, bannerDisplayNone: css` display: none; `, titleBase: css` h1& { font-family: AliPuHui, ${token.fontFamily}; } `, title: isMobile ? css` h1& { margin-bottom: ${token.margin}px; font-weight: normal; font-size: ${token.fontSizeHeading1 + 2}px; line-height: ${token.lineHeightHeading2}; } ` : css` h1& { margin-bottom: ${token.marginMD}px; font-weight: 900; font-size: 68px; } ` }; }; const HomeBaseLayout: FC = () => { const style = useStyle(); const { token } = useSiteToken(); const { isMobile, theme } = useContext(SiteContext); const { bannerConfig, name } = useAdditionalThemeConfig(); const actions: IAction[] = useLocaleValue('actions'); const title = useLocaleValue('title'); const description = useLocaleValue('description'); const [searchParams] = useSearchParams(); // 如果配置了 bannerImgUrl 字段,展示配置图片,否则展示 ant-design 默认 banner 视频 const { showBanner, bannerImgUrl, bannerMobileImgUrl } = Object.assign( bannerConfigDefault, bannerConfig ); const bannerContent = bannerImgUrl ? ( ) : (
); return (
{isMobile ? ( -1 ? '0.8' : 1}` }} alt="" /> ) : (
-1 ? '0.8' : 1}` }} > {bannerContent}
)} {/* Image Left Top */}
{/* Image Left Top */} bg {/* Image Right Top */} bg {title || name}
{description}
{actions?.map(({ link, text, type }) => { return isExternalLinks(link) ? ( ) : ( ); })}
); }; export default HomeBaseLayout;