38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
"use client"
|
|
|
|
import Link from "next/link"
|
|
import { AuthGuard } from "@/components/auth-guard"
|
|
import { DashboardSidebar } from "@/components/dashboard-sidebar"
|
|
import { Header } from "@/components/header"
|
|
import { Button } from "@/components/ui/button"
|
|
import { useAuthStore } from "@/store/auth"
|
|
|
|
export default function DashboardLayout({ children }: { children: React.ReactNode }) {
|
|
const isAuthenticated = useAuthStore((state) => state.isAuthenticated)
|
|
const currentRole = useAuthStore((state) => state.currentRole)
|
|
|
|
return (
|
|
<div className="flex min-h-screen flex-col">
|
|
<Header />
|
|
<div className="flex flex-1">
|
|
<div className="hidden md:block">
|
|
<DashboardSidebar />
|
|
</div>
|
|
<main className="flex-1 p-6">
|
|
<AuthGuard>
|
|
{isAuthenticated && currentRole === "consumer" ? (
|
|
<div className="flex min-h-[50vh] items-center justify-center">
|
|
<Button asChild>
|
|
<Link href="/">首页</Link>
|
|
</Button>
|
|
</div>
|
|
) : (
|
|
children
|
|
)}
|
|
</AuthGuard>
|
|
</main>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|