"use client"; import Link from "next/link"; import { Clock3, LayoutGrid, List, Plus, Search } from "lucide-react"; import { useEffect, useMemo, useState, type ReactNode } from "react"; import { ProjectCard } from "@/components/ProjectCard"; import { Button } from "@/components/ui/Button"; import { EmptyState } from "@/components/ui/EmptyState"; import { Select } from "@/components/ui/Select"; import { TextInput } from "@/components/ui/TextInput"; import type { ProjectResponse } from "@/lib/api/types"; import { filterProjects, type ProjectFilter, type ProjectSort, type ProjectViewMode, } from "@/lib/projects/projects"; import { buttonClass, cn } from "@/lib/ui/variants"; interface ProjectLibraryProps { projects: ProjectResponse[]; } const VIEW_STORAGE_KEY = "ww.project_view_mode"; export function ProjectLibrary({ projects }: ProjectLibraryProps) { const [search, setSearch] = useState(""); const [filter, setFilter] = useState("all"); const [sort, setSort] = useState("updated_at"); const [viewMode, setViewMode] = useState("cards"); useEffect(() => { const saved = window.localStorage.getItem(VIEW_STORAGE_KEY); if (saved === "cards" || saved === "compact") setViewMode(saved); }, []); const setView = (value: ProjectViewMode): void => { setViewMode(value); window.localStorage.setItem(VIEW_STORAGE_KEY, value); }; const visibleProjects = useMemo( () => filterProjects(projects, { search, filter, sort }), [projects, search, filter, sort], ); return (
setView("cards")} > setView("compact")} >

{visibleProjects.length === 0 ? (
} /> ) : viewMode === "cards" ? (
    {visibleProjects.map((p) => (
  • ))}
) : (
    {visibleProjects.map((p) => (
  • ))}
)} ); } function ViewButton({ active, label, children, onClick, }: { active: boolean; label: string; children: ReactNode; onClick: () => void; }) { return ( ); } function NewProjectCard() { return ( 新建 从一句灵感开始一本书 ); }