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.
This commit is contained in:
typist
2025-10-27 23:46:33 +08:00
parent 818a108282
commit 7b67934b80
3 changed files with 41 additions and 5 deletions

View File

@@ -0,0 +1,25 @@
import { Sidebar, SidebarContent, SidebarFooter, SidebarHeader, SidebarMenuButton, SidebarMenuItem } from "@/components/ui/sidebar";
import { tools } from "@/components/tool";
export const AppSidebar = () => (
<Sidebar>
<SidebarHeader>
Lite Kit
</SidebarHeader>
<SidebarContent>
{
tools.map((tool) => (
<SidebarMenuItem key={tool.name}>
<SidebarMenuButton>
{tool.icon}
{tool.name}
</SidebarMenuButton>
</SidebarMenuItem>
))
}
</SidebarContent>
<SidebarFooter>
<a href="mailto:litek@mail.typist.cc">contact us</a>
</SidebarFooter>
</Sidebar>
)

View File

@@ -0,0 +1,8 @@
interface Tool {
name: string;
description: string;
icon: React.ReactNode;
component: React.ReactNode;
}
export const tools: Tool[] = [];

View File

@@ -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: <div>Nohting</div>,
},
{
index: true,
loader: () => {