Articles.js 1.49 KB
Newer Older
愚道's avatar
愚道 committed
1
import React, { PureComponent } from 'react';
2
import { List, Icon, Tag } from 'antd';
愚道's avatar
愚道 committed
3
import { connect } from 'dva';
4
import ArticleListContent from '@/components/ArticleListContent';
ddcat1115's avatar
ddcat1115 committed
5 6
import styles from './Articles.less';

愚道's avatar
愚道 committed
7 8 9
@connect(({ list }) => ({
  list,
}))
afc163's avatar
afc163 committed
10
class Center extends PureComponent {
愚道's avatar
愚道 committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
  render() {
    const {
      list: { list },
    } = this.props;
    const IconText = ({ type, text }) => (
      <span>
        <Icon type={type} style={{ marginRight: 8 }} />
        {text}
      </span>
    );
    return (
      <List
        size="large"
        className={styles.articleList}
        rowKey="id"
        itemLayout="vertical"
        dataSource={list}
        renderItem={item => (
          <List.Item
            key={item.id}
            actions={[
              <IconText type="star-o" text={item.star} />,
              <IconText type="like-o" text={item.like} />,
              <IconText type="message" text={item.message} />,
            ]}
          >
            <List.Item.Meta
              title={
39
                <a className={styles.listItemMetaTitle} href={item.href}>
愚道's avatar
愚道 committed
40 41 42 43 44 45 46 47 48 49 50
                  {item.title}
                </a>
              }
              description={
                <span>
                  <Tag>Ant Design</Tag>
                  <Tag>设计语言</Tag>
                  <Tag>蚂蚁金服</Tag>
                </span>
              }
            />
51
            <ArticleListContent data={item} />
愚道's avatar
愚道 committed
52 53 54 55 56 57
          </List.Item>
        )}
      />
    );
  }
}
lijiehua's avatar
lijiehua committed
58 59

export default Center;