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

Commit 5227c90

Browse files
committed
refactor(ssr): support repos page
1 parent 4a2f381 commit 5227c90

File tree

4 files changed

+76
-1
lines changed

4 files changed

+76
-1
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 ReposBanner = ({ 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 ReposBanner

containers/CommunitiesBanner/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import ThreadsBanner from './ThreadsBanner'
1313

1414
import PostsBanner from './PostsBanner'
1515
import JobsBanner from './JobsBanner'
16+
import ReposBanner from './ReposBanner'
1617

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

@@ -27,6 +28,7 @@ const ChildBanner = ({
2728
categoriesTotalCount,
2829
threadsTotalCount,
2930
postsTotalCount,
31+
reposTotalCount,
3032
restProps,
3133
}) => {
3234
const {
@@ -43,6 +45,8 @@ const ChildBanner = ({
4345
// jobs
4446
jobsTotalCount,
4547
filteredJobsCount,
48+
// repo
49+
filteredReposCount,
4650
} = restProps
4751

4852
switch (curRoute.subPath) {
@@ -90,7 +94,12 @@ const ChildBanner = ({
9094
)
9195
}
9296
case ROUTE.REPOS: {
93-
return <h3>REPOS Banner</h3>
97+
return (
98+
<ReposBanner
99+
totalCount={reposTotalCount}
100+
filteredCount={filteredReposCount}
101+
/>
102+
)
94103
}
95104
case ROUTE.VIDEOS: {
96105
return <h3>VIDEOS Banner</h3>
@@ -125,6 +134,7 @@ class CommunitiesBannerContainer extends React.Component {
125134
categoriesTotalCount,
126135
threadsTotalCount,
127136
postsTotalCount,
137+
reposTotalCount,
128138
} = communitiesBanner
129139

130140
return (
@@ -136,6 +146,7 @@ class CommunitiesBannerContainer extends React.Component {
136146
threadsTotalCount={threadsTotalCount}
137147
tagsTotalCount={tagsTotalCount}
138148
postsTotalCount={postsTotalCount}
149+
reposTotalCount={reposTotalCount}
139150
restProps={stripMobx(communitiesBanner)}
140151
/>
141152
</BannerContainer>

containers/CommunitiesBanner/store.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ const CommunitiesBannerStore = t
2828
// jobs
2929
jobsTotalCount: t.optional(t.number, 0),
3030
filteredJobsCount: t.maybeNull(t.number),
31+
// repo
32+
filteredReposCount: t.maybeNull(t.number),
3133
})
3234
.views(self => ({
3335
get root() {
@@ -48,6 +50,9 @@ const CommunitiesBannerStore = t
4850
get postsTotalCount() {
4951
return self.root.communitiesContent.pagedPosts.totalCount
5052
},
53+
get reposTotalCount() {
54+
return self.root.communitiesContent.pagedRepos.totalCount
55+
},
5156
get curRoute() {
5257
return self.root.curRoute
5358
},

utils/ssr_helper.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export const ssrPagedSchema = subpath => {
1616
case ROUTE.POSTS: {
1717
return P.pagedPosts
1818
}
19+
case ROUTE.REPOS: {
20+
return P.pagedRepos
21+
}
1922
default: {
2023
return P.pagedCommunities
2124
}
@@ -44,6 +47,11 @@ export const ssrPagedContents = (mainPath, subPath, resp) => {
4447
communitiesContent: { pagedPosts: resp.pagedPosts },
4548
}
4649
}
50+
case ROUTE.REPOS: {
51+
return {
52+
communitiesContent: { pagedRepos: resp.pagedRepos },
53+
}
54+
}
4755
default: {
4856
return {
4957
communitiesContent: { pagedCommunities: resp.pagedCommunities },

0 commit comments

Comments
 (0)