nomadro/apps/com/admin/src/App.tsx
Eric 308974bf5e Harden platform upgrade: ops admin, live config, shared service proxy, and smoke deploys.
Ship Operations console polish, PocketBase social fixtures, and portal join-leads without local DBs or probe scripts.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-05 01:20:55 +08:00

137 lines
5.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { lazy, Suspense } from 'react'
import { Navigate, Route, Routes, useParams } from 'react-router-dom'
import { getToken } from './api/client'
import { readLane } from './lib/lane'
import Login from './pages/Login'
import ModuleSelect from './pages/ModuleSelect'
import WebLayout from './components/WebLayout'
const Docs = lazy(() => import('./pages/Docs'))
const Switches = lazy(() => import('./pages/Switches'))
const Events = lazy(() => import('./pages/Events'))
const Orders = lazy(() => import('./pages/Orders'))
const Users = lazy(() => import('./pages/Users'))
const Ntfy = lazy(() => import('./pages/Ntfy'))
const Social = lazy(() => import('./pages/Social'))
const SocialDetail = lazy(() => import('./pages/SocialDetail'))
const Blog = lazy(() => import('./pages/Blog'))
const Operations = lazy(() => import('./pages/Operations'))
import LaneHub, { type LaneKey } from './pages/LaneHub'
/**
* admin.nomadro.com — 游民社区运营台
* 登录 → /{lane}/social/overview(社区优先)
*/
function Private({ children }: { children: React.ReactNode }) {
if (!getToken()) return <Navigate to="/login" replace />
return <>{children}</>
}
function LaneGuard({ children }: { children: React.ReactNode }) {
const { lane } = useParams()
if (lane !== 'cn' && lane !== 'intl') return <Navigate to="/" replace />
return <>{children}</>
}
function LaneHome() {
const { lane } = useParams()
return <LaneHub lane={lane as LaneKey} />
}
function HomeRedirect() {
const lane = readLane()
return <Navigate to={`/${lane}/social/overview`} replace />
}
export default function App() {
return (
<Suspense fallback={<div className="com-empty" role="status">正在加载工作区…</div>}><Routes>
<Route path="/login" element={<Login />} />
<Route
path="/"
element={
<Private>
<HomeRedirect />
</Private>
}
/>
<Route
path="/modules"
element={
<Private>
<ModuleSelect />
</Private>
}
/>
<Route
path="/:lane"
element={
<Private>
<LaneGuard>
<WebLayout />
</LaneGuard>
</Private>
}
>
<Route index element={<Navigate to="social/overview" replace />} />
<Route path="audience" element={<LaneHome />} />
<Route path="operations" element={<Operations />} />
<Route path="switches" element={<Switches />} />
<Route path="social" element={<Navigate to="overview" replace />} />
<Route path="social/overview" element={<Social />} />
<Route path="social/roster" element={<Social />} />
<Route path="social/messages" element={<Social />} />
<Route path="social/reviews" element={<Social />} />
<Route path="social/meetupReviews" element={<Social />} />
<Route path="social/gigs" element={<Social />} />
<Route path="social/skills" element={<Social />} />
<Route path="social/liveness" element={<Social />} />
<Route path="social/coffee" element={<Social />} />
<Route path="social/trips" element={<Social />} />
<Route path="social/reports" element={<Social />} />
<Route path="social/blocks" element={<Social />} />
<Route path="social/files" element={<Social />} />
<Route path="social/feedback" element={<Social />} />
<Route path="social/archives" element={<Social />} />
<Route path="social/joins" element={<Social />} />
<Route path="social/catalog" element={<Social />} />
<Route path="social/roster/:id" element={<SocialDetail />} />
<Route path="social/messages/:id" element={<SocialDetail />} />
<Route path="social/reviews/:id" element={<SocialDetail />} />
<Route path="social/meetupReviews/:id" element={<SocialDetail />} />
<Route path="social/gigs/:id" element={<SocialDetail />} />
<Route path="social/gigApps/:id" element={<SocialDetail />} />
<Route path="social/skills/:id" element={<SocialDetail />} />
<Route path="social/liveness/:id" element={<SocialDetail />} />
<Route path="social/coffee/:id" element={<SocialDetail />} />
<Route path="social/trips/:id" element={<SocialDetail />} />
<Route path="social/reports/:id" element={<SocialDetail />} />
<Route path="social/blocks/:id" element={<SocialDetail />} />
<Route path="social/files/:id" element={<SocialDetail />} />
<Route path="social/feedback/:id" element={<SocialDetail />} />
<Route path="social/joins/:id" element={<SocialDetail />} />
<Route path="social/archives/:id" element={<SocialDetail />} />
<Route path="social/:section" element={<Social />} />
<Route path="blog" element={<Blog />} />
<Route path="events" element={<Events />} />
<Route path="orders" element={<Orders />} />
<Route path="users" element={<Users />} />
<Route path="ntfy" element={<Ntfy />} />
<Route path="docs" element={<Docs />} />
</Route>
<Route path="/audience" element={<Navigate to="/" replace />} />
<Route path="/switches" element={<Navigate to="/" replace />} />
<Route path="/events" element={<Navigate to="/" replace />} />
<Route path="/orders" element={<Navigate to="/" replace />} />
<Route path="/users" element={<Navigate to="/" replace />} />
<Route path="/ntfy" element={<Navigate to="/" replace />} />
<Route path="/docs" element={<Navigate to="/" replace />} />
<Route path="*" element={<Navigate to="/" replace />} />
</Routes></Suspense>
)
}