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

Commit bc8cf42

Browse files
committed
refactor(ssr): add video page add & ssr support
1 parent 5227c90 commit bc8cf42

File tree

13 files changed

+341
-58
lines changed

13 files changed

+341
-58
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from 'react'
2+
3+
import { ICON_CMD } from '../../config'
4+
import { Popover, BannerCountBrief } from '../../components'
5+
6+
import {
7+
BannerContentWrapper,
8+
Operation,
9+
OperationItem,
10+
OperationDivider,
11+
OperationTitle,
12+
OperationIcon,
13+
OperationIconChart,
14+
} from './styles/common_banner'
15+
16+
import * as logic from './logic'
17+
18+
const VideosBanner = ({ filteredCount, totalCount }) => (
19+
<BannerContentWrapper>
20+
<BannerCountBrief
21+
filteredCount={filteredCount}
22+
totalCount={totalCount}
23+
thread="视频"
24+
unit="个"
25+
/>
26+
<Operation>
27+
<OperationItem>
28+
<OperationIcon src={`${ICON_CMD}/filter2.svg`} />
29+
<Popover
30+
content={<div>兼容各个页面的 Filter 菜单</div>}
31+
trigger="hover"
32+
>
33+
<OperationTitle>过滤</OperationTitle>
34+
</Popover>
35+
</OperationItem>
36+
<OperationDivider />
37+
<OperationItem onClick={logic.onAdd}>
38+
<OperationIconChart src={`${ICON_CMD}/plus.svg`} />
39+
添加
40+
</OperationItem>
41+
<OperationDivider />
42+
<OperationItem>
43+
<OperationIcon src={`${ICON_CMD}/chart.svg`} />
44+
{/* <OperationIconChart src={`${ICON_CMD}/list.svg`} /> */}
45+
图表
46+
</OperationItem>
47+
</Operation>
48+
</BannerContentWrapper>
49+
)
50+
51+
export default VideosBanner

containers/CommunitiesBanner/index.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import ThreadsBanner from './ThreadsBanner'
1414
import PostsBanner from './PostsBanner'
1515
import JobsBanner from './JobsBanner'
1616
import ReposBanner from './ReposBanner'
17+
import VideosBanner from './VideosBanner'
1718

1819
import { BannerContainer } from './styles'
1920

@@ -28,7 +29,9 @@ const ChildBanner = ({
2829
categoriesTotalCount,
2930
threadsTotalCount,
3031
postsTotalCount,
32+
jobsTotalCount,
3133
reposTotalCount,
34+
videosTotalCount,
3235
restProps,
3336
}) => {
3437
const {
@@ -43,10 +46,11 @@ const ChildBanner = ({
4346
// posts
4447
filteredPostsCount,
4548
// jobs
46-
jobsTotalCount,
4749
filteredJobsCount,
4850
// repo
4951
filteredReposCount,
52+
// video
53+
filteredVideosCount,
5054
} = restProps
5155

5256
switch (curRoute.subPath) {
@@ -102,7 +106,12 @@ const ChildBanner = ({
102106
)
103107
}
104108
case ROUTE.VIDEOS: {
105-
return <h3>VIDEOS Banner</h3>
109+
return (
110+
<VideosBanner
111+
totalCount={videosTotalCount}
112+
filteredCount={filteredVideosCount}
113+
/>
114+
)
106115
}
107116
default: {
108117
return (
@@ -134,7 +143,9 @@ class CommunitiesBannerContainer extends React.Component {
134143
categoriesTotalCount,
135144
threadsTotalCount,
136145
postsTotalCount,
146+
jobsTotalCount,
137147
reposTotalCount,
148+
videosTotalCount,
138149
} = communitiesBanner
139150

140151
return (
@@ -146,7 +157,9 @@ class CommunitiesBannerContainer extends React.Component {
146157
threadsTotalCount={threadsTotalCount}
147158
tagsTotalCount={tagsTotalCount}
148159
postsTotalCount={postsTotalCount}
160+
jobsTotalCount={jobsTotalCount}
149161
reposTotalCount={reposTotalCount}
162+
videosTotalCount={videosTotalCount}
150163
restProps={stripMobx(communitiesBanner)}
151164
/>
152165
</BannerContainer>

containers/CommunitiesBanner/store.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,15 @@ const debug = makeDebugger('S:CommunitiesBannerStore')
1313

1414
const CommunitiesBannerStore = t
1515
.model('CommunitiesBannerStore', {
16-
// communities: totalCount of all
17-
// totalCount: t.optional(t.number, 0),
18-
filteredTotalCount: t.maybeNull(t.number),
19-
// categories
20-
filterdCategoriesCount: t.maybeNull(t.number),
21-
// tags
22-
filterdTagsCount: t.maybeNull(t.number),
23-
// threads
24-
filterdThreadsCount: t.maybeNull(t.number),
25-
// posts
26-
// postsTotalCount: t.optional(t.number, 0),
27-
filteredPostsCount: t.maybeNull(t.number),
28-
// jobs
29-
jobsTotalCount: t.optional(t.number, 0),
30-
filteredJobsCount: t.maybeNull(t.number),
31-
// repo
32-
filteredReposCount: t.maybeNull(t.number),
16+
filteredTotalCount: t.maybeNull(t.number), // communities
17+
filterdCategoriesCount: t.maybeNull(t.number), // categories
18+
filterdTagsCount: t.maybeNull(t.number), // tags
19+
filterdThreadsCount: t.maybeNull(t.number), // threads
20+
21+
filteredPostsCount: t.maybeNull(t.number), // posts
22+
filteredJobsCount: t.maybeNull(t.number), // jobs
23+
filteredReposCount: t.maybeNull(t.number), // repo
24+
filteredVideosCount: t.maybeNull(t.number), // video
3325
})
3426
.views(self => ({
3527
get root() {
@@ -50,9 +42,15 @@ const CommunitiesBannerStore = t
5042
get postsTotalCount() {
5143
return self.root.communitiesContent.pagedPosts.totalCount
5244
},
45+
get jobsTotalCount() {
46+
return self.root.communitiesContent.pagedJobs.totalCount
47+
},
5348
get reposTotalCount() {
5449
return self.root.communitiesContent.pagedRepos.totalCount
5550
},
51+
get videosTotalCount() {
52+
return self.root.communitiesContent.pagedVideos.totalCount
53+
},
5654
get curRoute() {
5755
return self.root.curRoute
5856
},

containers/CommunitiesContent/JobsContent.js

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -157,41 +157,27 @@ const columns = [
157157
},
158158
]
159159

160-
class JobsContent extends React.Component {
161-
componentDidMount() {
162-
logic.loadJobs()
163-
}
164-
165-
render() {
166-
const {
167-
data,
168-
restProps: { communitiesLoading },
169-
} = this.props
170-
return (
160+
const JobsContent = ({ data, restProps: { communitiesLoading } }) => (
161+
<React.Fragment>
162+
{data ? (
171163
<div>
172-
{data ? (
173-
<div>
174-
<Table
175-
columns={columns}
176-
dataSource={data.entries}
177-
scroll={{ x: 2000 }}
178-
loading={TableLoading(communitiesLoading)}
179-
pagination={false}
180-
/>
181-
<Pagi
182-
left="-10px"
183-
pageNumber={data.pageNumber}
184-
pageSize={data.pageSize}
185-
totalCount={data.totalCount}
186-
onChange={logic.loadJobs}
187-
/>
188-
</div>
189-
) : (
190-
<div />
191-
)}
164+
<Table
165+
columns={columns}
166+
dataSource={data.entries}
167+
scroll={{ x: 2000 }}
168+
loading={TableLoading(communitiesLoading)}
169+
pagination={false}
170+
/>
171+
<Pagi
172+
left="-10px"
173+
pageNumber={data.pageNumber}
174+
pageSize={data.pageSize}
175+
totalCount={data.totalCount}
176+
onChange={logic.loadJobs}
177+
/>
192178
</div>
193-
)
194-
}
195-
}
179+
) : null}
180+
</React.Fragment>
181+
)
196182

197183
export default JobsContent

0 commit comments

Comments
 (0)