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.

Commita4c50ef

Browse files
authored
refactor(articles-thread): extract articles thread (#1108)
* refactor(articlesFilter): adjust props* feat: add useMST hooks, awesome* chore: missing inline doc* chore(articles-thread): basic setup* chore(articles-thread): drop PostsThread* refactor(articlesFilter): wip* fix(preview): edge case* chore(types): add common used useMST store type* refactor(useMST): split it into useAccount* refactor(useAccount): improve type* refactor(useAccount): imporve substore hooks* chore(articles-thread): filter naming* refactor: wip* refactor(loadingEffect): rename to loading & ts* refactor: wip* refactor: wip* refactor(articlesThread): adjust props* refactor(articlesThread): make onPreview eventify* chore(articlesThread): fmt* chore(articlesThread): mv holygrail tabs to common layout* refactor(community-content): re-org* refactor(articlesThread): tab change wip
1 parent162c729 commita4c50ef

File tree

126 files changed

+1109
-2372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+1109
-2372
lines changed

‎server/routes.js‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,6 @@ router.route('/:community/help-center').get((req, res) => {
124124
returnrenderAndCache({ req, res,path:'/help-center'})
125125
})
126126

127-
// NOTE: TMP: 博客
128-
router.route('/:community/blogs').get((req,res)=>{
129-
returnrenderAndCache({ req, res,path:'/home/blogs'})
130-
})
131-
132127
// 社区主页
133128
router.route('/:community/:thread').get((req,res)=>{
134129
if(

‎src/components/ArticleItemPrefixLabel/ReadLabel.tsx‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import{FC,memo}from'react'
2+
import{useAccount}from'@/hooks'
23

34
import{ReadedLabel}from'./styles'
4-
55
importtype{TProps}from'./index'
66

7-
constReadLabel:FC<TProps>=({ entry, accountInfo, topOffset='20px'})=>{
7+
constReadLabel:FC<TProps>=({ entry, topOffset='20px'})=>{
8+
const{ c11n}=useAccount()
9+
const{ isLogin, markViewed}=c11n
10+
811
const{ viewerHasViewed}=entry
9-
const{
10-
isLogin,
11-
customization:{ markViewed},
12-
}=accountInfo
1312

1413
if(!isLogin)returnnull
1514
if(markViewed&&viewerHasViewed){

‎src/components/ArticleItemPrefixLabel/index.tsx‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
import{FC,memo}from'react'
88

9-
importtype{TAccount}from'@/spec'
109
import{buildLog}from'@/utils'
1110
import{PinIcon}from'./styles'
1211
importReadLabelfrom'./ReadLabel'
@@ -15,23 +14,16 @@ import ReadLabel from './ReadLabel'
1514
constlog=buildLog('c:ArticleItemPrefixLabel:index')
1615

1716
exporttypeTProps={
18-
accountInfo:TAccount
1917
topOffset?:string
2018
entry:{
2119
viewerHasViewed?:boolean
2220
pin?:boolean
2321
}
2422
}
25-
constArticleItemPrefixLabel:FC<TProps>=({
26-
entry,
27-
accountInfo,
28-
topOffset='22px',
29-
})=>{
23+
constArticleItemPrefixLabel:FC<TProps>=({ entry, topOffset='22px'})=>{
3024
if(entry.pin)return<PinIcontop={topOffset}/>
3125

32-
return(
33-
<ReadLabelentry={entry}accountInfo={accountInfo}topOffset={topOffset}/>
34-
)
26+
return<ReadLabelentry={entry}topOffset={topOffset}/>
3527
}
3628

3729
exportdefaultmemo(ArticleItemPrefixLabel)

‎src/components/ArticlesFilter/DesktopView.tsx‎

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,66 @@
55
*/
66

77
import{FC,memo}from'react'
8+
importdynamicfrom'next/dynamic'
89

9-
importtype{TThread,TAccount,TArticleFilter}from'@/spec'
10-
import{THREAD}from'@/constant'
10+
importtype{TArticleFilter,TResState}from'@/spec'
11+
12+
import{TYPE}from'@/constant'
1113
import{buildLog}from'@/utils'
14+
import{useViewing}from'@/hooks'
1215

1316
importFilterButtonfrom'./FilterButton'
14-
importSelectedTagsfrom'./SelectedTags'
17+
importSelectedFiltersfrom'./SelectedFilters'
1518
importFilterResultfrom'./FilterResult'
1619

1720
import{Wrapper,MainFilterWrapper}from'./styles'
1821

1922
/* eslint-disable-next-line */
2023
constlog=buildLog('c:ArticlesFilter:index')
2124

25+
constLavaLampLoading=dynamic(
26+
()=>import('@/components/Loading/LavaLampLoading'),
27+
{
28+
/* eslint-disable react/display-name */
29+
loading:()=><div/>,
30+
ssr:false,
31+
},
32+
)
33+
2234
typeTProps={
2335
activeFilter:TArticleFilter
2436
onSelect:(filter:TArticleFilter)=>void
25-
thread:TThread
26-
accountInfo:TAccount
37+
pageNumber?:number
2738
totalCount?:number
39+
resState?:TResState
2840
}
2941

3042
constArticlesFilter:FC<TProps>=({
31-
thread=THREAD.POST,
3243
activeFilter={},
3344
onSelect,
34-
accountInfo:{ isLogin},
45+
pageNumber=1,
3546
totalCount=0,
36-
})=>(
37-
<Wrapper>
38-
<MainFilterWrapper>
39-
<FilterButton
40-
thread={thread}
41-
onSelect={onSelect}
42-
isLogin={isLogin}
43-
activeFilter={activeFilter}
44-
/>
45-
46-
<SelectedTagsonSelect={onSelect}activeFilter={activeFilter}/>
47-
</MainFilterWrapper>
48-
<FilterResulttotalCount={totalCount}/>
49-
</Wrapper>
50-
)
47+
resState=TYPE.RES_STATE.DONE,
48+
})=>{
49+
const{ activeThread}=useViewing()
50+
51+
return(
52+
<Wrapper>
53+
<MainFilterWrapper>
54+
<FilterButton
55+
thread={activeThread}
56+
onSelect={onSelect}
57+
activeFilter={activeFilter}
58+
/>
59+
<SelectedFiltersonSelect={onSelect}activeFilter={activeFilter}/>
60+
</MainFilterWrapper>
61+
62+
{resState===TYPE.RES_STATE.LOADING&&(
63+
<LavaLampLoadingtop={2}right={28}/>
64+
)}
65+
<FilterResultpageNumber={pageNumber}totalCount={totalCount}/>
66+
</Wrapper>
67+
)
68+
}
5169

5270
exportdefaultmemo(ArticlesFilter)

‎src/components/ArticlesFilter/FilterButton.tsx‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import dynamic from 'next/dynamic'
33

44
importtype{TThread,TArticleFilter}from'@/spec'
55
import{ICON_CMD}from'@/config'
6+
import{useAccount}from'@/hooks'
67

78
importTooltipfrom'@/components/Tooltip'
89

@@ -21,17 +22,13 @@ const FilterPanel = dynamic(() => import('./FilterPanel/index'), {
2122

2223
typeTProps={
2324
thread:TThread
24-
isLogin:boolean
2525
activeFilter:TArticleFilter
2626
onSelect:(filter:TArticleFilter)=>void
2727
}
2828

29-
constFilterButton:FC<TProps>=({
30-
thread,
31-
onSelect,
32-
isLogin,
33-
activeFilter,
34-
})=>{
29+
constFilterButton:FC<TProps>=({ thread, onSelect, activeFilter})=>{
30+
const{ isLogin}=useAccount()
31+
3532
return(
3633
<Wrapper>
3734
<Tooltip

‎src/components/ArticlesFilter/FilterResult.tsx‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
import{FC,memo}from'react'
22

3+
importDotDividerfrom'@/components/DotDivider'
4+
35
import{Wrapper,ResultText}from'./styles/filter_result'
46

57
typeTProps={
68
totalCount:number
9+
pageNumber:number
710
}
811

9-
constFilterResult:FC<TProps>=({ totalCount})=>{
12+
constFilterResult:FC<TProps>=({pageNumber,totalCount})=>{
1013
return(
1114
<Wrapper>
15+
<ResultText>{pageNumber}</ResultText>
16+
<DotDividerspace={8}/>
1217
<ResultText>{totalCount}</ResultText>
1318
</Wrapper>
1419
)

‎src/components/ArticlesFilter/SelectedTags.tsx‎renamed to ‎src/components/ArticlesFilter/SelectedFilters.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { TArticleFilter } from '@/spec'
55
import{isEmptyValue}from'@/utils'
66

77
importTagfrom'@/components/Tag'
8-
import{Wrapper,TagWrapper}from'./styles/selected_tags'
8+
import{Wrapper,TagWrapper}from'./styles/selected_filters'
99

1010
constfilterDict={
1111
TODAY:'今天',
@@ -51,7 +51,7 @@ type TProps = {
5151
activeFilter:TArticleFilter
5252
}
5353

54-
constSelectedTags:FC<TProps>=({ activeFilter, onSelect})=>(
54+
constSelectedFilters:FC<TProps>=({ activeFilter, onSelect})=>(
5555
<Wrapper>
5656
{keys(activeFilter).map((filterKey)=>(
5757
<FilterTag
@@ -64,4 +64,4 @@ const SelectedTags: FC<TProps> = ({ activeFilter, onSelect }) => (
6464
</Wrapper>
6565
)
6666

67-
exportdefaultmemo(SelectedTags)
67+
exportdefaultmemo(SelectedFilters)

‎src/components/ArticlesFilter/index.tsx‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
*/
66

7-
importReactfrom'react'
7+
import{Fragment,memo}from'react'
88

99
import{useDevice}from'@/hooks'
1010
import{buildLog}from'@/utils'
@@ -17,9 +17,7 @@ const log = buildLog('c:ArticlesFilter:index')
1717
constArticlesFilter=(props)=>{
1818
const{ isMobile}=useDevice()
1919

20-
return(
21-
<React.Fragment>{!isMobile&&<DesktopView{...props}/>}</React.Fragment>
22-
)
20+
return<Fragment>{!isMobile&&<DesktopView{...props}/>}</Fragment>
2321
}
2422

25-
exportdefaultReact.memo(ArticlesFilter)
23+
exportdefaultmemo(ArticlesFilter)

‎src/components/ArticlesFilter/styles/filter_result.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ export const Wrapper = styled.div`
77
`
88
exportconstResultText=styled.div`
99
color:${theme('thread.filterResultHint')};
10-
margin-right: 3px;
1110
`
File renamed without changes.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp