Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commitc60c453

Browse files
committed
refactor(tables): add repos table to community with ssr
1 parentc87775f commitc60c453

File tree

9 files changed

+121
-8
lines changed

9 files changed

+121
-8
lines changed

‎containers/CommunitiesContent/logic.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,16 @@ export function unsetTag(threadId, tag) {
225225
}
226226

227227
/* when error occured cancle all the loading state */
228-
constcancleLoading=()=>{
228+
constcancleLoading=()=>
229229
store.markState({
230230
communitiesLoading:false,
231231
postsLoading:false,
232232
jobsLoading:false,
233+
reposLoading:false,
234+
videosLoading:false,
233235
tagsLoading:false,
234236
categoriessLoading:false,
235237
})
236-
}
237238

238239
constDataSolver=[
239240
{
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
importReactfrom'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*aslogicfrom'./logic'
17+
18+
constVideosBanner=({ filteredCount, totalCount})=>(
19+
<BannerContentWrapper>
20+
<BannerCountBrieffilteredCount={filteredCount}totalCount={totalCount}/>
21+
<Operation>
22+
<OperationItemonClick={console.log}>
23+
<OperationIconChartsrc={`${ICON_CMD}/refresh.svg`}/>
24+
刷新
25+
</OperationItem>
26+
<OperationDivider/>
27+
<OperationItem>
28+
<OperationIconsrc={`${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+
<OperationItemonClick={logic.onAdd}>
38+
<OperationIconChartsrc={`${ICON_CMD}/plus.svg`}/>
39+
添加
40+
</OperationItem>
41+
<OperationDivider/>
42+
<OperationItem>
43+
<OperationIconsrc={`${ICON_CMD}/chart.svg`}/>
44+
图表
45+
</OperationItem>
46+
</Operation>
47+
</BannerContentWrapper>
48+
)
49+
50+
exportdefaultVideosBanner

‎containers/CommunityBanner/index.js‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import * as logic from './logic'
1414

1515
importPostsBannerfrom'./PostsBanner'
1616
importJobsBannerfrom'./JobsBanner'
17+
importVideosBannerfrom'./VideosBanner'
1718
importTagsBannerfrom'./TagsBanner'
1819
importThreadsBannerfrom'./ThreadsBanner'
1920
importSubscribersBannerfrom'./SubscribersBanner'
@@ -28,10 +29,15 @@ const ChildBanner = ({
2829
curRoute,
2930
postsTotalCount,
3031
jobsTotalCount,
32+
videosTotalCount,
3133
tagsTotalCount,
3234
restProps,
3335
})=>{
34-
const{ filteredPostsCount, filteredJobsCount}=restProps
36+
const{
37+
filteredPostsCount,
38+
filteredJobsCount,
39+
filteredVideosCount,
40+
}=restProps
3541

3642
switch(curRoute.subPath){
3743
caseROUTE.POSTS:{
@@ -50,6 +56,14 @@ const ChildBanner = ({
5056
/>
5157
)
5258
}
59+
caseROUTE.VIDEOS:{
60+
return(
61+
<VideosBanner
62+
totalCount={videosTotalCount}
63+
filteredCount={filteredVideosCount}
64+
/>
65+
)
66+
}
5367
caseROUTE.SUBSCRIBERS:{
5468
return<SubscribersBannertotalCount={100}filteredCount={10}/>
5569
}
@@ -82,6 +96,7 @@ class CommunityBannerContainer extends React.Component {
8296
curRoute,
8397
postsTotalCount,
8498
jobsTotalCount,
99+
videosTotalCount,
85100
tagsTotalCount,
86101
}=communityBanner
87102

@@ -91,6 +106,7 @@ class CommunityBannerContainer extends React.Component {
91106
curRoute={curRoute}
92107
postsTotalCount={postsTotalCount}
93108
jobsTotalCount={jobsTotalCount}
109+
videosTotalCount={videosTotalCount}
94110
tagsTotalCount={tagsTotalCount}
95111
restProps={stripMobx(communityBanner)}
96112
/>

‎containers/CommunityBanner/store.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const CommunityBannerStore = t
1616
// postsTotalCount: t.optional(t.number, 0),
1717
filteredPostsCount:t.maybeNull(t.number),
1818
filteredJobsCount:t.maybeNull(t.number),
19+
filteredVideosCount:t.maybeNull(t.number),
1920
// tagsTotalCount: t.optional(t.number, 0),
2021
})
2122
.views(self=>({
@@ -28,6 +29,9 @@ const CommunityBannerStore = t
2829
getjobsTotalCount(){
2930
returnself.root.communityContent.pagedJobs.totalCount
3031
},
32+
getvideosTotalCount(){
33+
returnself.root.communityContent.pagedVideos.totalCount
34+
},
3135
gettagsTotalCount(){
3236
returnself.root.communityContent.pagedTags.length
3337
},
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
importReactfrom'react'
2+
3+
importVideosTablefrom'../../components/VideosTable'
4+
import*aslogicfrom'./logic'
5+
6+
constVideosContent=({ data,restProps:{ videosLoading}})=>(
7+
<VideosTable
8+
data={data}
9+
loading={videosLoading}
10+
onDelete={logic.onDelete}
11+
onEdit={logic.onEdit}
12+
/>
13+
)
14+
15+
exportdefaultVideosContent

‎containers/CommunityContent/index.js‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { makeDebugger, storePlug, ROUTE } from '../../utils'
1414
importPostsContentfrom'./PostsContent'
1515
importJobsContentfrom'./JobsContent'
1616
importTagsContentfrom'./TagsContent'
17+
importVideosContentfrom'./VideosContent'
1718

1819
import{Wrapper}from'./styles'
1920
import*aslogicfrom'./logic'
@@ -26,6 +27,7 @@ const ChildContent = ({
2627
curRoute,
2728
pagedPostsData,
2829
pagedJobsData,
30+
pagedVideosData,
2931
pagedTagsData,
3032
restProps,
3133
})=>{
@@ -40,7 +42,7 @@ const ChildContent = ({
4042
return<h3>ROUTE.REPOS</h3>
4143
}
4244
caseROUTE.VIDEOS:{
43-
return<h3>ROUTE.VIDEOS</h3>
45+
return<VideosContentdata={pagedVideosData}restProps={restProps}/>
4446
}
4547
caseROUTE.TAGS:{
4648
return<TagsContentdata={pagedTagsData}restProps={restProps}/>
@@ -70,16 +72,20 @@ class CommunityContentContainer extends React.Component {
7072
curRoute,
7173
pagedPostsData,
7274
pagedJobsData,
75+
pagedVideosData,
7376
pagedTagsData,
7477
}=communityContent
7578
constrestProps={ ...communityContent}
7679

80+
console.log('the fuck pagedVideosData: ',pagedVideosData)
81+
7782
return(
7883
<Wrapper>
7984
<ChildContent
8085
curRoute={curRoute}
8186
pagedPostsData={pagedPostsData}
8287
pagedJobsData={pagedJobsData}
88+
pagedVideosData={pagedVideosData}
8389
pagedTagsData={pagedTagsData}
8490
restProps={restProps}
8591
/>

‎containers/CommunityContent/logic.js‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ export function loadJobs(page = 1) {
5050
sr71$.query(S.pagedJobs,commonFilter(page,community))
5151
}
5252

53+
exportfunctionloadVideos(page=1){
54+
scrollIntoEle(TYPE.APP_HEADER_ID)
55+
store.markState({videosLoading:true})
56+
const{mainPath:community}=store.curRoute
57+
sr71$.query(S.pagedVideos,commonFilter(page,community))
58+
}
59+
5360
exportfunctionloadTags(){
5461
scrollIntoEle(TYPE.APP_HEADER_ID)
5562
store.markState({tagsLoading:true})
@@ -69,6 +76,8 @@ const cancleLoading = () => {
6976
// communitiesLoading: false,
7077
postsLoading:false,
7178
jobsLoading:false,
79+
videosLoading:false,
80+
reposLoading:false,
7281
tagsLoading:false,
7382
})
7483
}
@@ -88,6 +97,13 @@ const DataSolver = [
8897
store.markState({ pagedJobs})
8998
},
9099
},
100+
{
101+
match:asyncRes('pagedVideos'),
102+
action:({ pagedVideos})=>{
103+
cancleLoading()
104+
store.markState({ pagedVideos})
105+
},
106+
},
91107
{
92108
match:asyncRes('partialTags'),
93109
action:({ partialTags})=>{
@@ -102,9 +118,6 @@ const DataSolver = [
102118
debug('SIDEBAR_MENU_CHANGE ',res[EVENT.SIDEBAR_MENU_CHANGE].data)
103119

104120
switch(subPath){
105-
caseROUTE.CATEGORIES:{
106-
returnconsole.log('todo')
107-
}
108121
caseROUTE.TAGS:{
109122
returnloadTags()
110123
}
@@ -121,7 +134,7 @@ const DataSolver = [
121134
returnconsole.log('todo')
122135
}
123136
caseROUTE.VIDEOS:{
124-
returnconsole.log('todo')
137+
returnloadVideos()
125138
}
126139
default:{
127140
returnconsole.log('todo')

‎containers/CommunityContent/store.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ const CommunityContentStore = t
5757
getpagedJobsData(){
5858
returnstripMobx(self.pagedJobs)
5959
},
60+
getpagedVideosData(){
61+
returnstripMobx(self.pagedVideos)
62+
},
6063
getpagedTagsData(){
6164
return{entries:stripMobx(self.pagedTags)}
6265
},

‎utils/ssr_helper.js‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ const ssrCommunityContents = (subPath, resp) => {
5959
communityContent:{pagedJobs:resp.pagedJobs},
6060
}
6161
}
62+
caseROUTE.VIDEOS:{
63+
return{
64+
communityContent:{pagedVideos:resp.pagedVideos},
65+
}
66+
}
6267
caseROUTE.TAGS:{
6368
return{
6469
communityContent:{pagedTags:resp.partialTags},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp