From 6fcd54ed34b532b3a15ff8a0199a8947ce540e3f Mon Sep 17 00:00:00 2001 From: kyuuseiryuu Date: Tue, 10 Feb 2026 15:15:08 +0900 Subject: [PATCH] fix(Profile): disable uid: 0 --- src/index.tsx | 3 +++ src/page/ProfilePage.tsx | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index dd67bba..23b3dc8 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -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); }, diff --git a/src/page/ProfilePage.tsx b/src/page/ProfilePage.tsx index a8caf9c..ce08191 100644 --- a/src/page/ProfilePage.tsx +++ b/src/page/ProfilePage.tsx @@ -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(() => + [profile?.province, profile?.sex, profile?.bg ?? '', ...Object.values(profile?.allCities ?? [])] + .filter(Boolean) + , [profile]); return ( <> @@ -96,11 +100,7 @@ export default function ProfilePage() { 姓名:{profile?.realname} 积分:{profile?.score} - { - ([profile?.province, profile?.sex, profile?.bg ?? '', ...Object.values(profile?.allCities ?? [])] as React.ReactNode[]) - .filter(Boolean) - .reduce((a, b) => (<>{a}{b})) - } + {(tags.length > 0 && tags.reduce((a, b) => (<>{a}{b})))} 简介 @@ -131,7 +131,7 @@ export default function ProfilePage() { - + );