feat(Profile): uid param

This commit is contained in:
kyuuseiryuu 2026-02-10 16:00:54 +09:00
parent 6fcd54ed34
commit 5d668b2078
2 changed files with 6 additions and 4 deletions

View File

@ -49,7 +49,9 @@ const route = createBrowserRouter([
{
path: 'profile/:uid',
loader: async ({ params }) => {
return fetch(`/api/user/${params.uid}`);
const { uid } = params;
const profile = await (await fetch(`/api/user/${uid}`)).json();
return { profile, uid };
},
Component: ProfilePage,
HydrateFallback: () => <HydrateFallback />

View File

@ -82,7 +82,7 @@ function PlayerList(props: { title: string; names?: string[]; uids?: string[] })
}
export default function ProfilePage() {
const profile = useLoaderData<XCXProfile | null>();
const { profile, uid } = useLoaderData<{ profile: XCXProfile; uid: string }>();
console.debug('profile', profile);
const navigate = useNavigate();
useTitle(`${profile?.username}${profile?.realname ? ` (${profile?.realname})` : ''} 个人详情`, { restoreOnUnmount: true });
@ -106,7 +106,7 @@ export default function ProfilePage() {
<Typography.Paragraph>
{profile?.description}
</Typography.Paragraph>
<UserTags uid={profile?.uid} />
<UserTags uid={uid} />
<Raket profile={profile} />
<Flex wrap gap={24} justify="center">
<Flex vertical align="center">
@ -131,7 +131,7 @@ export default function ProfilePage() {
</Flex>
</Flex>
<Honor honors={profile?.honors} />
<GameTable uid={profile?.uid} data={profile?.games?.data} />
<GameTable uid={uid} data={profile?.games?.data} />
</Flex>
</>
);