This commit is contained in:
freedakgmail
2025-11-24 16:07:24 +08:00
parent 3d075c6076
commit b25f4bea02
426 changed files with 3619 additions and 4468 deletions
+14 -22
View File
@@ -1,6 +1,6 @@
"use client"
import { useState } from "react"
import { useState, useEffect } from "react"
import { useRouter } from "next/navigation"
import { useSession } from "next-auth/react"
import { SiteHeader } from "@/components/site-header"
@@ -10,16 +10,24 @@ import { Label } from "@/components/ui/label"
import { Textarea } from "@/components/ui/textarea"
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
import { Alert, AlertDescription } from "@/components/ui/alert"
import { ArrowLeft, TreePine } from "lucide-react"
import { ArrowLeft, TreePine, User } from "lucide-react"
import Link from "next/link"
import { EmptyStateBadge } from "@/components/empty-state-badge"
export default function NewTreePage() {
const router = useRouter()
const { data: session } = useSession()
const { data: session, status } = useSession()
const [name, setName] = useState("")
const [description, setDescription] = useState("")
const [error, setError] = useState("")
const [loading, setLoading] = useState(false)
// 未登录时重定向到登录页
useEffect(() => {
if (status === 'unauthenticated') {
router.push('/auth/signin')
}
}, [status, router])
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
@@ -59,25 +67,9 @@ export default function NewTreePage() {
}
}
if (!session) {
return (
<div className="min-h-screen bg-background flex flex-col">
<SiteHeader />
<div className="flex-1 flex items-center justify-center">
<Card className="w-full max-w-md mx-4">
<CardHeader>
<CardTitle></CardTitle>
<CardDescription></CardDescription>
</CardHeader>
<CardFooter>
<Button asChild className="w-full">
<Link href="/auth/signin"></Link>
</Button>
</CardFooter>
</Card>
</div>
</div>
)
// 未登录时不渲染内容(已在 useEffect 中重定向)
if (status === 'loading' || !session) {
return null
}
return (