default.jsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import React from 'react';
  2. import { Table, Avatar } from '@douyinfe/semi-ui';
  3. import { IconMore } from '@douyinfe/semi-icons';
  4. function App() {
  5. const columns = [
  6. {
  7. title: '标题',
  8. dataIndex: 'name',
  9. render: (text, record, index) => {
  10. return (
  11. <div>
  12. <Avatar size="small" shape="square" src={record.nameIconSrc} style={{ marginRight: 12 }}></Avatar>
  13. {text}
  14. </div>
  15. );
  16. }
  17. },
  18. {
  19. title: '大小',
  20. dataIndex: 'size',
  21. },
  22. {
  23. title: '所有者',
  24. dataIndex: 'owner',
  25. render: (text, record, index) => {
  26. return (
  27. <div>
  28. <Avatar size="small" color={record.avatarBg} style={{ marginRight: 4 }}>{typeof text === 'string' && text.slice(0, 1)}</Avatar>
  29. {text}
  30. </div>
  31. );
  32. }
  33. },
  34. {
  35. title: '更新日期',
  36. dataIndex: 'updateTime',
  37. },
  38. {
  39. title: '',
  40. dataIndex: 'operate',
  41. render: () => {
  42. return <IconMore />;
  43. }
  44. },
  45. ];
  46. const data = [
  47. {
  48. key: '1',
  49. name: 'Semi Design 设计稿.fig',
  50. nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/figma-icon.png',
  51. size: '2M',
  52. owner: '姜鹏志',
  53. updateTime: '2020-02-02 05:13',
  54. avatarBg: 'grey'
  55. },
  56. {
  57. key: '2',
  58. name: 'Semi Design 分享演示文稿',
  59. nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/docs-icon.png',
  60. size: '2M',
  61. owner: '郝宣',
  62. updateTime: '2020-01-17 05:31',
  63. avatarBg: 'red'
  64. },
  65. {
  66. key: '3',
  67. name: '设计文档',
  68. nameIconSrc: 'https://lf3-static.bytednsdoc.com/obj/eden-cn/ptlz_zlp/ljhwZthlaukjlkulzlp/docs-icon.png',
  69. size: '34KB',
  70. owner: 'Zoey Edwards',
  71. updateTime: '2020-01-26 11:01',
  72. avatarBg: 'light-blue'
  73. },
  74. ];
  75. return <Table columns={columns} dataSource={data} pagination={false} />;
  76. }
  77. render(App);