diff --git a/src/components/User.tsx b/src/components/User.tsx index a24b09b..c0c250f 100644 --- a/src/components/User.tsx +++ b/src/components/User.tsx @@ -1,12 +1,12 @@ -import { Link } from "react-router"; - +import { useHref } from 'react-router'; interface Props { name: string; uid?: string; } export default function User(props: Props) { + const href = useHref(`/profile/${props.uid}`); if (!Number(props.uid)) return {props.name} return ( - {props.name} + {props.name} ); } \ No newline at end of file diff --git a/src/page/EventPage.tsx b/src/page/EventPage.tsx index 1ab60dc..b4e16d2 100644 --- a/src/page/EventPage.tsx +++ b/src/page/EventPage.tsx @@ -23,11 +23,8 @@ export default function EventPage() { }, [members]); useTitle(game.title, { restoreOnUnmount: true }); return ( -
- - navigate('/')}/> - {game.title} - +
+ {game.title}
); diff --git a/src/page/FavPlayersPage.tsx b/src/page/FavPlayersPage.tsx index dbab90a..64e54ec 100644 --- a/src/page/FavPlayersPage.tsx +++ b/src/page/FavPlayersPage.tsx @@ -4,14 +4,14 @@ import { useNavigate } from "react-router"; import { useMemo, useState } from "react"; enum SortType { - DEFAULT = '默认排序', + DEFAULT = '注册时间', SCORE_UP = '积分升序', SCORE_DOWN = '积分降序', } export function FavePlayersPage() { const { favMap } = useFavPlayerStore(state => state); - const [sortType, setSortType] = useState(SortType.SCORE_DOWN); + const [sortType, setSortType] = useState(SortType.DEFAULT); const list = useMemo(() => { const l = Object.values(favMap); switch (sortType) { @@ -33,8 +33,9 @@ export function FavePlayersPage() { value={sortType} onChange={e => setSortType(e)} options={[ - SortType.SCORE_DOWN, + SortType.DEFAULT, SortType.SCORE_UP, + SortType.SCORE_DOWN, ]} />
diff --git a/src/page/ProfilePage.tsx b/src/page/ProfilePage.tsx index 7a0e40a..eb7380c 100644 --- a/src/page/ProfilePage.tsx +++ b/src/page/ProfilePage.tsx @@ -1,15 +1,15 @@ +import React, { useEffect, useMemo } from "react"; import { Link, useLoaderData, useNavigate } from "react-router"; -import type { XCXProfile } from "../types/profile"; import { Avatar, Descriptions, Divider, Flex, FloatButton, Image, Typography } from "antd"; import { HomeOutlined } from "@ant-design/icons"; - +import { useTitle } from "ahooks"; +import type { XCXProfile } from "../types/profile"; import User from "../components/User"; -import React, { useMemo } from "react"; import { ChangeBackground } from "../components/ChangeBackground"; import UserTags from "../components/Tags"; import { GameTable } from "../components/GameTable"; -import { useTitle } from "ahooks"; import { FavButton } from "../components/FavButton"; +import { useFavPlayerStore } from "../store/useFavPlayerStore"; function Honor(props: { honors?: XCXProfile['honors'] }) { if (!props.honors?.length) return null; @@ -91,6 +91,17 @@ export default function ProfilePage() { [profile?.province, profile?.sex, profile?.bg ?? '', ...Object.values(profile?.allCities ?? [])] .filter(Boolean) , [profile]); + const favUser = useMemo(() => ({ + uid, + score: profile.score, + name: profile.username, + realname: profile.realname, + avatar: profile.realpic + }), [profile]); + useEffect(() => { + if (!useFavPlayerStore.getState().isFav(uid)) return; + useFavPlayerStore.getState().fav(favUser); + }, [favUser]); return ( <>