71 lines
2.2 KiB
TypeScript
71 lines
2.2 KiB
TypeScript
"use client"
|
|
|
|
import type React from "react"
|
|
|
|
import { useState } from "react"
|
|
import { useRouter } from "next/navigation"
|
|
import { Button } from "@/components/ui/button"
|
|
import { Input } from "@/components/ui/input"
|
|
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from "@/components/ui/card"
|
|
import { Label } from "@/components/ui/label"
|
|
|
|
export default function LoginPage() {
|
|
const [username, setUsername] = useState("")
|
|
const [password, setPassword] = useState("")
|
|
const [isLoading, setIsLoading] = useState(false)
|
|
const router = useRouter()
|
|
|
|
const handleLogin = async (e: React.FormEvent) => {
|
|
e.preventDefault()
|
|
setIsLoading(true)
|
|
|
|
// Simulate login API call
|
|
setTimeout(() => {
|
|
setIsLoading(false)
|
|
router.push("/dashboard")
|
|
}, 1500)
|
|
}
|
|
|
|
return (
|
|
<div className="flex h-screen w-full items-center justify-center bg-gray-50">
|
|
<Card className="w-[400px]">
|
|
<CardHeader className="space-y-1">
|
|
<CardTitle className="text-2xl text-center">超级管理员后台</CardTitle>
|
|
<CardDescription className="text-center">请输入您的账号和密码登录系统</CardDescription>
|
|
</CardHeader>
|
|
<form onSubmit={handleLogin}>
|
|
<CardContent className="space-y-4">
|
|
<div className="space-y-2">
|
|
<Label htmlFor="username">账号</Label>
|
|
<Input
|
|
id="username"
|
|
placeholder="请输入账号"
|
|
value={username}
|
|
onChange={(e) => setUsername(e.target.value)}
|
|
required
|
|
/>
|
|
</div>
|
|
<div className="space-y-2">
|
|
<Label htmlFor="password">密码</Label>
|
|
<Input
|
|
id="password"
|
|
type="password"
|
|
placeholder="请输入密码"
|
|
value={password}
|
|
onChange={(e) => setPassword(e.target.value)}
|
|
required
|
|
/>
|
|
</div>
|
|
</CardContent>
|
|
<CardFooter>
|
|
<Button className="w-full" type="submit" disabled={isLoading}>
|
|
{isLoading ? "登录中..." : "登录"}
|
|
</Button>
|
|
</CardFooter>
|
|
</form>
|
|
</Card>
|
|
</div>
|
|
)
|
|
}
|
|
|