Commit 95b665cd authored by m's avatar m

feat: update

parent 62c6cf0a
......@@ -26,13 +26,10 @@ const Overview: React.FC = () => {
duration: 80,
}
const { data, error } = useRequest(getUserInfo, {
useRequest(getUserInfo, {
params: { uid: 100 },
})
console.log('error', error)
console.log('data', data)
return (
<>
<TopLeftInfo />
......
import { View, Button, Text, } from '@tarojs/components'
import { useState } from 'react'
import { memo } from 'react'
import classNames from 'classnames'
import { useStoreState } from '@/store/hooks'
import { User } from '../../types'
import useToggle from '@/hooks/useToggle'
import UserInfo from './user-info'
import Timing from './timing'
import styles from './index.module.scss'
import { User } from '../../types'
interface RankingListProps {
users: User[];
currentUser?: User;
}
import styles from './index.module.scss'
const RankList: React.FC<RankingListProps> = ({ users, currentUser }) => {
const [showAll, setShowAll] = useState(false)
const { currentUserInTopThree, topThreeUsers } = useStoreState((state) => state.prepareModel)
const RankList: React.FC<{ users: User[] }> = ({ users }) => {
const [showAll, toggleShowAll] = useToggle()
const { currentUser, currentUserInTopThree, topThreeUsers } = useStoreState((state) => state.prepareModel)
const renderItem = (user: User) => {
const isCurrentUser = currentUser && currentUser.nickname === user.nickname
......@@ -27,7 +25,7 @@ const RankList: React.FC<RankingListProps> = ({ users, currentUser }) => {
)
}
const displayUsers = showAll ? users : topThreeUsers
const computeUsers = showAll ? users : topThreeUsers
return (
<View className={styles.wrapper}>
......@@ -43,11 +41,11 @@ const RankList: React.FC<RankingListProps> = ({ users, currentUser }) => {
)}
<View className={styles.list}>
{displayUsers.map(renderItem)}
{computeUsers.map(renderItem)}
</View>
{!showAll && (
<Button className={styles.loadMore} onClick={() => setShowAll(!showAll)}>
<Button className={styles.loadMore} onClick={() => toggleShowAll()}>
查看更多
</Button>
)}
......@@ -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 { View, Text } from '@tarojs/components'
import { useEffect } from 'react'
import Tabs, { type TabItem } from '@/components/Tabs'
import { useStoreState, useStoreActions } from '@/store/hooks'
import Overview from './components/overview/index'
import RankList from './components/rank-list/index'
import StudyLeagueRank from './components/study-league-rank'
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)
useEffect(() => {
refresh()
}, [])
console.log('list')
}, [refresh])
const tabs: TabItem[] = [
{
label: '成都排行榜',
children: <RankList users={list} currentUser={currentUser} />
},
{
label: '学习部落排行榜',
children: (
<View>
<RankList users={list} currentUser={currentUser} />
<Text>立即创建</Text>
</View>
)
},
{ label: '成都排行榜', children: <RankList users={users} /> },
{ label: '学习部落排行榜', children: <StudyLeagueRank users={users} /> }
]
return (
<View>
<>
<Overview />
<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