fix:批量修复了一些问题
This commit is contained in:
+38
-11
@@ -1,13 +1,15 @@
|
||||
/**
|
||||
* 主应用入口
|
||||
*
|
||||
* 整合前台(报纸风格)和后台(暗色管理)的路由。
|
||||
* - / → 先知(Profeto)主站
|
||||
* - /admin/* → 管理后台
|
||||
* 顶层三分区导航:
|
||||
* - 比赛/预测 → 公开,报纸风赛程 + 预测
|
||||
* - 评估 → 只读(后端需 admin 鉴权,未登录引导登录)
|
||||
* - 管理 → 采集/回测/配置等(需登录)
|
||||
*/
|
||||
|
||||
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom'
|
||||
import { ErrorBoundary } from './components/ErrorBoundary'
|
||||
import { useState } from 'react'
|
||||
import Matches from './pages/Matches'
|
||||
import { adminRoutes } from './admin/routes'
|
||||
|
||||
@@ -21,10 +23,34 @@ function dateLine(): string {
|
||||
})
|
||||
}
|
||||
|
||||
/** 顶层导航三分区 */
|
||||
type TopView = 'matches' | 'eval' | 'admin'
|
||||
|
||||
function TopNav({ onNavigate }: { onNavigate: (v: TopView) => void }) {
|
||||
const go = (v: TopView) => {
|
||||
onNavigate(v)
|
||||
const path = v === 'matches' ? '/' : v === 'eval' ? '/admin/eval' : '/admin'
|
||||
window.location.assign(path)
|
||||
}
|
||||
return (
|
||||
<nav className="flex items-center justify-center gap-1 border-b border-ink-200" aria-label="主导航">
|
||||
<button onClick={() => go('matches')} className="tab">
|
||||
<span aria-hidden="true">◇</span> 比赛 / 预测
|
||||
</button>
|
||||
<button onClick={() => go('eval')} className="tab">
|
||||
<span aria-hidden="true">◈</span> 评估
|
||||
</button>
|
||||
<button onClick={() => go('admin')} className="tab">
|
||||
<span aria-hidden="true">⚙</span> 管理
|
||||
</button>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
|
||||
function HomePage() {
|
||||
return (
|
||||
<div className="min-h-screen bg-paper-50">
|
||||
{/* ── 报头:粗线 + 居中刊名 + 报眉 ── */}
|
||||
{/* ── 报头:粗线 + 居中刊名 + 顶层导航 ── */}
|
||||
<header className="masthead-rule">
|
||||
<div className="mx-auto max-w-5xl px-5 sm:px-8">
|
||||
<div className="border-b border-ink-900 py-5 text-center sm:py-6">
|
||||
@@ -40,14 +66,8 @@ function HomePage() {
|
||||
</div>
|
||||
<div className="flex items-center justify-between border-b border-ink-200 py-2 text-2xs text-ink-500">
|
||||
<span>{dateLine()}</span>
|
||||
<a
|
||||
href="/admin"
|
||||
className="flex items-center gap-1.5 text-press hover:text-press-dark transition-colors"
|
||||
>
|
||||
<span aria-hidden="true">⚙</span>
|
||||
管理后台
|
||||
</a>
|
||||
</div>
|
||||
<TopNav onNavigate={() => {}} />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -64,12 +84,18 @@ function HomePage() {
|
||||
)
|
||||
}
|
||||
|
||||
/** 管理入口页:直接导向 /admin,由 AdminLayout 处理鉴权(未登录显示登录页) */
|
||||
function AdminEntry() {
|
||||
return <Navigate to="/admin" replace />
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
<BrowserRouter>
|
||||
<Routes>
|
||||
<Route path="/" element={<HomePage />} />
|
||||
<Route path="/admin" element={<AdminEntry />} />
|
||||
{adminRoutes.map(route => (
|
||||
<Route key={route.path} path={route.path} element={route.element}>
|
||||
{route.children.map(child => (
|
||||
@@ -88,3 +114,4 @@ export default function App() {
|
||||
</ErrorBoundary>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user