index.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import React, { useMemo } from 'react';
  2. import { Table, Avatar } from '@douyinfe/semi-ui';
  3. import { IconMore } from '@douyinfe/semi-icons';
  4. export default function App() {
  5. const columns = [
  6. {
  7. title: '标题',
  8. dataIndex: 'name',
  9. width: 400,
  10. render: (text, record, index) => {
  11. return (
  12. <div>
  13. <Avatar
  14. size="small"
  15. shape="square"
  16. src={record.nameIconSrc}
  17. style={{ marginRight: 12 }}
  18. ></Avatar>
  19. {text}
  20. </div>
  21. );
  22. },
  23. },
  24. {
  25. title: '大小',
  26. dataIndex: 'size',
  27. },
  28. {
  29. title: '所有者',
  30. dataIndex: 'owner',
  31. render: (text, record, index) => {
  32. return (
  33. <div>
  34. <Avatar size="small" color={record.avatarBg} style={{ marginRight: 4 }}>
  35. {typeof text === 'string' && text.slice(0, 1)}
  36. </Avatar>
  37. {text}
  38. </div>
  39. );
  40. },
  41. },
  42. {
  43. title: '更新日期',
  44. dataIndex: 'updateTime',
  45. },
  46. {
  47. title: '',
  48. dataIndex: 'operate',
  49. render: () => {
  50. return <IconMore />;
  51. },
  52. },
  53. ];
  54. const pagination = useMemo(
  55. () => ({
  56. pageSize: 3,
  57. }),
  58. []
  59. );
  60. return <Table columns={columns} dataSource={[]} rowSelection pagination={pagination} />;
  61. }