fix(Profile): disable uid: 0
This commit is contained in:
parent
dada5c28a7
commit
6fcd54ed34
@ -46,6 +46,7 @@ const server = serve({
|
||||
"/api/user/:uid": {
|
||||
async GET(req) {
|
||||
const uid = req.params.uid;
|
||||
if (uid === '0') return Response.json(null);
|
||||
const profile = await xcxApi.getAdvProfile(uid);
|
||||
return Response.json(profile);
|
||||
},
|
||||
@ -53,6 +54,7 @@ const server = serve({
|
||||
"/api/user/:uid/games": {
|
||||
async GET(req) {
|
||||
const uid = req.params.uid;
|
||||
if (uid === '0') return Response.json([]);
|
||||
const search = new URL(req.url).searchParams;
|
||||
const page = Number(search.get('page')) ?? 0;
|
||||
const resp = await xcxApi.getGameList(uid, page);
|
||||
@ -62,6 +64,7 @@ const server = serve({
|
||||
"/api/user/:uid/tags": {
|
||||
async GET(req) {
|
||||
const uid = req.params.uid;
|
||||
if (uid == '0') return Response.json([]);
|
||||
const profile = await xcxApi.getPlayerTags(uid);
|
||||
return Response.json(profile);
|
||||
},
|
||||
|
||||
@ -4,7 +4,7 @@ import { Avatar, Descriptions, Divider, Flex, FloatButton, Image, Typography } f
|
||||
import { HomeOutlined } from "@ant-design/icons";
|
||||
|
||||
import User from "../components/User";
|
||||
import React from "react";
|
||||
import React, { useMemo } from "react";
|
||||
import { ChangeBackground } from "../components/ChangeBackground";
|
||||
import UserTags from "../components/Tags";
|
||||
import { GameTable } from "../components/GameTable";
|
||||
@ -86,6 +86,10 @@ export default function ProfilePage() {
|
||||
console.debug('profile', profile);
|
||||
const navigate = useNavigate();
|
||||
useTitle(`${profile?.username}${profile?.realname ? ` (${profile?.realname})` : ''} 个人详情`, { restoreOnUnmount: true });
|
||||
const tags = useMemo<React.ReactNode[]>(() =>
|
||||
[profile?.province, profile?.sex, profile?.bg ?? '', ...Object.values(profile?.allCities ?? [])]
|
||||
.filter(Boolean)
|
||||
, [profile]);
|
||||
return (
|
||||
<>
|
||||
<ChangeBackground url={profile?.realpic} />
|
||||
@ -96,11 +100,7 @@ export default function ProfilePage() {
|
||||
<Typography.Text>姓名:{profile?.realname}</Typography.Text>
|
||||
<Typography.Text>积分:{profile?.score}</Typography.Text>
|
||||
<Typography.Text style={{ textAlign: 'center' }}>
|
||||
{
|
||||
([profile?.province, profile?.sex, profile?.bg ?? '', ...Object.values(profile?.allCities ?? [])] as React.ReactNode[])
|
||||
.filter(Boolean)
|
||||
.reduce((a, b) => (<>{a}<Divider orientation="vertical" />{b}</>))
|
||||
}
|
||||
{(tags.length > 0 && tags.reduce((a, b) => (<>{a}<Divider orientation="vertical" />{b}</>)))}
|
||||
</Typography.Text>
|
||||
<Divider>简介</Divider>
|
||||
<Typography.Paragraph>
|
||||
@ -131,7 +131,7 @@ export default function ProfilePage() {
|
||||
</Flex>
|
||||
</Flex>
|
||||
<Honor honors={profile?.honors} />
|
||||
<GameTable uid={profile?.uid} data={profile?.games.data} />
|
||||
<GameTable uid={profile?.uid} data={profile?.games?.data} />
|
||||
</Flex>
|
||||
</>
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user