- 添加 main.tsx 应用入口 - 添加 App.tsx 根组件 - 配置路由系统(React Router v7) - 添加状态管理(Zustand) - 定义 TypeScript 类型
56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
import { createBrowserRouter, Navigate } from 'react-router-dom';
|
|
import { MainLayout } from '../layouts/MainLayout';
|
|
import { Dashboard } from '../pages/Dashboard';
|
|
import { Upload } from '../pages/Upload';
|
|
import { Gallery } from '../pages/Gallery';
|
|
import { Links } from '../pages/Links';
|
|
import { Tools } from '../pages/Tools';
|
|
import { Storage } from '../pages/Storage';
|
|
import { Analytics } from '../pages/Analytics';
|
|
import { Settings } from '../pages/Settings';
|
|
|
|
export const router = createBrowserRouter([
|
|
{
|
|
path: '/',
|
|
element: <MainLayout />,
|
|
children: [
|
|
{
|
|
index: true,
|
|
element: <Navigate to="/dashboard" replace />,
|
|
},
|
|
{
|
|
path: 'dashboard',
|
|
element: <Dashboard />,
|
|
},
|
|
{
|
|
path: 'upload',
|
|
element: <Upload />,
|
|
},
|
|
{
|
|
path: 'gallery',
|
|
element: <Gallery />,
|
|
},
|
|
{
|
|
path: 'links',
|
|
element: <Links />,
|
|
},
|
|
{
|
|
path: 'tools',
|
|
element: <Tools />,
|
|
},
|
|
{
|
|
path: 'storage',
|
|
element: <Storage />,
|
|
},
|
|
{
|
|
path: 'analytics',
|
|
element: <Analytics />,
|
|
},
|
|
{
|
|
path: 'settings',
|
|
element: <Settings />,
|
|
},
|
|
],
|
|
},
|
|
]);
|