78 lines
2.8 KiB
TypeScript
78 lines
2.8 KiB
TypeScript
|
|
"use client"
|
||
|
|
|
||
|
|
import Link from "next/link"
|
||
|
|
import { usePathname } from "next/navigation"
|
||
|
|
import { LayoutDashboard, FileText, Users, CreditCard, QrCode, Settings, LogOut, ChevronLeft } from "lucide-react"
|
||
|
|
import { useStore } from "@/lib/store"
|
||
|
|
import { useRouter } from "next/navigation"
|
||
|
|
import { useEffect } from "react"
|
||
|
|
|
||
|
|
export default function AdminLayout({ children }: { children: React.ReactNode }) {
|
||
|
|
const pathname = usePathname()
|
||
|
|
const router = useRouter()
|
||
|
|
const { user, isLoggedIn } = useStore()
|
||
|
|
|
||
|
|
// Simple admin check (in real app, use robust auth)
|
||
|
|
useEffect(() => {
|
||
|
|
if (!isLoggedIn) {
|
||
|
|
// router.push("/my") // Commented out for easier development access
|
||
|
|
}
|
||
|
|
}, [isLoggedIn, router])
|
||
|
|
|
||
|
|
const menuItems = [
|
||
|
|
{ icon: LayoutDashboard, label: "数据概览", href: "/admin" },
|
||
|
|
{ icon: FileText, label: "内容管理", href: "/admin/content" },
|
||
|
|
{ icon: Users, label: "用户管理", href: "/admin/users" },
|
||
|
|
{ icon: CreditCard, label: "支付配置", href: "/admin/payment" },
|
||
|
|
{ icon: QrCode, label: "二维码", href: "/admin/qrcodes" },
|
||
|
|
{ icon: Settings, label: "系统设置", href: "/admin/settings" },
|
||
|
|
]
|
||
|
|
|
||
|
|
return (
|
||
|
|
<div className="flex min-h-screen bg-[#0f172a]">
|
||
|
|
{/* Sidebar */}
|
||
|
|
<div className="w-64 bg-[#1e293b] text-white flex flex-col border-r border-gray-800">
|
||
|
|
<div className="p-6 border-b border-gray-800">
|
||
|
|
<h1 className="text-xl font-bold text-[#38bdac]">管理后台</h1>
|
||
|
|
<p className="text-xs text-gray-400 mt-1">Soul创业实验场</p>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<nav className="flex-1 p-4 space-y-2">
|
||
|
|
{menuItems.map((item) => {
|
||
|
|
const isActive = pathname === item.href
|
||
|
|
return (
|
||
|
|
<Link
|
||
|
|
key={item.href}
|
||
|
|
href={item.href}
|
||
|
|
className={`flex items-center gap-3 px-4 py-3 rounded-lg transition-colors ${
|
||
|
|
isActive
|
||
|
|
? "bg-[#38bdac]/10 text-[#38bdac] border border-[#38bdac]/20"
|
||
|
|
: "text-gray-400 hover:bg-gray-800 hover:text-white"
|
||
|
|
}`}
|
||
|
|
>
|
||
|
|
<item.icon className="w-5 h-5" />
|
||
|
|
<span className="text-sm font-medium">{item.label}</span>
|
||
|
|
</Link>
|
||
|
|
)
|
||
|
|
})}
|
||
|
|
</nav>
|
||
|
|
|
||
|
|
<div className="p-4 border-t border-gray-800">
|
||
|
|
<Link
|
||
|
|
href="/my"
|
||
|
|
className="flex items-center gap-3 px-4 py-3 text-gray-400 hover:text-white rounded-lg hover:bg-gray-800 transition-colors"
|
||
|
|
>
|
||
|
|
<LogOut className="w-5 h-5" />
|
||
|
|
<span className="text-sm font-medium">返回前台</span>
|
||
|
|
</Link>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
{/* Main Content */}
|
||
|
|
<div className="flex-1 overflow-auto bg-[#0f172a]">
|
||
|
|
{children}
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
)
|
||
|
|
}
|