From 7b67934b806d97c123b774e62bc3cf346f487507 Mon Sep 17 00:00:00 2001 From: typist Date: Mon, 27 Oct 2025 23:46:33 +0800 Subject: [PATCH] feat: enhance routing and sidebar with dynamic tools integration - Added a new AppSidebar component to display tools in the sidebar. - Introduced a tools array in the tool module to manage tool properties. - Updated router configuration to dynamically generate routes for each tool. --- src/components/sidebar/index.tsx | 25 +++++++++++++++++++++++++ src/components/tool/index.tsx | 8 ++++++++ src/router.tsx | 13 ++++++++----- 3 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 src/components/sidebar/index.tsx create mode 100644 src/components/tool/index.tsx diff --git a/src/components/sidebar/index.tsx b/src/components/sidebar/index.tsx new file mode 100644 index 0000000..a1c2680 --- /dev/null +++ b/src/components/sidebar/index.tsx @@ -0,0 +1,25 @@ +import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarMenuButton, SidebarMenuItem } from "@/components/ui/sidebar"; +import { tools } from "@/components/tool"; + +export const AppSidebar = () => ( + + + Lite Kit + + + { + tools.map((tool) => ( + + + {tool.icon} + {tool.name} + + + )) + } + + + contact us + + +) \ No newline at end of file diff --git a/src/components/tool/index.tsx b/src/components/tool/index.tsx new file mode 100644 index 0000000..1ffec6c --- /dev/null +++ b/src/components/tool/index.tsx @@ -0,0 +1,8 @@ +interface Tool { + name: string; + description: string; + icon: React.ReactNode; + component: React.ReactNode; +} + +export const tools: Tool[] = []; \ No newline at end of file diff --git a/src/router.tsx b/src/router.tsx index 0e17d98..72d384c 100644 --- a/src/router.tsx +++ b/src/router.tsx @@ -5,6 +5,7 @@ import { } from "react-router-dom"; import { Layout } from "./layout"; +import { tools } from "@/components/tool"; // 路由配置 const router = createBrowserRouter([ @@ -15,18 +16,20 @@ const router = createBrowserRouter([ { path: "tools", children: [ + ...tools.map((tool) => ( + { + path: tool.name, + element: tool.component, + } + )), { index: true, - loader: () => redirect(`/empty`), + element: null, }, ] }, ] }, - { - path: "empty", - element:
Nohting
, - }, { index: true, loader: () => {