my-kaiqiuwang/src/routes.tsx
kyuuseiryuu 4b69ed3b84 refactor(front-end): switch to web-based map navigation and update layouts
- Update `openMapDirection` to `openWebMapRaw` in `utils/front.ts` to open
  maps in a new browser tab (`_blank`) using raw WGS-84 coordinates.
- Adjust URL schemes for Google, AMap, Baidu, Tencent, and Apple Maps to
  support direct web navigation with `coordinate` parameters.
- Update `ClubSummary.tsx` to use `openWebMapRaw` and change the map button
  label from "Navigation" to "View Location" with a new icon.
- Add `padding-bottom` to `AppBar.tsx` in `AppBarLayout.tsx` to accommodate
  the increased bottom padding required by the updated AppBar styling.
- Remove the "Home" FloatButton from `ProfilePage.tsx` and update `routes.tsx`
  to remove the unused `ActionButtonLayout` import.
- Update navigation handlers in `AppBar.tsx` to use `replace: true` for smoother
  state management without creating new browser history entries.
2026-03-16 02:04:06 +09:00

95 lines
2.9 KiB
TypeScript

import { createBrowserRouter } from "react-router";
import ProfilePage from "./page/ProfilePage";
import EventPage from "./page/EventPage";
import type { MatchInfo, XCXMember } from "./types";
import { FindUserPage } from "./page/FindUserPage";
import { FavePlayersPage } from "./page/FavPlayersPage";
import { UserCenter } from "./page/UserCenter";
import { CallbackPage } from "./page/Logto/Callback";
import App from "./App";
import { ClubEventsPage } from "./page/ClubEvents";
import { HydrateFallback } from "./components/HydrateFallback";
import { AppBarLayout } from './components/Layout';
export const route = createBrowserRouter([
{
path: '/',
element: <AppBarLayout />,
children: [
{
path: '',
index: true,
Component: App,
HydrateFallback: () => <HydrateFallback />
},
{
path: '/club/:id',
Component: ClubEventsPage,
HydrateFallback: () => <HydrateFallback />,
loader: async ({ params }) => {
const id = params.id;
const [info] = await Promise.all([
fetch(`/api/club/${id}`).then(r => r.json()),
]);
return { info };
},
},
{
path: '/fav-players',
Component: FavePlayersPage,
},
{
path: '/event/:matchId',
loader: async ({ params }) => {
const info: MatchInfo = await (await fetch(`/api/match/${params.matchId}`)).json();
const members = info.itemId
? await (await fetch(`/api/match/${params.matchId}/${info.itemId}`)).json()
: info.players.map((e, i) => ({
number: i + 1,
uid: e.uid,
name: e.name,
score: e.score,
realname: e.name,
} as XCXMember));
const uids = info.players.map(e => e.uid);
const uidScore = await fetch(`/api/user/nowScores`, {
method: "POST",
body: JSON.stringify({ uids }),
});
return { info, members, uidScore: new Map(Object.entries(await uidScore.json())) };
},
Component: EventPage,
HydrateFallback: () => <HydrateFallback />
},
{
path: 'profile/:uid',
loader: async ({ params }) => {
const { uid } = params;
const profile = await (await fetch(`/api/user/${uid}`)).json();
const tags = await (await fetch(`/api/user/${uid}/tags`)).json();
return { profile, uid, tags };
},
Component: ProfilePage,
HydrateFallback: () => <HydrateFallback />
},
{
path: 'find',
Component: FindUserPage,
},
{
path: 'user-center',
Component: UserCenter,
},
{
path: 'auth',
children: [
{
path: 'callback',
Component: CallbackPage,
},
],
},
],
},
]);