Admin-only /bookmarks page for managing entries; homepage now renders public bookmarks as a category-grouped navigation grid (empty state links admin to the manager). Dashboard gains a recent-bookmarks card, dock and main layout get a bookmark entry for admins, and the middleware protects /bookmarks. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import Link from "next/link";
|
|
import { auth } from "@/auth";
|
|
import { Button } from "@/components/ui/button";
|
|
import { signOut } from "@/auth";
|
|
|
|
export default async function MainLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode;
|
|
}) {
|
|
const session = await auth();
|
|
const user = session?.user as any;
|
|
|
|
return (
|
|
<div className="min-h-screen bg-gray-50">
|
|
<header className="border-b bg-white">
|
|
<div className="mx-auto flex max-w-6xl items-center justify-between px-4 py-3">
|
|
<Link href="/" className="text-lg font-bold">
|
|
EvanPage
|
|
</Link>
|
|
<nav className="flex items-center gap-4">
|
|
<Link href="/dashboard" className="text-sm hover:underline">
|
|
仪表盘
|
|
</Link>
|
|
{user?.role === "admin" && (
|
|
<Link href="/bookmarks" className="text-sm hover:underline">
|
|
书签
|
|
</Link>
|
|
)}
|
|
<form
|
|
action={async () => {
|
|
"use server";
|
|
await signOut({ redirectTo: "/login" });
|
|
}}
|
|
>
|
|
<Button variant="ghost" size="sm" type="submit">
|
|
退出
|
|
</Button>
|
|
</form>
|
|
</nav>
|
|
</div>
|
|
</header>
|
|
<main className="mx-auto max-w-6xl px-4 py-6">{children}</main>
|
|
</div>
|
|
);
|
|
}
|