Commit 95b665cd authored by m's avatar m

feat: update

parent 62c6cf0a
...@@ -26,13 +26,10 @@ const Overview: React.FC = () => { ...@@ -26,13 +26,10 @@ const Overview: React.FC = () => {
duration: 80, duration: 80,
} }
const { data, error } = useRequest(getUserInfo, { useRequest(getUserInfo, {
params: { uid: 100 }, params: { uid: 100 },
}) })
console.log('error', error)
console.log('data', data)
return ( return (
<> <>
<TopLeftInfo /> <TopLeftInfo />
......
import { View, Button, Text, } from '@tarojs/components' import { View, Button, Text, } from '@tarojs/components'
import { useState } from 'react' import { memo } from 'react'
import classNames from 'classnames' import classNames from 'classnames'
import { useStoreState } from '@/store/hooks' import { useStoreState } from '@/store/hooks'
import { User } from '../../types' import useToggle from '@/hooks/useToggle'
import UserInfo from './user-info' import UserInfo from './user-info'
import Timing from './timing' import Timing from './timing'
import styles from './index.module.scss' import { User } from '../../types'
interface RankingListProps { import styles from './index.module.scss'
users: User[];
currentUser?: User;
}
const RankList: React.FC<RankingListProps> = ({ users, currentUser }) => { const RankList: React.FC<{ users: User[] }> = ({ users }) => {
const [showAll, setShowAll] = useState(false) const [showAll, toggleShowAll] = useToggle()
const { currentUserInTopThree, topThreeUsers } = useStoreState((state) => state.prepareModel) const { currentUser, currentUserInTopThree, topThreeUsers } = useStoreState((state) => state.prepareModel)
const renderItem = (user: User) => { const renderItem = (user: User) => {
const isCurrentUser = currentUser && currentUser.nickname === user.nickname const isCurrentUser = currentUser && currentUser.nickname === user.nickname
...@@ -27,7 +25,7 @@ const RankList: React.FC<RankingListProps> = ({ users, currentUser }) => { ...@@ -27,7 +25,7 @@ const RankList: React.FC<RankingListProps> = ({ users, currentUser }) => {
) )
} }
const displayUsers = showAll ? users : topThreeUsers const computeUsers = showAll ? users : topThreeUsers
return ( return (
<View className={styles.wrapper}> <View className={styles.wrapper}>
...@@ -43,11 +41,11 @@ const RankList: React.FC<RankingListProps> = ({ users, currentUser }) => { ...@@ -43,11 +41,11 @@ const RankList: React.FC<RankingListProps> = ({ users, currentUser }) => {
)} )}
<View className={styles.list}> <View className={styles.list}>
{displayUsers.map(renderItem)} {computeUsers.map(renderItem)}
</View> </View>
{!showAll && ( {!showAll && (
<Button className={styles.loadMore} onClick={() => setShowAll(!showAll)}> <Button className={styles.loadMore} onClick={() => toggleShowAll()}>
查看更多 查看更多
</Button> </Button>
)} )}
...@@ -55,4 +53,4 @@ const RankList: React.FC<RankingListProps> = ({ users, currentUser }) => { ...@@ -55,4 +53,4 @@ const RankList: React.FC<RankingListProps> = ({ users, currentUser }) => {
) )
} }
export default RankList export default memo(RankList)
import { View, Text } from '@tarojs/components'
import RankList from './rank-list/index'
import { User } from '../types'
const StudyLeagueRank: React.FC<{ users: User[] }> = ({ users }) => {
return (
<View>
<RankList users={users} />
<Text>立即创建</Text>
</View>
)
}
export default StudyLeagueRank
import { useEffect, memo } from 'react' import { useEffect } from 'react'
import { View, Text } from '@tarojs/components'
import Tabs, { type TabItem } from '@/components/Tabs' import Tabs, { type TabItem } from '@/components/Tabs'
import { useStoreState, useStoreActions } from '@/store/hooks' import { useStoreState, useStoreActions } from '@/store/hooks'
import Overview from './components/overview/index' import Overview from './components/overview/index'
import RankList from './components/rank-list/index' import RankList from './components/rank-list/index'
import StudyLeagueRank from './components/study-league-rank'
const Prepare: React.FC = () => { const Prepare: React.FC = () => {
const { currentUser, list } = useStoreState((state) => state.prepareModel) const { list: users } = useStoreState((state) => state.prepareModel)
const refresh = useStoreActions((actions) => actions.prepareModel.refresh) const refresh = useStoreActions((actions) => actions.prepareModel.refresh)
useEffect(() => { useEffect(() => {
refresh() refresh()
}, []) }, [refresh])
console.log('list')
const tabs: TabItem[] = [ const tabs: TabItem[] = [
{ { label: '成都排行榜', children: <RankList users={users} /> },
label: '成都排行榜', { label: '学习部落排行榜', children: <StudyLeagueRank users={users} /> }
children: <RankList users={list} currentUser={currentUser} />
},
{
label: '学习部落排行榜',
children: (
<View>
<RankList users={list} currentUser={currentUser} />
<Text>立即创建</Text>
</View>
)
},
] ]
return ( return (
<View> <>
<Overview /> <Overview />
<Tabs items={tabs} /> <Tabs items={tabs} />
</View> </>
) )
} }
export default memo(Prepare) export default Prepare
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment