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

Commit 4067cd0

Browse files
committed
refactor: shortcuts render for paged table contents
1 parent fe9b79c commit 4067cd0

File tree

4 files changed

+79
-101
lines changed

4 files changed

+79
-101
lines changed

containers/CommunitiesContent/CategoriesContent.js

Lines changed: 25 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ const columns = [
2929
width: 150,
3030
dataIndex: 'title',
3131
align: 'center',
32-
render: text => {
33-
return <div>{Trans(text)}</div>
34-
},
32+
render: text => <div>{Trans(text)}</div>,
3533
},
3634
{
3735
title: 'raw',
@@ -44,55 +42,47 @@ const columns = [
4442
width: 260,
4543
dataIndex: 'communities',
4644
align: 'center',
47-
render: communities => {
48-
return <CommunityCell array={communities} />
49-
},
45+
render: communities => <CommunityCell array={communities} />,
5046
},
5147
{
5248
title: '创建者',
5349
width: 180,
5450
dataIndex: 'author',
5551
align: 'center',
56-
render: author => {
57-
return <UserCell user={author} />
58-
},
52+
render: text => <UserCell user={text} />,
5953
},
6054
{
6155
title: '时间戳',
6256
width: 120,
6357
align: 'center',
64-
render: (text, record) => {
65-
return <TimeStampCell data={record} />
66-
},
58+
render: (text, record) => <TimeStampCell data={record} />,
6759
},
6860
{
6961
title: '操作',
7062
width: 200,
7163
dataIndex: '',
7264
align: 'center',
73-
render: (text, record) => {
74-
return (
75-
<OperationWrapper>
76-
<Button
77-
size="small"
78-
type="primary"
79-
ghost
80-
onClick={logic.onEditCategory.bind(this, record)}
81-
>
82-
编辑
83-
</Button>
84-
<Space right="10px" />
85-
<Button
86-
size="small"
87-
type="red"
88-
ghost
89-
onClick={logic.onDeleteCagegory.bind(this, record)}
90-
>
91-
删除
92-
</Button>
93-
</OperationWrapper>
94-
)
95-
},
65+
render: (text, record) => (
66+
<OperationWrapper>
67+
<Button
68+
size="small"
69+
type="primary"
70+
ghost
71+
onClick={logic.onEditCategory.bind(this, record)}
72+
>
73+
编辑
74+
</Button>
75+
<Space right="10px" />
76+
<Button
77+
size="small"
78+
type="red"
79+
ghost
80+
onClick={logic.onDeleteCagegory.bind(this, record)}
81+
>
82+
删除
83+
</Button>
84+
</OperationWrapper>
85+
),
9686
},
9787
]
9888

containers/CommunitiesContent/IndexContent.js

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

3-
import { cutFrom } from '../../utils'
43
import {
54
Pagi,
65
Table,
@@ -33,28 +32,19 @@ const columns = [
3332
align: 'center',
3433
fixed: 'left',
3534
width: 80,
36-
render: text => {
37-
// TODO: jadge image type before render, currently only svg supported
38-
return <CommunityIcon src={text} />
39-
},
35+
render: text => <CommunityIcon src={text} />,
4036
},
4137
{
4238
title: '名称',
4339
width: 200,
4440
dataIndex: 'title',
4541
align: 'center',
46-
render: text => {
47-
return <div>{cutFrom(text, 15)}</div>
48-
},
4942
},
5043
{
5144
title: '描述',
5245
width: 300,
5346
dataIndex: 'desc',
54-
align: 'center',
55-
render: text => {
56-
return <div>{cutFrom(text, 10)}</div>
57-
},
47+
align: 'left',
5848
},
5949
{
6050
title: 'threads',
@@ -75,9 +65,6 @@ const columns = [
7565
width: 150,
7666
dataIndex: 'raw',
7767
align: 'center',
78-
render: text => {
79-
return <div>{cutFrom(text, 10)}</div>
80-
},
8168
},
8269
{
8370
title: '类别',
@@ -111,17 +98,13 @@ const columns = [
11198
width: 100,
11299
dataIndex: 'postsCount',
113100
align: 'center',
114-
render: (text, record) => {
115-
return <ContentsCountCell data={record} />
116-
},
101+
render: (text, record) => <ContentsCountCell data={record} />,
117102
},
118103
{
119104
title: '时间戳',
120105
width: 120,
121106
align: 'center',
122-
render: (text, record) => {
123-
return <TimeStampCell data={record} />
124-
},
107+
render: (text, record) => <TimeStampCell data={record} />,
125108
},
126109
{
127110
title: '操作',

containers/CommunitiesContent/TagsContent.js

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react'
22

3-
import { cutFrom } from '../../utils'
43
import {
54
Pagi,
65
Table,
@@ -13,6 +12,8 @@ import {
1312
} from '../../components'
1413

1514
import { OperationWrapper } from './styles'
15+
16+
import { Trans } from '../../utils'
1617
import * as logic from './logic'
1718

1819
/* eslint-disable react/display-name */
@@ -26,48 +27,50 @@ const columns = [
2627
},
2728
{
2829
title: '标题',
29-
width: 200,
30+
width: 120,
3031
dataIndex: 'title',
31-
align: 'center',
32-
render: text => {
33-
return <div>{cutFrom(text, 15)}</div>
34-
},
32+
align: 'left',
33+
render: text => (
34+
<div>
35+
{Trans(text)}({text})
36+
</div>
37+
),
3538
},
3639
{
3740
title: '颜色',
38-
width: 80,
41+
width: 60,
3942
dataIndex: 'color',
4043
align: 'center',
41-
render: text => {
42-
return <ColorCell color={text} />
43-
},
44+
render: text => <ColorCell color={text} />,
4445
},
4546
{
4647
title: '社区',
4748
width: 200,
4849
dataIndex: 'community',
4950
align: 'center',
50-
render: community => {
51-
return <CommunityCell data={community} />
52-
},
51+
render: community => <CommunityCell data={community} />,
5352
},
5453
{
5554
title: '版块',
5655
width: 200,
5756
dataIndex: 'thread',
5857
align: 'center',
59-
render: text => {
60-
return <div>{text}</div>
61-
},
58+
render: text => (
59+
<div>
60+
{Trans(text)}({text})
61+
</div>
62+
),
6263
},
6364
{
64-
title: 'topic',
65+
title: '子话题',
6566
width: 150,
6667
dataIndex: 'topic',
6768
align: 'center',
68-
render: text => {
69-
return <div>{text.title}</div>
70-
},
69+
render: text => (
70+
<div>
71+
{Trans(text.title)}({text.title})
72+
</div>
73+
),
7174
},
7275
{
7376
title: '时间戳',
@@ -80,29 +83,27 @@ const columns = [
8083
width: 200,
8184
dataIndex: '',
8285
align: 'center',
83-
render: (text, record) => {
84-
return (
85-
<OperationWrapper>
86-
<Button
87-
size="small"
88-
type="primary"
89-
ghost
90-
onClick={logic.onEditTag.bind(this, record)}
91-
>
92-
编辑
93-
</Button>
94-
<Space right="10px" />
95-
<Button
96-
size="small"
97-
type="red"
98-
ghost
99-
onClick={logic.onDeleteTag.bind(this, record)}
100-
>
101-
删除
102-
</Button>
103-
</OperationWrapper>
104-
)
105-
},
86+
render: (text, record) => (
87+
<OperationWrapper>
88+
<Button
89+
size="small"
90+
type="primary"
91+
ghost
92+
onClick={logic.onEditTag.bind(this, record)}
93+
>
94+
编辑
95+
</Button>
96+
<Space right="10px" />
97+
<Button
98+
size="small"
99+
type="red"
100+
ghost
101+
onClick={logic.onDeleteTag.bind(this, record)}
102+
>
103+
删除
104+
</Button>
105+
</OperationWrapper>
106+
),
106107
},
107108
]
108109

containers/CommunitiesContent/ThreadsContent.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react'
22

3-
import { cutFrom } from '../../utils'
43
import { Pagi, Table, TableLoading } from '../../components'
54

65
/* import { OperationWrapper } from './styles' */
6+
import { Trans } from '../../utils'
77
import * as logic from './logic'
88

99
/* eslint-disable react/display-name */
@@ -19,7 +19,11 @@ const columns = [
1919
width: 300,
2020
dataIndex: 'title',
2121
align: 'center',
22-
render: text => <div>{cutFrom(text, 15)}</div>,
22+
render: text => (
23+
<div>
24+
{Trans(text)}({text})
25+
</div>
26+
),
2327
},
2428
{
2529
title: 'raw',

0 commit comments

Comments
 (0)