Files
mnote/wolai-frontend/src/app/(app)/layout.tsx
T

42 lines
1.7 KiB
TypeScript
Raw Normal View History

2025-11-23 10:55:04 +08:00
import { redirect } from "next/navigation";
import type { ReactNode } from "react";
import { Sidebar } from "@/components/sidebar/sidebar";
2026-04-13 19:21:42 +08:00
import { GlobalAiAgentHost } from "@/components/ai-agent/GlobalAiAgentHost";
2025-11-23 10:55:04 +08:00
import { Breadcrumb } from "@/components/breadcrumb";
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger";
import { SearchPalette } from "@/components/search/search-palette";
2026-01-17 10:12:53 +08:00
import { isConvexEnabled } from "@/lib/convex/enabled";
2026-01-18 19:01:31 +08:00
import { getAuthedConvexClient } from "@/lib/convex/route";
2026-04-14 13:22:29 +08:00
import { loadSidebarDataFromConvex } from "@/lib/server/sidebar-data";
2025-11-23 10:55:04 +08:00
export default async function AppLayout({ children }: { children: ReactNode }) {
2026-01-17 10:12:53 +08:00
if (isConvexEnabled()) {
2026-01-18 19:01:31 +08:00
const { auth, client } = await getAuthedConvexClient();
2026-04-14 13:22:29 +08:00
const {
documents,
sidebarInitialData,
} = await loadSidebarDataFromConvex({
client,
userId: auth.userId,
2026-01-17 10:12:53 +08:00
fallbackName: auth.name ?? auth.email ?? "我的空间",
});
return (
2026-01-18 19:01:31 +08:00
<div className="flex h-screen w-full overflow-hidden bg-wolai-bg text-wolai-text-primary">
2026-01-17 10:12:53 +08:00
{sidebarInitialData && <Sidebar initialData={sidebarInitialData} />}
2026-01-18 19:01:31 +08:00
<div className="flex min-w-0 flex-1 flex-col h-full bg-white relative overflow-hidden">
<header className="h-[44px] w-full flex items-center px-4 text-wolai-text-secondary text-sm bg-white/80 backdrop-blur-sm sticky top-0 z-50">
2026-01-17 10:12:53 +08:00
<MobileSidebarTrigger />
<Breadcrumb documents={documents} />
</header>
<main className="flex-1 overflow-hidden bg-white">{children}</main>
<SearchPalette workspaceId={sidebarInitialData?.activeWorkspaceId ?? null} />
2026-04-13 19:21:42 +08:00
<GlobalAiAgentHost />
2026-01-17 10:12:53 +08:00
</div>
</div>
);
}
2026-01-18 19:01:31 +08:00
redirect("/login");
2025-11-23 10:55:04 +08:00
}