Files
mini-game-ai/src/components/layout/Sidebar.tsx
richarjiang a7449bf49b feat: 实现 Mini Game AI 工具平台
基于 Next.js 15、React 19 和 TypeScript 构建面向小游戏开发者的 AI 赋能工具平台。

主要功能:
- 首页:包含 Hero、功能展示、优势介绍、定价和 CTA 区域
- 三大核心工具:视频转序列帧、图片压缩、音频压缩
- 响应式布局:包含顶部导航、页脚和侧边栏
- 文件上传:支持拖拽上传,使用 react-dropzone
- 进度追踪:实时显示上传和处理进度
- 可配置工具:每个工具都支持自定义参数配置
- 结果预览:支持下载处理后的文件
- 4K 优化:针对大屏幕优化的响应式设计
- API 路由:文件上传和处理的模拟实现

技术栈:
- Next.js 15 (App Router)
- React 19
- TypeScript (严格模式)
- Tailwind CSS(自定义 4K 断点)
- shadcn/ui 组件库
- Framer Motion 动画
- Zustand 状态管理

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-20 22:26:55 +08:00

106 lines
3.2 KiB
TypeScript

"use client";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { motion } from "framer-motion";
import {
Video,
Image,
Music,
Sparkles,
LayoutDashboard,
CreditCard,
Settings,
} from "lucide-react";
import { cn } from "@/lib/utils";
const sidebarNavItems = [
{
title: "Dashboard",
items: [
{ name: "Overview", href: "/dashboard", icon: LayoutDashboard },
],
},
{
title: "Tools",
items: [
{ name: "Video to Frames", href: "/tools/video-frames", icon: Video },
{ name: "Image Compression", href: "/tools/image-compress", icon: Image },
{ name: "Audio Compression", href: "/tools/audio-compress", icon: Music },
],
},
{
title: "AI Tools",
items: [
{ name: "AI Image", href: "/tools/ai-image", icon: Sparkles },
{ name: "AI Audio", href: "/tools/ai-audio", icon: Sparkles },
],
},
{
title: "Account",
items: [
{ name: "Pricing", href: "/pricing", icon: CreditCard },
{ name: "Settings", href: "/settings", icon: Settings },
],
},
];
interface SidebarProps {
className?: string;
}
export function Sidebar({ className }: SidebarProps) {
const pathname = usePathname();
return (
<aside
className={cn(
"fixed left-0 top-16 z-40 h-[calc(100vh-4rem)] w-64 border-r border-border/40 bg-background/95 backdrop-blur",
className
)}
>
<div className="h-full overflow-y-auto py-6 pr-4">
<nav className="space-y-8 px-4">
{sidebarNavItems.map((section) => (
<div key={section.title}>
<h3 className="mb-4 px-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground">
{section.title}
</h3>
<ul className="space-y-1">
{section.items.map((item) => {
const Icon = item.icon;
const isActive = pathname === item.href || pathname?.startsWith(item.href + "/");
return (
<li key={item.name}>
<Link
href={item.href}
className={cn(
"group flex items-center rounded-lg px-3 py-2 text-sm font-medium transition-all",
isActive
? "bg-primary/10 text-primary"
: "text-muted-foreground hover:bg-accent hover:text-accent-foreground"
)}
>
<Icon className={cn("mr-3 h-4 w-4", isActive ? "text-primary" : "")} />
<span className="flex-1">{item.name}</span>
{isActive && (
<motion.div
layoutId="activeIndicator"
className="h-4 w-1 rounded-full bg-primary"
transition={{ type: "spring", stiffness: 300, damping: 30 }}
/>
)}
</Link>
</li>
);
})}
</ul>
</div>
))}
</nav>
</div>
</aside>
);
}