chore: init monorepo snapshot

This commit is contained in:
liaibo
2025-11-23 10:55:04 +08:00
commit c70ff52869
941 changed files with 246586 additions and 0 deletions
@@ -0,0 +1,11 @@
import { Skeleton } from "@/components/ui/skeleton";
export default function LoadingDocument() {
return (
<div className="flex h-full flex-col gap-4 px-12 py-8">
<Skeleton className="h-9 w-1/3" />
<Skeleton className="h-4 w-64" />
<Skeleton className="h-[400px] w-full" />
</div>
);
}
@@ -0,0 +1,61 @@
import { notFound, redirect } from "next/navigation";
import { createSupabaseServerClient } from "@/lib/supabase/server";
import { DocumentShell } from "@/components/editor/document-shell";
import type { PageOptionsState, DocumentStats } from "@/types/page-options";
interface DocumentPageProps {
params: Promise<{ id: string }>;
}
export default async function DocumentPage({ params }: DocumentPageProps) {
const { id } = await params;
const supabase = await createSupabaseServerClient();
const {
data: { session },
} = await supabase.auth.getSession();
if (!session) {
redirect("/login");
}
const { data: document } = await supabase
.from("documents")
.select(
"id,title,content,updated_at,workspace_id,wide_layout,use_small_text,show_heading_numbers,show_toc,show_structure,protect_editing,show_word_count,word_count,character_count,block_count",
)
.eq("user_id", session.user.id)
.eq("id", id)
.single();
if (!document) {
notFound();
}
const initialOptions: PageOptionsState = {
wideLayout: document.wide_layout ?? false,
smallText: document.use_small_text ?? false,
showHeadingNumbers: document.show_heading_numbers ?? true,
showToc: document.show_toc ?? false,
showStructure: document.show_structure ?? false,
protectEditing: document.protect_editing ?? false,
showWordCount: document.show_word_count ?? true,
};
const initialStats: DocumentStats = {
wordCount: document.word_count ?? 0,
characterCount: document.character_count ?? 0,
blockCount: document.block_count ?? 0,
};
return (
<DocumentShell
documentId={document.id}
workspaceId={document.workspace_id}
title={document.title}
updatedAt={document.updated_at}
initialContent={document.content}
initialOptions={initialOptions}
initialStats={initialStats}
/>
);
}
+55
View File
@@ -0,0 +1,55 @@
import { redirect } from "next/navigation";
import type { ReactNode } from "react";
import { Sidebar } from "@/components/sidebar/sidebar";
import { Breadcrumb } from "@/components/breadcrumb";
import { BottomToolbar } from "@/components/bottom-toolbar";
import { MobileSidebarTrigger } from "@/components/mobile-sidebar-trigger";
import type { DocumentRecord } from "@/lib/documents";
import { createSupabaseServerClient } from "@/lib/supabase/server";
import { ensureDefaultWorkspace, fetchWorkspaceSummaries } from "@/lib/workspaces";
import { fetchSidebarDataset } from "@/lib/sidebar-tree";
import type { SidebarInitialData } from "@/components/sidebar/types";
import { SearchPalette } from "@/components/search/search-palette";
export default async function AppLayout({ children }: { children: ReactNode }) {
const supabase = await createSupabaseServerClient();
const {
data: { session },
} = await supabase.auth.getSession();
if (!session) {
redirect("/login");
}
await ensureDefaultWorkspace(supabase, session.user.id, session.user.email ?? "我的空间");
const { workspaces, activeWorkspaceId } = await fetchWorkspaceSummaries(supabase, session.user.id);
let documents: DocumentRecord[] = [];
let sidebarInitialData: SidebarInitialData | null = null;
if (activeWorkspaceId) {
const dataset = await fetchSidebarDataset(supabase, activeWorkspaceId);
documents = dataset.documents;
sidebarInitialData = {
activeWorkspaceId,
workspaces,
documents: dataset.documents,
trashedDocuments: dataset.trashedDocuments,
};
}
return (
<div className="flex h-screen bg-white">
{sidebarInitialData && <Sidebar initialData={sidebarInitialData} />}
<div className="flex min-w-0 flex-1 flex-col">
<header className="flex h-10 items-center gap-4 border-b border-[#eeeeee] px-4">
<MobileSidebarTrigger />
<Breadcrumb documents={documents} />
</header>
<main className="flex-1 overflow-hidden bg-white">{children}</main>
<BottomToolbar />
<SearchPalette workspaceId={sidebarInitialData?.activeWorkspaceId ?? null} />
</div>
</div>
);
}