"use client"; import { useMemo, useState } from "react"; import { ArrowRight, Loader2, NotebookPen, Sparkles } from "lucide-react"; import { toast } from "sonner"; import { useTheme } from "@/contexts/ThemeContext"; import { createSearchSpace } from "@/core/note/api"; import { useNoteAuth } from "@/hooks/useNoteAuth"; import { cn } from "@/lib/utils"; export default function LightAppNewNotePage() { const { theme } = useTheme(); const isDark = theme === "dark"; const { loading: authLoading, error: authError } = useNoteAuth(); const [titleInput, setTitleInput] = useState(""); const [creating, setCreating] = useState(false); const hasTitle = useMemo(() => titleInput.trim().length > 0, [titleInput]); const isBusy = authLoading || creating; const handleCreate = async () => { const name = titleInput.trim(); if (!name || isBusy || authError) { return; } setCreating(true); try { const searchSpace = await createSearchSpace({ name }); toast.success(`笔记「${searchSpace.name}」创建成功`); setTitleInput(""); } catch (error) { const message = error instanceof Error ? error.message : "创建笔记失败,请稍后重试"; toast.error(message); } finally { setCreating(false); } }; return (
新建笔记开始使用 {authError ? `(${authError})` : ""}