ai-chatbot/app/(admin)/layout.tsx
Your Name 2a793dcbba
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
fix: hide video canvas entry when disabled
2026-04-15 21:25:24 +08:00

59 lines
2.0 KiB
TypeScript

import { auth } from "@/app/(auth)/auth";
import { TopNavbar } from "@/components/top-navbar";
import { getSiteSettings, getNavLinks, getTutorialVideos } from "@/lib/db/queries";
export default async function AdminLayout({
children,
}: {
children: React.ReactNode;
}) {
const [session, siteSettings, navLinks, tutorialVideos] = await Promise.all([
auth(),
getSiteSettings(),
getNavLinks(),
getTutorialVideos(),
]);
const settingsHref =
session?.user?.type === "admin"
? "/settings"
: session?.user?.type === "agent_admin"
? "/settings/agent-workflow"
: null;
return (
<div className="flex min-h-screen flex-col bg-background">
<TopNavbar
siteName={siteSettings.siteName}
siteLogo={siteSettings.siteLogo || undefined}
siteLogoDark={siteSettings.siteLogoDark || undefined}
isAdmin={session?.user?.type === "admin" || session?.user?.type === "agent_admin"}
settingsHref={settingsHref}
customLinks={navLinks.map((link) => ({
id: link.id,
name: link.name,
url: link.url,
order: link.order,
toolboxGroup: link.toolboxGroup || 1,
}))}
toolbox1Name={siteSettings.toolbox1Name || "工具箱"}
toolbox1Enabled={siteSettings.toolbox1Enabled ?? true}
toolbox2Name={siteSettings.toolbox2Name || "工具箱2"}
toolbox2Enabled={siteSettings.toolbox2Enabled ?? false}
tutorialVideos={tutorialVideos.map(v => ({
id: v.id,
title: v.title,
videoUrl: v.videoUrl,
coverUrl: v.coverUrl,
description: v.description,
order: v.order,
}))}
tutorialEnabled={siteSettings.tutorialEnabled ?? false}
rankingEnabled={siteSettings.rankingEnabled ?? true}
productPlanningEnabled={(siteSettings as any).productPlanningEnabled ?? true}
videoCanvasEnabled={(siteSettings as any).videoCanvasEnabled ?? true}
/>
<div className="flex-1 pl-16">{children}</div>
</div>
);
}