import { Avatar, List } from 'antd'; import classNames from 'classnames'; import React from 'react'; import styles from './NoticeList.less'; export type NoticeIconTabProps = { count?: number; showClear?: boolean; showViewMore?: boolean; style?: React.CSSProperties; title: string; tabKey: API.NoticeIconItemType; onClick?: (item: API.NoticeIconItem) => void; onClear?: () => void; emptyText?: string; clearText?: string; viewMoreText?: string; list: API.NoticeIconItem[]; onViewMore?: (e: any) => void; }; const NoticeList: React.FC = ({ list = [], onClick, onClear, title, onViewMore, emptyText, showClear = true, clearText, viewMoreText, showViewMore = false, }) => { if (!list || list.length === 0) { return (
not found
{emptyText}
); } return (
className={styles.list} dataSource={list} renderItem={(item, i) => { const itemCls = classNames(styles.item, { [styles.read]: item.read, }); // eslint-disable-next-line no-nested-ternary const leftIcon = item.avatar ? ( typeof item.avatar === 'string' ? ( ) : ( {item.avatar} ) ) : null; return (
{ onClick?.(item); }} > {item.title}
{item.extra}
} description={
{item.description}
{item.datetime}
} />
); }} />
{showClear ? (
{clearText} {title}
) : null} {showViewMore ? (
{ if (onViewMore) { onViewMore(e); } }} > {viewMoreText}
) : null}
); }; export default NoticeList;