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.

Commit10cb079

Browse files
committed
refactor(sidebar): community & content workflow
1 parentd334e35 commit10cb079

File tree

17 files changed

+280
-363
lines changed

17 files changed

+280
-363
lines changed

‎containers/CommunitiesContent/logic.js‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ const DataSolver = [
292292
match:asyncRes('pagedCategories'),
293293
action:({ pagedCategories})=>{
294294
cancleLoading()
295+
debug('pagedCategories: ',pagedCategories)
295296
store.markState({ pagedCategories})
296297
},
297298
},
@@ -380,7 +381,6 @@ const DataSolver = [
380381
action:res=>{
381382
const{ mainPath, subPath}=res[EVENT.SIDEBAR_MENU_CHANGE].data
382383
if(mainPath!==ROUTE.COMMUNITIES)returnfalse
383-
debug('unknow event: ',subPath)
384384

385385
switch(subPath){
386386
caseROUTE.CATEGORIES:{
@@ -440,10 +440,8 @@ const ErrSolver = [
440440
exportfunctioninit(_store){
441441
store=_store
442442

443-
if(sub$)return// loadCommunities() // loadCategories()
443+
if(sub$)returnfalse
444444
sub$=sr71$.data().subscribe($solver(DataSolver,ErrSolver))
445-
446-
// loadCommunities() // loadCategories()
447445
}
448446

449447
exportfunctionuninit(){
Lines changed: 10 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,169 +1,18 @@
11
importReactfrom'react'
2-
importTimeAgofrom'timeago-react'
32

4-
import{cutFrom}from'../../utils'
5-
import{
6-
Pagi,
7-
Table,
8-
TableLoading,
9-
Button,
10-
Space,
11-
UserCell,
12-
}from'../../components'
3+
importPostsTablefrom'../../components/PostsTable'
134

14-
import{OperationWrapper}from'./styles'
5+
//import { OperationWrapper } from './styles'
156
import*aslogicfrom'./logic'
167

178
/* eslint-disable react/display-name */
18-
constcolumns=[
19-
{
20-
title:'id',
21-
dataIndex:'id',
22-
align:'center',
23-
width:80,
24-
fixed:'left',
25-
},
26-
{
27-
title:'作者',
28-
width:200,
29-
dataIndex:'author',
30-
align:'center',
31-
render:author=>{
32-
return<UserCelluser={author}/>
33-
},
34-
},
35-
{
36-
title:'标题',
37-
width:200,
38-
dataIndex:'title',
39-
align:'center',
40-
render:text=>{
41-
return<div>{cutFrom(text,15)}</div>
42-
},
43-
},
44-
{
45-
title:'摘要',
46-
width:300,
47-
dataIndex:'digest',
48-
align:'center',
49-
render:text=>{
50-
return<div>{cutFrom(text,10)}</div>
51-
},
52-
},
53-
{
54-
title:'浏览',
55-
width:100,
56-
dataIndex:'views',
57-
align:'center',
58-
},
59-
{
60-
title:'收藏',
61-
width:100,
62-
dataIndex:'favoritedCount',
63-
align:'center',
64-
},
65-
{
66-
title:'点赞',
67-
width:100,
68-
dataIndex:'starredCount',
69-
align:'center',
70-
},
71-
{
72-
title:'评论数',
73-
width:100,
74-
dataIndex:'commentsCount',
75-
align:'center',
76-
},
77-
{
78-
title:'评论参与',
79-
width:150,
80-
dataIndex:'commentsParticipatorsCount',
81-
align:'center',
82-
},
83-
{
84-
title:'创建时间',
85-
width:150,
86-
dataIndex:'insertedAt',
87-
align:'center',
88-
render:text=>{
89-
return<TimeAgodatetime={text}locale="zh_CN"/>
90-
},
91-
},
92-
{
93-
title:'上次更新',
94-
width:150,
95-
dataIndex:'updatedAt',
96-
align:'center',
97-
render:text=>{
98-
return<TimeAgodatetime={text}locale="zh_CN"/>
99-
},
100-
},
101-
{
102-
title:'操作',
103-
width:200,
104-
dataIndex:'',
105-
align:'center',
106-
render:(text,record)=>{
107-
return(
108-
<OperationWrapper>
109-
<Button
110-
size="small"
111-
type="primary"
112-
ghost
113-
onClick={logic.onEdit.bind(this,record)}
114-
>
115-
编辑
116-
</Button>
117-
<Spaceright="10px"/>
118-
<Button
119-
size="small"
120-
type="red"
121-
ghost
122-
onClick={logic.onDelete.bind(this,record)}
123-
>
124-
删除
125-
</Button>
126-
</OperationWrapper>
127-
)
128-
},
129-
},
130-
]
131-
132-
classPostsContentextendsReact.Component{
133-
componentDidMount(){
134-
// logic.loadPosts()
135-
}
136-
137-
render(){
138-
const{
139-
data,
140-
restProps:{ postsLoading},
141-
}=this.props
142-
return(
143-
<div>
144-
{data ?(
145-
<div>
146-
<Table
147-
columns={columns}
148-
dataSource={data.entries}
149-
scroll={{x:1500}}
150-
loading={TableLoading(postsLoading)}
151-
pagination={false}
152-
/>
153-
<Pagi
154-
left="-10px"
155-
pageNumber={data.pageNumber}
156-
pageSize={data.pageSize}
157-
totalCount={data.totalCount}
158-
onChange={logic.loadPosts}
159-
/>
160-
</div>
161-
) :(
162-
<div/>
163-
)}
164-
</div>
165-
)
166-
}
167-
}
9+
constPostsContent=({ data,restProps:{ postsLoading}})=>(
10+
<PostsTable
11+
data={data}
12+
loading={postsLoading}
13+
onDelete={logic.onDelete}
14+
onEdit={logic.onEdit}
15+
/>
16+
)
16817

16918
exportdefaultPostsContent

‎containers/CommunityContent/index.js‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,28 @@ import * as logic from './logic'
2121
constdebug=makeDebugger('C:CommunityContent')
2222
/* eslint-enable no-unused-vars */
2323

24-
constrenderChildContent=(route,store,restProps)=>{
24+
constrenderChildContent=(curRoute,store,restProps)=>{
2525
const{ pagedPostsData, pagedTagsData}=store
26-
// return <IndexContent data={pagedCommunitiesData} restProps={restProps} />
27-
// return <PostsContent data={pagedPostsData} restProps={restProps} />
2826

29-
debug('current fucking: ',pagedPostsData)
30-
31-
switch(route.subPath){
27+
switch(curRoute.subPath){
28+
caseROUTE.POSTS:{
29+
return<PostsContentdata={pagedPostsData}restProps={restProps}/>
30+
}
31+
caseROUTE.JOBS:{
32+
return<h3>ROUTE.JOBS</h3>
33+
}
34+
caseROUTE.REPOS:{
35+
return<h3>ROUTE.REPOS</h3>
36+
}
37+
caseROUTE.VIDEOS:{
38+
return<h3>ROUTE.VIDEOS</h3>
39+
}
3240
caseROUTE.TAGS:{
3341
return<TagsContentdata={pagedTagsData}restProps={restProps}/>
3442
}
3543
caseROUTE.EDITORS:{
3644
return<h2>Editors Content</h2>
3745
}
38-
caseROUTE.POSTS:{
39-
return<PostsContentdata={pagedPostsData}restProps={restProps}/>
40-
}
4146
default:{
4247
return<h2>default</h2>
4348
}
@@ -56,12 +61,12 @@ class CommunityContentContainer extends React.Component {
5661

5762
render(){
5863
const{ communityContent}=this.props
59-
const{route}=communityContent
64+
const{curRoute}=communityContent
6065
constrestProps={ ...communityContent}
6166

6267
return(
6368
<Wrapper>
64-
{renderChildContent(route,communityContent,restProps)}
69+
{renderChildContent(curRoute,communityContent,restProps)}
6570
</Wrapper>
6671
)
6772
}

‎containers/CommunityContent/logic.js‎

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
$solver,
77
// ERR,
88
makeDebugger,
9-
// EVENT,
9+
EVENT,
10+
ROUTE,
1011
TYPE,
1112
scrollIntoEle,
1213
}from'../../utils'
@@ -16,7 +17,10 @@ import S from './schema'
1617

1718
importSR71from'../../utils/network/sr71'
1819

19-
constsr71$=newSR71()
20+
constsr71$=newSR71({
21+
resv_event:[EVENT.SIDEBAR_MENU_CHANGE],
22+
})
23+
2024
letsub$=null
2125

2226
/* eslint-disable no-unused-vars */
@@ -25,18 +29,20 @@ const debug = makeDebugger('L:CommunityContent')
2529

2630
letstore=null
2731

28-
constcommonFilter=page=>{
32+
constcommonFilter=(page,community='home')=>{
2933
constsize=PAGE_SIZE.D
3034
return{
31-
filter:{ page, size},
35+
filter:{ page, size, community},
3236
}
3337
}
3438

3539
exportfunctionloadPosts(page=1){
3640
scrollIntoEle(TYPE.APP_HEADER_ID)
3741
store.markState({postsLoading:true})
3842

39-
sr71$.query(S.pagedPosts,commonFilter(page))
43+
const{mainPath:community}=store.curRoute
44+
45+
sr71$.query(S.pagedPosts,commonFilter(page,community))
4046
}
4147

4248
exportfunctionloadTags(page=1){
@@ -75,6 +81,40 @@ const DataSolver = [
7581
store.markState({ pagedTags})
7682
},
7783
},
84+
{
85+
match:asyncRes(EVENT.SIDEBAR_MENU_CHANGE),
86+
action:res=>{
87+
const{/* mainPath */ subPath}=res[EVENT.SIDEBAR_MENU_CHANGE].data
88+
debug('SIDEBAR_MENU_CHANGE ',res[EVENT.SIDEBAR_MENU_CHANGE].data)
89+
90+
switch(subPath){
91+
caseROUTE.CATEGORIES:{
92+
returnconsole.log('todo')
93+
}
94+
caseROUTE.TAGS:{
95+
returnloadTags()
96+
}
97+
caseROUTE.THREADS:{
98+
returnconsole.log('todo')
99+
}
100+
caseROUTE.POSTS:{
101+
returnloadPosts()
102+
}
103+
caseROUTE.JOBS:{
104+
returnconsole.log('todo')
105+
}
106+
caseROUTE.REPOS:{
107+
returnconsole.log('todo')
108+
}
109+
caseROUTE.VIDEOS:{
110+
returnconsole.log('todo')
111+
}
112+
default:{
113+
returnconsole.log('todo')
114+
}
115+
}
116+
},
117+
},
78118
]
79119
constErrSolver=[]
80120

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp