mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
775d1800bb
* chore(deps-dev): bump eslint-config-prettier from 6.15.0 to 7.0.0 Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 6.15.0 to 7.0.0. - [Release notes](https://github.com/prettier/eslint-config-prettier/releases) - [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/eslint-config-prettier/compare/v6.15.0...v7.0.0) Signed-off-by: dependabot[bot] <support@github.com> * chore: fix eslint style * chore: prettier code style Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: afc163 <afc163@gmail.com>
83 lines
2.0 KiB
TypeScript
83 lines
2.0 KiB
TypeScript
import * as React from 'react';
|
|
import classNames from 'classnames';
|
|
import { FormattedMessage, useIntl } from 'react-intl';
|
|
import { Row, Col, Typography } from 'antd';
|
|
import { useSiteData } from './util';
|
|
import './RecommendPage.less';
|
|
|
|
const { Title, Paragraph } = Typography;
|
|
|
|
interface Recommend {
|
|
title?: string;
|
|
img?: string;
|
|
href?: string;
|
|
popularize?: boolean;
|
|
description?: string;
|
|
loading?: boolean;
|
|
}
|
|
|
|
interface RecommendBlockProps extends Recommend {
|
|
main?: boolean;
|
|
}
|
|
|
|
const RecommendBlock = ({
|
|
main,
|
|
title,
|
|
popularize,
|
|
description,
|
|
img,
|
|
href,
|
|
loading,
|
|
}: RecommendBlockProps) => (
|
|
<a
|
|
className={classNames('recommend-block', {
|
|
'recommend-block-main': !!main,
|
|
'recommend-block-loading': loading,
|
|
})}
|
|
href={href}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
onClick={() => {
|
|
window?.gtag('event', '点击', {
|
|
event_category: '首页推广',
|
|
event_label: href,
|
|
});
|
|
}}
|
|
>
|
|
<img src={img} alt={title} />
|
|
{popularize && (
|
|
<span className="recommend-popularize">
|
|
<FormattedMessage id="app.home.popularize" />
|
|
</span>
|
|
)}
|
|
<div className="recommend-content">
|
|
<Title level={4}>{title}</Title>
|
|
<Paragraph style={{ fontSize: 13 }}>{description}</Paragraph>
|
|
</div>
|
|
</a>
|
|
);
|
|
|
|
export default function RecommendPage() {
|
|
const { locale } = useIntl();
|
|
const isZhCN = locale === 'zh-CN';
|
|
const list = useSiteData<Recommend[]>('recommendations', isZhCN ? 'cn' : 'en');
|
|
const isLoading = !list;
|
|
return (
|
|
<Row gutter={[24, 24]} style={{ marginBottom: -36 }}>
|
|
<Col xs={24} sm={14}>
|
|
<RecommendBlock {...(list ? list[0] : {})} main loading={isLoading} />
|
|
</Col>
|
|
<Col xs={24} sm={10}>
|
|
<Row gutter={[24, 24]}>
|
|
<Col span={24}>
|
|
<RecommendBlock {...(list ? list[1] : {})} loading={isLoading} />
|
|
</Col>
|
|
<Col span={24}>
|
|
<RecommendBlock {...(list ? list[2] : {})} loading={isLoading} />
|
|
</Col>
|
|
</Row>
|
|
</Col>
|
|
</Row>
|
|
);
|
|
}
|