0.0.9.0
This commit is contained in:
+14
-22
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user