diff --git a/src/App.tsx b/src/App.tsx index 06d9a57..83e6d54 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,20 +2,20 @@ import { useCallback } from "react"; import { ClubSelector } from "./components/GameSelector"; import type { IEventInfo } from "./types"; import { useNavigate } from "react-router"; +import { FloatButton, Typography } from "antd"; +import { SearchOutlined } from "@ant-design/icons"; import "./index.css"; -import { FindUserButton } from "./components/FindUser"; export function App() { const navigate = useNavigate(); const handleGameClick = useCallback(async (game: IEventInfo) => { navigate(`/event/${game.matchId}`); }, []); - return (
-

开球网比赛分组预测

+ 开球网比赛分组预测 - + } onClick={() => navigate('/find')} />
); } diff --git a/src/frontend.tsx b/src/frontend.tsx index 920ecb1..70f1a9f 100644 --- a/src/frontend.tsx +++ b/src/frontend.tsx @@ -14,6 +14,7 @@ import { createBrowserRouter, RouterProvider, Outlet, useNavigation } from "reac import ProfilePage from "./page/ProfilePage"; import EventPage from "./page/EventPage"; import type { MatchInfo, XCXMember } from "./types"; +import { FindUserPage } from "./page/FindUserPage"; const elem = document.getElementById("root")!; @@ -58,6 +59,10 @@ const route = createBrowserRouter([ }, ], }, + { + path: 'find', + Component: FindUserPage, + } ]); function HydrateFallback() { diff --git a/src/components/FindUser/index.tsx b/src/page/FindUserPage.tsx similarity index 75% rename from src/components/FindUser/index.tsx rename to src/page/FindUserPage.tsx index 28d3361..fa82f3a 100644 --- a/src/components/FindUser/index.tsx +++ b/src/page/FindUserPage.tsx @@ -1,32 +1,21 @@ -import { SearchOutlined } from "@ant-design/icons"; import { useLocalStorageState, useRequest } from "ahooks"; -import { FloatButton, Drawer, Input, Table } from "antd"; -import { useState } from "react"; -import type { XCXFindUser, XCXFindUserResp } from "../../types"; -import User from "../User"; -import { SEX } from "../../utils"; +import { Input, Table, Spin, Typography, Flex, Space } from "antd"; +import type { XCXFindUser, XCXFindUserResp } from "../types"; +import User from "../components/User"; +import { SEX } from "../utils"; import dayjs from "dayjs"; -export function FindUserButton() { - const [open, setOpen] = useState(false); +export function FindUserPage() { const [searchKey, setSearchKey] = useLocalStorageState('findUser:searchKey'); const findUserReq = useRequest(async (page: number = 1) => { const findOutUsers: XCXFindUserResp = await (await fetch(`/api/user/find?page=${page}&key=${searchKey}`)).json(); return findOutUsers; }, { manual: true, refreshDeps: [searchKey], cacheKey: 'findUser:result' }); return ( - <> - } - onClick={() => setOpen(true)} - /> - setOpen(false)} - loading={findUserReq.loading} - size="80vh" - > +
+ 查找用户 + + e.uid} dataSource={findUserReq.data?.data} pagination={{ @@ -64,7 +54,8 @@ export function FindUserButton() { SEX[sex]} /> year !== '0' ? dayjs().diff(dayjs(year), 'year') : '-'} />
- - +
+
+
); } \ No newline at end of file diff --git a/src/services/xcxApi.ts b/src/services/xcxApi.ts index 443cc93..ae57457 100644 --- a/src/services/xcxApi.ts +++ b/src/services/xcxApi.ts @@ -52,7 +52,7 @@ export class XCXAPI { return (await this.#fetch<{ data: GamesData[] }>(url))?.data; } async findUser(key: string = '', page: number = 1) { - if (!key) return; + if (!key) return null; const url = `/api/user/lists?page=${page}&key=${key}`; return (await this.#fetch(url)); }