refactor(dashboard): extract RoleGuard and unify mobile nav with Button
This commit is contained in:
@@ -1,16 +1,11 @@
|
||||
"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"
|
||||
import { RoleGuard } from "@/components/role-guard"
|
||||
|
||||
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 />
|
||||
@@ -20,15 +15,7 @@ export default function DashboardLayout({ children }: { children: React.ReactNod
|
||||
</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
|
||||
)}
|
||||
<RoleGuard>{children}</RoleGuard>
|
||||
</AuthGuard>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user