- 新增订单查询与发货结果推送开放接口,支持 can_ship 与幂等 - 鉴权采用 X-Api-Key + Timestamp + Nonce + HMAC-SHA256 签名 - 订单扩展发货字段与 ship_logs,管理端增加发货记录与开放文档页
95 lines
2.4 KiB
TypeScript
95 lines
2.4 KiB
TypeScript
import { BrowserRouter, Navigate, Route, Routes } from 'react-router-dom'
|
|
import { ConfigProvider, App as AntdApp } from 'antd'
|
|
import zhCN from 'antd/locale/zh_CN'
|
|
import { AuthProvider, useAuth } from './store/auth'
|
|
import MainLayout from './layouts/MainLayout'
|
|
import Login from './pages/Login'
|
|
import Register from './pages/Register'
|
|
import Dashboard from './pages/Dashboard'
|
|
import Skins from './pages/Skins'
|
|
import Orders from './pages/Orders'
|
|
import Distributors from './pages/Distributors'
|
|
import ShipLogs from './pages/ShipLogs'
|
|
import OpenApiDocs from './pages/OpenApiDocs'
|
|
import type { ReactNode } from 'react'
|
|
|
|
function PrivateRoute({ children }: { children: ReactNode }) {
|
|
const { token } = useAuth()
|
|
if (!token) return <Navigate to="/login" replace />
|
|
return <>{children}</>
|
|
}
|
|
|
|
function AdminRoute({ children }: { children: ReactNode }) {
|
|
const { isAdmin } = useAuth()
|
|
if (!isAdmin) return <Navigate to="/" replace />
|
|
return <>{children}</>
|
|
}
|
|
|
|
function AppRoutes() {
|
|
return (
|
|
<Routes>
|
|
<Route path="/login" element={<Login />} />
|
|
<Route path="/register" element={<Register />} />
|
|
<Route
|
|
path="/"
|
|
element={
|
|
<PrivateRoute>
|
|
<MainLayout />
|
|
</PrivateRoute>
|
|
}
|
|
>
|
|
<Route index element={<Dashboard />} />
|
|
<Route path="skins" element={<Skins />} />
|
|
<Route path="orders" element={<Orders />} />
|
|
<Route
|
|
path="distributors"
|
|
element={
|
|
<AdminRoute>
|
|
<Distributors />
|
|
</AdminRoute>
|
|
}
|
|
/>
|
|
<Route
|
|
path="ship-logs"
|
|
element={
|
|
<AdminRoute>
|
|
<ShipLogs />
|
|
</AdminRoute>
|
|
}
|
|
/>
|
|
<Route
|
|
path="open-api"
|
|
element={
|
|
<AdminRoute>
|
|
<OpenApiDocs />
|
|
</AdminRoute>
|
|
}
|
|
/>
|
|
</Route>
|
|
<Route path="*" element={<Navigate to="/" replace />} />
|
|
</Routes>
|
|
)
|
|
}
|
|
|
|
export default function App() {
|
|
return (
|
|
<ConfigProvider
|
|
locale={zhCN}
|
|
theme={{
|
|
token: {
|
|
colorPrimary: '#1677ff',
|
|
borderRadius: 6,
|
|
},
|
|
}}
|
|
>
|
|
<AntdApp>
|
|
<AuthProvider>
|
|
<BrowserRouter>
|
|
<AppRoutes />
|
|
</BrowserRouter>
|
|
</AuthProvider>
|
|
</AntdApp>
|
|
</ConfigProvider>
|
|
)
|
|
}
|