You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.tsx 2.4 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import clock from '@/assets/img/clock.png';
  2. import creatByImg from '@/assets/img/creatBy.png';
  3. import KFIcon from '@/components/KFIcon';
  4. import { formatDate } from '@/utils/date';
  5. import { Button, Flex, Typography } from 'antd';
  6. import { ResourceData } from '../../config';
  7. import styles from './index.less';
  8. type ResourceItemProps = {
  9. item: ResourceData;
  10. isPublic: boolean;
  11. onRemove: (item: ResourceData) => void;
  12. onClick: (item: ResourceData) => void;
  13. };
  14. function ResourceItem({ item, isPublic, onClick, onRemove }: ResourceItemProps) {
  15. const timeAgo = `最近更新:${formatDate(item.full_last_update_time, 'YYYY-MM-DD HH:mm')}`;
  16. const create_by = item.create_by ?? '';
  17. return (
  18. <div className={styles['resource-item']} onClick={() => onClick(item)}>
  19. <Flex justify="space-between" align="center" style={{ marginBottom: '20px', height: '32px' }}>
  20. <Typography.Paragraph
  21. className={styles['resource-item__name']}
  22. ellipsis={{ tooltip: item.name }}
  23. >
  24. {item.name}
  25. </Typography.Paragraph>
  26. {!isPublic && (
  27. <Button
  28. type="text"
  29. shape="circle"
  30. onClick={(e) => {
  31. e.stopPropagation();
  32. onRemove(item);
  33. }}
  34. >
  35. <KFIcon type="icon-shanchu" font={17} />
  36. </Button>
  37. )}
  38. </Flex>
  39. <div className={styles['resource-item__description']}>{item.description}</div>
  40. <Flex justify="space-between" gap={'0 8px'}>
  41. <div className={styles['resource-item__time']}>
  42. <img
  43. style={{ width: '17px', marginRight: '6px' }}
  44. src={creatByImg}
  45. draggable={false}
  46. alt=""
  47. />
  48. <Typography.Text ellipsis={{ tooltip: create_by }}>{create_by}</Typography.Text>
  49. </div>
  50. <div className={styles['resource-item__time']}>
  51. <img style={{ width: '12px', marginRight: '5px' }} src={clock} draggable={false} alt="" />
  52. <Typography.Text ellipsis={{ tooltip: timeAgo }}>{timeAgo}</Typography.Text>
  53. <div className={styles['resource-item__time__separator']}></div>
  54. <KFIcon type="icon-dianzan" font={16} />
  55. <div className={styles['resource-item__time__praise']}>{item.praises_count}</div>
  56. </div>
  57. </Flex>
  58. </div>
  59. );
  60. }
  61. export default ResourceItem;