动态菜单和动态路由的 antd pro

CardList.js 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import React, { PureComponent } from 'react';
  2. import { connect } from 'dva';
  3. import { Card, Button, Icon, List } from 'antd';
  4. import Ellipsis from 'components/Ellipsis';
  5. import PageHeaderLayout from '../../layouts/PageHeaderLayout';
  6. import styles from './CardList.less';
  7. @connect(({ list, loading }) => ({
  8. list,
  9. loading: loading.models.list,
  10. }))
  11. export default class CardList extends PureComponent {
  12. componentDidMount() {
  13. this.props.dispatch({
  14. type: 'list/fetch',
  15. payload: {
  16. count: 8,
  17. },
  18. });
  19. }
  20. render() {
  21. const { list: { list }, loading } = this.props;
  22. const content = (
  23. <div className={styles.pageHeaderContent}>
  24. <p>
  25. 段落示意:蚂蚁金服务设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,
  26. 提供跨越设计与开发的体验解决方案。
  27. </p>
  28. <div className={styles.contentLink}>
  29. <a>
  30. <img alt="" src="https://gw.alipayobjects.com/zos/rmsportal/MjEImQtenlyueSmVEfUD.svg" />{' '}
  31. 快速开始
  32. </a>
  33. <a>
  34. <img alt="" src="https://gw.alipayobjects.com/zos/rmsportal/NbuDUAuBlIApFuDvWiND.svg" />{' '}
  35. 产品简介
  36. </a>
  37. <a>
  38. <img alt="" src="https://gw.alipayobjects.com/zos/rmsportal/ohOEPSYdDTNnyMbGuyLb.svg" />{' '}
  39. 产品文档
  40. </a>
  41. </div>
  42. </div>
  43. );
  44. const extraContent = (
  45. <div className={styles.extraImg}>
  46. <img
  47. alt="这是一个标题"
  48. src="https://gw.alipayobjects.com/zos/rmsportal/RzwpdLnhmvDJToTdfDPe.png"
  49. />
  50. </div>
  51. );
  52. return (
  53. <PageHeaderLayout title="卡片列表" content={content} extraContent={extraContent}>
  54. <div className={styles.cardList}>
  55. <List
  56. rowKey="id"
  57. loading={loading}
  58. grid={{ gutter: 24, lg: 3, md: 2, sm: 1, xs: 1 }}
  59. dataSource={['', ...list]}
  60. renderItem={item =>
  61. item ? (
  62. <List.Item key={item.id}>
  63. <Card hoverable className={styles.card} actions={[<a>操作一</a>, <a>操作二</a>]}>
  64. <Card.Meta
  65. avatar={<img alt="" className={styles.cardAvatar} src={item.avatar} />}
  66. title={<a href="#">{item.title}</a>}
  67. description={
  68. <Ellipsis className={styles.item} lines={3}>
  69. {item.description}
  70. </Ellipsis>
  71. }
  72. />
  73. </Card>
  74. </List.Item>
  75. ) : (
  76. <List.Item>
  77. <Button type="dashed" className={styles.newButton}>
  78. <Icon type="plus" /> 新增产品
  79. </Button>
  80. </List.Item>
  81. )
  82. }
  83. />
  84. </div>
  85. </PageHeaderLayout>
  86. );
  87. }
  88. }