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 8, 2022. It is now read-only.

Commit198edbc

Browse files
authored
refactor(redesign): explore as home page (#1250)
* refactor(route): re-org explore as home page* refactor(footer): home footer for explore page* style(explore): adjust content pending
1 parent3ef7777 commit198edbc

File tree

12 files changed

+203
-105
lines changed

12 files changed

+203
-105
lines changed

‎src/containers/content/ExploreContent/styles/community_card.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ const BaseCard = styled.div`
1010
1111
position: relative;
1212
padding: 15px 20px;
13-
width:260px;
13+
width:268px;
1414
height: 150px;
15-
margin-right: 25px;
15+
margin-left: 25px;
1616
background: #0c3442; //${theme('content.cardBg')};
1717
border: 1px solid;
1818
border-color:${theme('content.cardBorder')};

‎src/containers/content/ExploreContent/styles/community_list.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export const Wrapper = styled.div`
99
exportconstInnerWrapper=styled.div`
1010
${css.flex('justify-start')};
1111
flex-wrap: wrap;
12-
margin-left: 20px;
1312
1413
${css.media.mobile`
1514
margin-left: -10px;

‎src/containers/content/ExploreContent/styles/sidebar.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const Wrapper = styled.div`
88
width: 120px;
99
min-width: 120px;
1010
margin-right: 70px;
11-
margin-left:30px;
11+
margin-left:12px;
1212
`
1313
exportconstHolder=styled.div`
1414
flex-grow: 1;

‎src/containers/unit/Footer/DesktopView/TopInfo/index.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const TopInfo: FC<TProps> = ({
3333
caseMETRIC.WORKS_ARTICLE:{
3434
return<WorksArticle{...restProps}/>
3535
}
36-
caseMETRIC.EXPLORE:{
37-
return<Generaltitle="发现社区"/>
38-
}
36+
//case METRIC.EXPLORE: {
37+
// return <General title="发现社区" />
38+
//}
3939
caseMETRIC.COOL_GUIDE:{
4040
return<Generaltitle="酷导航"/>
4141
}

‎src/containers/unit/Footer/DesktopView/index.tsx‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,21 @@ const FooterContainer: FC<TProps> = ({
5252
METRIC.SPONSOR,
5353
METRIC.SUPPORT_US,
5454
METRIC.HAVE_A_DRINK,
55-
METRIC.EXPLORE,
5655
METRIC.FRIENDS,
5756
])
5857

5958
return(
6059
<Wrappertestid={testid}layout={c11n.bannerLayout}metric={metric}>
6160
<JoinModal/>
62-
{metric===METRIC.COMMUNITY&&isHome&&(
61+
{metric===METRIC.EXPLORE&&(
6362
<HomeLayout
6463
metric={metric}
6564
layout={c11n.bannerLayout}
6665
onlineStatus={onlineStatus}
6766
/>
6867
)}
6968

70-
{metric===METRIC.COMMUNITY&&!isHome&&(
69+
{metric===METRIC.COMMUNITY&&(
7170
<GeneralLayoutmetric={metric}title={curCommunity.title}/>
7271
)}
7372

‎src/pages/plaza.tsx‎renamed to ‎src/pages/gallery.tsx‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,10 @@ const loader = async (context, opt = {}) => {
3030
filter,
3131
)
3232
constsessionState=gqClient.request(P.sessionState)
33-
constsubscribedCommunities=gqClient.request(P.subscribedCommunities,{
34-
filter:{
35-
page:1,
36-
size:30,
37-
},
38-
})
3933

4034
return{
4135
filter,
4236
...(awaitsessionState),
43-
...(awaitsubscribedCommunities),
4437
...(awaitpagedArticles),
4538
}
4639
}
@@ -78,7 +71,7 @@ export const getServerSideProps = async (context) => {
7871
}
7972
}
8073

81-
constWorksListPage=(props)=>{
74+
constGalleryPage=(props)=>{
8275
conststore=useStore(props)
8376
constseoConfig=worksSEO()
8477

@@ -91,4 +84,4 @@ const WorksListPage = (props) => {
9184
)
9285
}
9386

94-
exportdefaultWorksListPage
87+
exportdefaultGalleryPage

‎src/pages/hot.tsx‎

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import{Provider}from'mobx-react'
2+
import{GetStaticProps}from'next'
3+
import{merge,toLower}from'ramda'
4+
5+
// import { PAGE_SIZE } from '@/config'
6+
import{HCN,THREAD,METRIC,ROUTE}from'@/constant'
7+
import{useStore}from'@/stores/init'
8+
9+
import{
10+
isArticleThread,
11+
ssrPagedArticleSchema,
12+
isrPagedArticlesFilter,
13+
ssrParseArticleThread,
14+
communitySEO,
15+
singular,
16+
makeGQClient,
17+
}from'@/utils'
18+
19+
importGlobalLayoutfrom'@/containers/layout/GlobalLayout'
20+
importCommunityContentfrom'@/containers/content/CommunityContent'
21+
22+
import{P}from'@/schemas'
23+
24+
constloader=async()=>{
25+
constgqClient=makeGQClient('')
26+
27+
// 线上环境会直接跳过 index 到这里,有待排查。。
28+
constcommunity=HCN
29+
constthread=THREAD.POST
30+
31+
// query data
32+
constcurCommunity=gqClient.request(P.community,{
33+
raw:community,
34+
userHasLogin:false,
35+
})
36+
37+
constpagedArticleTags=gqClient.request(P.pagedArticleTags,{
38+
filter:{communityRaw:community,thread:singular(thread,'upperCase')},
39+
})
40+
41+
constfilter=isrPagedArticlesFilter({})
42+
43+
constpagedArticles=isArticleThread(thread)
44+
?gqClient.request(ssrPagedArticleSchema(thread),filter)
45+
:{}
46+
47+
return{
48+
filter,
49+
...(awaitpagedArticleTags),
50+
...(awaitcurCommunity),
51+
...(awaitpagedArticles),
52+
}
53+
}
54+
55+
// export const getStaticPaths: GetStaticPaths = async () => {
56+
// return { paths: [], fallback: true }
57+
// }
58+
59+
exportconstgetStaticProps:GetStaticProps=async(ctx)=>{
60+
console.log('hot params: ',ctx)
61+
62+
constthread=THREAD.POST
63+
constresp=awaitloader()
64+
65+
const{ filter, community, pagedArticleTags}=resp
66+
// console.log('iii got resp: ', resp)
67+
constarticleThread=ssrParseArticleThread(resp,thread,filter)
68+
69+
constinitProps=merge(
70+
{
71+
// ...ssrBaseStates(resp),
72+
route:{
73+
communityPath:community.raw,
74+
mainPath:ROUTE.HOT,
75+
subPath:thread===THREAD.POST ?'' :thread,
76+
thread,
77+
},
78+
tagsBar:{
79+
tags:pagedArticleTags.entries,
80+
},
81+
viewing:{
82+
community,
83+
activeThread:toLower(thread),
84+
},
85+
},
86+
articleThread,
87+
)
88+
89+
return{props:{errorCode:null, ...initProps},revalidate:10}
90+
}
91+
92+
constCommunityPage=(props)=>{
93+
conststore=useStore(props)
94+
95+
const{ viewing}=store
96+
const{ community, activeThread}=viewing
97+
98+
return(
99+
<Providerstore={store}>
100+
<GlobalLayout
101+
metric={METRIC.COMMUNITY}
102+
seoConfig={communitySEO(community,activeThread)}
103+
>
104+
<CommunityContent/>
105+
</GlobalLayout>
106+
</Provider>
107+
)
108+
}
109+
110+
exportdefaultCommunityPage

‎src/pages/index.tsx‎

Lines changed: 69 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,101 @@
1+
/*
2+
this page is for /explore
3+
*/
14
import{Provider}from'mobx-react'
2-
import{GetStaticPaths,GetStaticProps}from'next'
3-
import{merge,toLower}from'ramda'
4-
5-
// import { PAGE_SIZE } from '@/config'
6-
import{HCN,THREAD,METRIC}from'@/constant'
7-
import{useStore}from'@/stores/init'
5+
import{clone}from'ramda'
6+
import{METRIC}from'@/constant'
87

8+
import{PAGE_SIZE}from'@/config'
99
import{
10-
isArticleThread,
11-
ssrPagedArticleSchema,
12-
isrPagedArticlesFilter,
13-
ssrParseArticleThread,
14-
communitySEO,
15-
singular,
16-
makeGQClient,
10+
ssrBaseStates,
11+
ssrFetchPrepare,
12+
ssrGetParam,
13+
refreshIfneed,
14+
exploreSEO,
15+
ssrError,
1716
}from'@/utils'
1817

18+
import{useStore}from'@/stores/init'
19+
1920
importGlobalLayoutfrom'@/containers/layout/GlobalLayout'
20-
importCommunityContentfrom'@/containers/content/CommunityContent'
21+
importExploreContentfrom'@/containers/content/ExploreContent'
2122

2223
import{P}from'@/schemas'
2324

24-
constloader=async()=>{
25-
constgqClient=makeGQClient('')
25+
constloader=async(context,opt={})=>{
26+
const{gqClient, userHasLogin}=ssrFetchPrepare(context,opt)
2627

27-
// 线上环境会直接跳过 index 到这里,有待排查。。
28-
constcommunity=HCN
29-
constthread=THREAD.POST
28+
constcategory=ssrGetParam(context,'nc_path')
29+
constpage=ssrGetParam(context,'page')
3030

31-
// query data
32-
constcurCommunity=gqClient.request(P.community,{
33-
raw:community,
34-
userHasLogin:false,
35-
})
31+
constfilter={
32+
page:1,
33+
size:PAGE_SIZE.M,
34+
}
3635

37-
constpagedArticleTags=gqClient.request(P.pagedArticleTags,{
38-
filter:{communityRaw:community,thread:singular(thread,'upperCase')},
39-
})
36+
constcommunitiesFilter=clone(filter)
37+
//@ts-ignore
38+
if(category)communitiesFilter.category=category
39+
if(page)communitiesFilter.page=parseInt(page,10)
4040

41-
constfilter=isrPagedArticlesFilter({})
41+
constsessionState=gqClient.request(P.sessionState)
42+
constpagedCommunities=gqClient.request(P.pagedCommunities,{
43+
filter:communitiesFilter,
44+
userHasLogin,
45+
})
46+
constpagedCategories=gqClient.request(P.pagedCategories,{ filter})
4247

43-
constpagedArticles=isArticleThread(thread)
44-
?gqClient.request(ssrPagedArticleSchema(thread),filter)
45-
:{}
48+
constsubscribedCommunities=gqClient.request(P.subscribedCommunities,{
49+
filter:{
50+
page:1,
51+
size:30,
52+
},
53+
})
4654

4755
return{
48-
filter,
49-
...(awaitpagedArticleTags),
50-
...(awaitcurCommunity),
51-
...(awaitpagedArticles),
56+
...(awaitsessionState),
57+
...(awaitpagedCategories),
58+
...(awaitpagedCommunities),
59+
...(awaitsubscribedCommunities),
5260
}
5361
}
5462

55-
exportconstgetStaticProps:GetStaticProps=async()=>{
56-
console.log('index params: ')
57-
58-
constthread=THREAD.POST
59-
constresp=awaitloader()
60-
61-
const{ filter, community, pagedArticleTags}=resp
62-
// console.log('iii got resp: ', resp)
63-
constarticleThread=ssrParseArticleThread(resp,thread,filter)
64-
65-
constinitProps=merge(
66-
{
67-
// ...ssrBaseStates(resp),
68-
route:{
69-
communityPath:community.raw,
70-
mainPath:community.raw===HCN ?'' :community.raw,
71-
subPath:thread===THREAD.POST ?'' :thread,
72-
thread,
73-
},
74-
tagsBar:{
75-
tags:pagedArticleTags.entries,
76-
},
77-
viewing:{
78-
community,
79-
activeThread:toLower(thread),
80-
},
63+
exportconstgetServerSideProps=async(context)=>{
64+
letresp
65+
try{
66+
resp=awaitloader(context)
67+
const{ sessionState}=resp
68+
69+
refreshIfneed(sessionState,'/explore',context)
70+
}catch(e){
71+
console.log('#### error from server: ',e)
72+
returnssrError(context,'fetch',500)
73+
}
74+
75+
const{ pagedCategories, pagedCommunities}=resp
76+
77+
constinitProps={
78+
...ssrBaseStates(resp),
79+
exploreContent:{
80+
pagedCommunities,
81+
pagedCategories,
8182
},
82-
articleThread,
83-
)
83+
}
8484

85-
return{props:{errorCode:null, ...initProps},revalidate:10}
85+
return{props:{errorCode:null, ...initProps}}
8686
}
8787

88-
constCommunityPage=(props)=>{
88+
constExplorePage=(props)=>{
8989
conststore=useStore(props)
90-
91-
const{ viewing}=store
92-
const{ community, activeThread}=viewing
90+
constseoConfig=exploreSEO()
9391

9492
return(
9593
<Providerstore={store}>
96-
<GlobalLayout
97-
metric={METRIC.COMMUNITY}
98-
seoConfig={communitySEO(community,activeThread)}
99-
>
100-
<CommunityContent/>
94+
<GlobalLayoutmetric={METRIC.EXPLORE}seoConfig={seoConfig}noSidebar>
95+
<ExploreContent/>
10196
</GlobalLayout>
10297
</Provider>
10398
)
10499
}
105100

106-
exportdefaultCommunityPage
101+
exportdefaultExplorePage

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp