Files
writer-work-flow/apps/web/app/page.tsx
Yaojia Wang 8389572cbb feat(frontend): 进来即写——落地页「直接开始写」直达空白编辑器,敲字后延迟落库
Phase 0(写作工作台重构):新增 /write 草稿编辑器入口,只有敲入实质正文并停顿后
才懒建占位「未命名草稿」项目并种入首章草稿(useDeferredDraft,双重幂等闸 + 草稿落库
非致命降级),随即 replace 换入完整工作台;空进空出不落库,杜绝孤儿草稿。
落地页 CTA 改为「直接开始写」为主、「先立项」(立项向导)为辅。
2026-07-07 18:18:18 +02:00

83 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Link from "next/link";
import { BookOpen, PenLine, Plus } from "lucide-react";
import { AppShell } from "@/components/AppShell";
import { BackendDownNotice } from "@/components/BackendDownNotice";
import { ProjectLibrary } from "@/components/projects/ProjectLibrary";
import { EmptyState } from "@/components/ui/EmptyState";
import { PageHeader } from "@/components/ui/PageHeader";
import { fetchProjects } from "@/lib/api/server";
import type { ProjectResponse } from "@/lib/api/types";
import { buttonClass } from "@/lib/ui/variants";
// 作品库Dashboard 入口UX §6.1。Server Component 读取。
export default async function DashboardPage() {
let projects: ProjectResponse[] = [];
let loadError = false;
try {
const data = await fetchProjects();
projects = data.projects ?? [];
} catch {
loadError = true;
}
return (
<AppShell>
<div className="mx-auto max-w-5xl px-6 py-10 sm:px-8">
<PageHeader
title="我的作品"
description="从一个灵感进入正文、设定、审稿与验收闭环。"
actions={
<div className="flex flex-wrap items-center gap-2">
<Link
href="/write"
className={buttonClass({ variant: "primary" })}
>
<PenLine className="h-4 w-4" aria-hidden="true" />
</Link>
<Link
href="/projects/new"
className={buttonClass({ variant: "secondary" })}
>
<Plus className="h-4 w-4" aria-hidden="true" />
</Link>
</div>
}
/>
{loadError ? (
<BackendDownNotice />
) : projects.length === 0 ? (
<EmptyState
icon={BookOpen}
title="还没有作品"
description="直接开始写,落笔即成书;或先立项,从一句灵感搭好设定、大纲再动笔。"
action={
<div className="flex flex-wrap items-center justify-center gap-2">
<Link
href="/write"
className={buttonClass({ variant: "primary" })}
>
<PenLine className="h-4 w-4" aria-hidden="true" />
</Link>
<Link
href="/projects/new"
className={buttonClass({ variant: "secondary" })}
>
<Plus className="h-4 w-4" aria-hidden="true" />
</Link>
</div>
}
/>
) : (
<ProjectLibrary projects={projects} />
)}
</div>
</AppShell>
);
}