Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 088b042

Browse files
committed
refactor: improve render contents
1 parent bc8cf42 commit 088b042

File tree

13 files changed

+59
-171
lines changed

13 files changed

+59
-171
lines changed

components/UserCell/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const UserCell = ({ user, align, left, small }) => (
1818
<div>
1919
<UserCellWrapper align={align} left={left}>
2020
<Avatar src={user.avatar} alt={user.nickname} small={small} />
21-
<NickName>{cutFrom(user.nickname, 15)}</NickName>
21+
<NickName>{cutFrom(user.nickname, 10)}</NickName>
2222
</UserCellWrapper>
2323
</div>
2424
)

containers/CommunitiesContent/JobsContent.js

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
2-
import TimeAgo from 'timeago-react'
32

43
import { cutFrom } from '../../utils'
4+
55
import {
66
Pagi,
77
Table,
@@ -11,6 +11,7 @@ import {
1111
UserCell,
1212
CommunityCell,
1313
TagsCell,
14+
TimeStampCell,
1415
} from '../../components'
1516

1617
import { OperationWrapper } from './styles'
@@ -82,49 +83,25 @@ const columns = [
8283
dataIndex: 'views',
8384
align: 'center',
8485
},
85-
/*
86-
{
87-
title: '收藏',
88-
width: 100,
89-
dataIndex: 'favoritedCount',
90-
align: 'center',
91-
},
92-
{
93-
title: '点赞',
94-
width: 100,
95-
dataIndex: 'starredCount',
96-
align: 'center',
97-
},
9886
{
9987
title: '评论数',
10088
width: 100,
10189
dataIndex: 'commentsCount',
10290
align: 'center',
10391
},
92+
/*
93+
{
94+
title: '收藏',
95+
width: 100,
96+
dataIndex: 'favoritedCount',
97+
align: 'center',
98+
},
99+
*/
104100
{
105-
title: '评论参与',
106-
width: 150,
107-
dataIndex: 'commentsParticipatorsCount',
108-
align: 'center',
109-
},
110-
*/
111-
{
112-
title: '创建时间',
113-
width: 150,
114-
dataIndex: 'insertedAt',
115-
align: 'center',
116-
render: text => {
117-
return <TimeAgo datetime={text} locale="zh_CN" />
118-
},
119-
},
120-
{
121-
title: '上次更新',
122-
width: 150,
123-
dataIndex: 'updatedAt',
101+
title: '时间戳',
102+
width: 120,
124103
align: 'center',
125-
render: text => {
126-
return <TimeAgo datetime={text} locale="zh_CN" />
127-
},
104+
render: (text, record) => <TimeStampCell data={record} />,
128105
},
129106
{
130107
title: '操作',

containers/CommunitiesContent/PostsContent.js

Lines changed: 15 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import React from 'react'
2-
import TimeAgo from 'timeago-react'
32

4-
import { cutFrom } from '../../utils'
53
import {
64
Pagi,
75
Table,
@@ -11,6 +9,7 @@ import {
119
UserCell,
1210
CommunityCell,
1311
TagsCell,
12+
TimeStampCell,
1413
} from '../../components'
1514

1615
import { OperationWrapper } from './styles'
@@ -27,21 +26,21 @@ const columns = [
2726
},
2827
{
2928
title: '标题',
30-
width: 300,
29+
width: 250,
3130
dataIndex: 'title',
32-
align: 'center',
31+
align: 'left',
3332
fixed: 'left',
3433
render: text => {
35-
return <div>{cutFrom(text, 15)}</div>
34+
return <div>{text}</div>
3635
},
3736
},
3837
{
3938
title: '摘要',
40-
width: 400,
39+
width: 300,
4140
dataIndex: 'digest',
4241
align: 'center',
4342
render: text => {
44-
return <div>{cutFrom(text, 10)}</div>
43+
return <div>{text}</div>
4544
},
4645
},
4746
{
@@ -91,47 +90,29 @@ const columns = [
9190
dataIndex: 'views',
9291
align: 'center',
9392
},
94-
{
95-
title: '收藏',
96-
width: 100,
97-
dataIndex: 'favoritedCount',
98-
align: 'center',
99-
},
100-
{
101-
title: '点赞',
102-
width: 100,
103-
dataIndex: 'starredCount',
104-
align: 'center',
105-
},
10693
{
10794
title: '评论数',
10895
width: 100,
10996
dataIndex: 'commentsCount',
11097
align: 'center',
11198
},
11299
{
113-
title: '评论参与',
114-
width: 150,
115-
dataIndex: 'commentsParticipatorsCount',
100+
title: '收藏',
101+
width: 100,
102+
dataIndex: 'favoritedCount',
116103
align: 'center',
117104
},
118105
{
119-
title: '创建时间',
120-
width: 150,
121-
dataIndex: 'insertedAt',
106+
title: '点赞',
107+
width: 100,
108+
dataIndex: 'starredCount',
122109
align: 'center',
123-
render: text => {
124-
return <TimeAgo datetime={text} locale="zh_CN" />
125-
},
126110
},
127111
{
128-
title: '上次更新',
129-
width: 150,
130-
dataIndex: 'updatedAt',
112+
title: '时间戳',
113+
width: 120,
131114
align: 'center',
132-
render: text => {
133-
return <TimeAgo datetime={text} locale="zh_CN" />
134-
},
115+
render: (text, record) => <TimeStampCell data={record} />,
135116
},
136117
{
137118
title: '操作',

containers/CommunitiesContent/ReposContent.js

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import TimeAgo from 'timeago-react'
32

43
import {
54
Pagi,
@@ -10,6 +9,7 @@ import {
109
UserCell,
1110
CommunityCell,
1211
TagsCell,
12+
TimeStampCell,
1313
} from '../../components'
1414

1515
import { OperationWrapper } from './styles'
@@ -90,28 +90,10 @@ const columns = [
9090
align: 'center',
9191
},
9292
{
93-
title: '评论参与',
94-
width: 150,
95-
dataIndex: 'commentsParticipatorsCount',
96-
align: 'center',
97-
},
98-
{
99-
title: '创建时间',
100-
width: 150,
101-
dataIndex: 'insertedAt',
93+
title: '时间戳',
94+
width: 120,
10295
align: 'center',
103-
render: text => {
104-
return <TimeAgo datetime={text} locale="zh_CN" />
105-
},
106-
},
107-
{
108-
title: '上次更新',
109-
width: 150,
110-
dataIndex: 'updatedAt',
111-
align: 'center',
112-
render: text => {
113-
return <TimeAgo datetime={text} locale="zh_CN" />
114-
},
96+
render: (text, record) => <TimeStampCell data={record} />,
11597
},
11698
{
11799
title: '操作',

containers/CommunitiesContent/TagsContent.js

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import TimeAgo from 'timeago-react'
32

43
import { cutFrom } from '../../utils'
54
import {
@@ -10,6 +9,7 @@ import {
109
Space,
1110
ColorCell,
1211
CommunityCell,
12+
TimeStampCell,
1313
} from '../../components'
1414

1515
import { OperationWrapper } from './styles'
@@ -70,22 +70,10 @@ const columns = [
7070
},
7171
},
7272
{
73-
title: '创建时间',
74-
width: 150,
75-
dataIndex: 'insertedAt',
73+
title: '时间戳',
74+
width: 120,
7675
align: 'center',
77-
render: text => {
78-
return <TimeAgo datetime={text} locale="zh_CN" />
79-
},
80-
},
81-
{
82-
title: '上次更新',
83-
width: 150,
84-
dataIndex: 'updatedAt',
85-
align: 'center',
86-
render: text => {
87-
return <TimeAgo datetime={text} locale="zh_CN" />
88-
},
76+
render: (text, record) => <TimeStampCell data={record} />,
8977
},
9078
{
9179
title: '操作',

containers/CommunitiesContent/ThreadsContent.js

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
import React from 'react'
2-
/* import TimeAgo from 'timeago-react' */
32

43
import { cutFrom } from '../../utils'
5-
import {
6-
Pagi,
7-
Table,
8-
TableLoading,
9-
/* Button, */
10-
/* Space, */
11-
/* UserCell, */
12-
/* CommunityCell, */
13-
/* TagsCell, */
14-
} from '../../components'
4+
import { Pagi, Table, TableLoading } from '../../components'
155

166
/* import { OperationWrapper } from './styles' */
177
import * as logic from './logic'
@@ -38,24 +28,6 @@ const columns = [
3828
align: 'center',
3929
},
4030
/*
41-
{
42-
title: '创建时间',
43-
width: 150,
44-
dataIndex: 'insertedAt',
45-
align: 'center',
46-
render: text => {
47-
return <TimeAgo datetime={text} locale="zh_CN" />
48-
},
49-
},
50-
{
51-
title: '上次更新',
52-
width: 150,
53-
dataIndex: 'updatedAt',
54-
align: 'center',
55-
render: text => {
56-
return <TimeAgo datetime={text} locale="zh_CN" />
57-
},
58-
},
5931
{
6032
title: '操作',
6133
width: 200,

containers/CommunitiesContent/VideosContent.js

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import React from 'react'
2-
import TimeAgo from 'timeago-react'
32

43
import { cutFrom } from '../../utils'
54
import {
@@ -11,6 +10,7 @@ import {
1110
UserCell,
1211
CommunityCell,
1312
TagsCell,
13+
TimeStampCell,
1414
} from '../../components'
1515

1616
import { OperationWrapper } from './styles'
@@ -82,6 +82,12 @@ const columns = [
8282
dataIndex: 'views',
8383
align: 'center',
8484
},
85+
{
86+
title: '评论',
87+
width: 100,
88+
dataIndex: 'commentsCount',
89+
align: 'center',
90+
},
8591
/*
8692
{
8793
title: '收藏',
@@ -95,36 +101,12 @@ const columns = [
95101
dataIndex: 'starredCount',
96102
align: 'center',
97103
},
98-
{
99-
title: '评论数',
100-
width: 100,
101-
dataIndex: 'commentsCount',
102-
align: 'center',
103-
},
104-
{
105-
title: '评论参与',
106-
width: 150,
107-
dataIndex: 'commentsParticipatorsCount',
108-
align: 'center',
109-
},
110104
*/
111105
{
112-
title: '创建时间',
113-
width: 150,
114-
dataIndex: 'insertedAt',
115-
align: 'center',
116-
render: text => {
117-
return <TimeAgo datetime={text} locale="zh_CN" />
118-
},
119-
},
120-
{
121-
title: '上次更新',
122-
width: 150,
123-
dataIndex: 'updatedAt',
106+
title: '时间戳',
107+
width: 120,
124108
align: 'center',
125-
render: text => {
126-
return <TimeAgo datetime={text} locale="zh_CN" />
127-
},
109+
render: (text, record) => <TimeStampCell data={record} />,
128110
},
129111
{
130112
title: '操作',

0 commit comments

Comments
 (0)