feat: add basic layout (#3)

Co-authored-by: typist <git@mail.typist.cc>
Reviewed-on: #3
This commit is contained in:
2025-10-27 23:48:33 +08:00
parent f4383d195f
commit 0c54293312
15 changed files with 1775 additions and 3 deletions

48
src/router.tsx Normal file
View File

@@ -0,0 +1,48 @@
import {
createBrowserRouter,
redirect,
RouterProvider,
} from "react-router-dom";
import { Layout } from "./layout";
import { tools } from "@/components/tool";
// 路由配置
const router = createBrowserRouter([
{
path: "",
element: <Layout />,
children: [
{
path: "tools",
children: [
...tools.map((tool) => (
{
path: tool.name,
element: tool.component,
}
)),
{
index: true,
element: null,
},
]
},
]
},
{
index: true,
loader: () => {
return redirect("/tools");
},
},
{
path: "*",
loader: () => {
return redirect("/tools");
},
},
]);
// 路由提供者组件
export const AppRouter = () => <RouterProvider router={router} />;