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.

Commitd6b8b87

Browse files
authored
chore(footer): home footer status (#1208)
* chore: tmp thought* feat(footer): add online status for home layout
1 parentd13471f commitd6b8b87

File tree

7 files changed

+49
-10
lines changed

7 files changed

+49
-10
lines changed

‎src/containers/content/HaveADrinkContent/demo.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ const demo = [
149149
text:'意指一件产品包含了所有必要的东西,开箱即用,最早来源于 Python 社区。',
150150
reference:'https://qr.ae/pGmyXB',
151151
},
152+
{
153+
title:'Snowflake ID',
154+
text:'Twitter 开发的用于标识 tweets 的分布式算法,特点之一是发布时间相近的 tweet, 其生成的 ID 也相近。',
155+
reference:'https://en.wikipedia.org/wiki/Snowflake_ID',
156+
},
152157
],
153158
},
154159
{

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import{FC,memo}from'react'
22
import{useTheme}from'styled-components'
33

4-
importtype{TThemeMap,TC11NLayout,TMetric}from'@/spec'
4+
importtype{TThemeMap,TC11NLayout,TMetric,TOnlineStatus}from'@/spec'
55
import{GITHUB,BUILD_VERSION}from'@/config'
66
import{ROUTE}from'@/constant'
77
import{siteBirthDay}from'@/utils/helper'
@@ -24,9 +24,10 @@ import {
2424
typeTProps={
2525
metric:TMetric
2626
layout:TC11NLayout
27+
onlineStatus:TOnlineStatus
2728
}
2829

29-
constHomeView:FC<TProps>=({ metric, layout})=>{
30+
constHomeView:FC<TProps>=({ metric, layout, onlineStatus})=>{
3031
consttheme=useTheme()asTThemeMap
3132

3233
constlinkColors={
@@ -119,10 +120,10 @@ const HomeView: FC<TProps> = ({ metric, layout }) => {
119120
<Title>用户</Title>
120121
<Body>
121122
<Itemas="span"normal>
122-
注册人数:--
123+
注册人数:{onlineStatus.totalSubscribes}
123124
</Item>
124125
<Itemas="span"normal>
125-
在线人数:--
126+
在线人数:{onlineStatus.realtimeVisitors}
126127
</Item>
127128
<Itemas="span"normal>
128129
黑洞: --

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const FooterContainer: FC<TProps> = ({
4242
})=>{
4343
useInit(store,metric)
4444

45-
const{ viewingArticle, curCommunity, c11n}=store
45+
const{ viewingArticle, curCommunity, c11n, onlineStatus}=store
4646
constisHome=curCommunity.raw===HCN
4747
constisGeneral=includes(metric,[
4848
METRIC.WORKS_ARTICLE,
@@ -59,7 +59,11 @@ const FooterContainer: FC<TProps> = ({
5959
<Wrappertestid={testid}layout={c11n.bannerLayout}metric={metric}>
6060
<JoinModal/>
6161
{metric===METRIC.COMMUNITY&&isHome&&(
62-
<HomeLayoutmetric={metric}layout={c11n.bannerLayout}/>
62+
<HomeLayout
63+
metric={metric}
64+
layout={c11n.bannerLayout}
65+
onlineStatus={onlineStatus}
66+
/>
6367
)}
6468

6569
{metric===METRIC.COMMUNITY&&!isHome&&(

‎src/containers/unit/Footer/store.ts‎

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@
55

66
import{typesasT,getParent,Instance}from'mobx-state-tree'
77

8-
importtype{TRootStore,TAccount,TC11N,TArticle,TCommunity}from'@/spec'
9-
import{METRIC}from'@/constant'
8+
importtype{
9+
TRootStore,
10+
TAccount,
11+
TC11N,
12+
TArticle,
13+
TCommunity,
14+
TOnlineStatus,
15+
}from'@/spec'
16+
import{METRIC,HCN}from'@/constant'
1017
import{markStates,toJS}from'@/utils/mobx'
1118

1219
// import { VIEW, TFooterView } from './constants'
@@ -40,6 +47,22 @@ const FooterStore = T.model('FooterStore', {
4047
returntoJS(root.viewing.community)
4148
},
4249

50+
gettotalSubscribes():number{
51+
constslf=selfasTStore
52+
const{ curCommunity}=slf
53+
54+
if(curCommunity.raw===HCN){
55+
returncurCommunity.subscribersCount
56+
}
57+
58+
return0
59+
},
60+
getonlineStatus():TOnlineStatus{
61+
constslf=selfasTStore
62+
const{ totalSubscribes, realtimeVisitors}=slf
63+
64+
return{ totalSubscribes, realtimeVisitors}
65+
},
4366
// get type(): TFooterView {
4467
// const root = getParent(self) as TRootStore
4568
// if (root.viewing.community.raw === HCN) return VIEW.HOME

‎src/containers/unit/TagsBar/DesktopView/Folder.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import{FC,useState,useRef,useEffect}from'react'
22

3-
import{findIndex}from'ramda'
3+
import{findIndex,reverse}from'ramda'
44

55
import{ICON}from'@/config'
66
import{sortByColor}from'@/utils/helper'
@@ -52,7 +52,7 @@ const Folder: FC<TProps> = ({
5252
const[isFolderOpen,toggleFolder]=useState(true)
5353
const[curDisplayCount,setCurDisplayCount]=useState(initDisplayCount)
5454

55-
constsortedTags=sortByColor(groupTags)
55+
constsortedTags=reverse(sortByColor(groupTags))
5656

5757
constisActiveTagInFolder=
5858
//@ts-ignore

‎src/spec/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export type {
6969
TView,
7070
TUserActivity,
7171
TEditMode,
72+
TOnlineStatus,
7273
}from'./utils'
7374

7475
exporttype{TGQLError}from'./graphql'

‎src/spec/utils.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,8 @@ export type TUserActivity = {
163163
action?:string
164164
totalCount?:number
165165
}
166+
167+
exporttypeTOnlineStatus={
168+
totalSubscribes?:number
169+
realtimeVisitors?:number
170+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp