feat: 侧边栏可点击折叠/展开

顶栏左侧新增切换按钮,点击后左侧菜单在 w-60↔w-0 间平滑伸缩隐藏。
折叠状态通过 SidebarProvider(context) 在侧边栏与顶栏间共享。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-11 22:56:04 +08:00
co-authored by Claude Opus 4.8
parent d123d1e46d
commit 2c337c7d62
4 changed files with 76 additions and 22 deletions
+22 -19
View File
@@ -2,6 +2,7 @@ import { redirect } from "next/navigation";
import { auth } from "@/lib/auth";
import { Sidebar } from "@/components/app/sidebar";
import { Topbar } from "@/components/app/topbar";
import { SidebarProvider } from "@/components/app/sidebar-context";
import { brand, copyright } from "@/lib/brand";
export default async function DashboardLayout({
@@ -14,25 +15,27 @@ export default async function DashboardLayout({
const u = session.user;
return (
<div className="flex h-screen overflow-hidden">
<Sidebar />
<div className="flex min-w-0 flex-1 flex-col">
<Topbar
user={{
name: u.name,
username: u.username,
roles: u.roles,
image: null, // 旧 face 为老站点相对路径,统一用文字头像
}}
/>
<main className="flex-1 overflow-y-auto">
<div className="p-6">{children}</div>
<footer className="flex items-center justify-between border-t px-6 py-4 text-xs text-[var(--color-muted-foreground)]">
<span>{copyright()}</span>
<span>{brand.name} · {brand.tagline}</span>
</footer>
</main>
<SidebarProvider>
<div className="flex h-screen overflow-hidden">
<Sidebar />
<div className="flex min-w-0 flex-1 flex-col">
<Topbar
user={{
name: u.name,
username: u.username,
roles: u.roles,
image: null, // 旧 face 为老站点相对路径,统一用文字头像
}}
/>
<main className="flex-1 overflow-y-auto">
<div className="p-6">{children}</div>
<footer className="flex items-center justify-between border-t px-6 py-4 text-xs text-[var(--color-muted-foreground)]">
<span>{copyright()}</span>
<span>{brand.name} · {brand.tagline}</span>
</footer>
</main>
</div>
</div>
</div>
</SidebarProvider>
);
}