174 lines
6.4 KiB
TypeScript
174 lines
6.4 KiB
TypeScript
'use client'
|
||
|
||
import { signIn } from 'next-auth/react'
|
||
import { useState } from 'react'
|
||
import { Mail, Lock, ArrowLeft, AlertCircle } from 'lucide-react'
|
||
import Link from 'next/link'
|
||
import Image from 'next/image'
|
||
|
||
export default function SignInPage() {
|
||
const [email, setEmail] = useState('')
|
||
const [password, setPassword] = useState('')
|
||
const [loading, setLoading] = useState(false)
|
||
const [error, setError] = useState('')
|
||
|
||
const handleSubmit = async (e: React.FormEvent) => {
|
||
e.preventDefault()
|
||
setLoading(true)
|
||
setError('')
|
||
|
||
try {
|
||
const result = await signIn('credentials', {
|
||
email,
|
||
password,
|
||
redirect: false,
|
||
})
|
||
|
||
if (result?.error) {
|
||
setError('邮箱或密码错误,请重试')
|
||
} else if (result?.ok) {
|
||
// 登录成功,跳转到首页
|
||
window.location.href = '/'
|
||
}
|
||
} catch (err) {
|
||
setError('登录失败,请稍后重试')
|
||
} finally {
|
||
setLoading(false)
|
||
}
|
||
}
|
||
|
||
return (
|
||
<div className="min-h-screen bg-gradient-to-b from-apple-gray-50 to-white flex items-center justify-center px-4 py-12">
|
||
<div className="max-w-md w-full">
|
||
{/* 返回首页 */}
|
||
<Link
|
||
href="/"
|
||
className="inline-flex items-center space-x-2 text-apple-gray-600 hover:text-apple-blue transition-colors mb-8"
|
||
>
|
||
<ArrowLeft className="w-4 h-4" />
|
||
<span>返回首页</span>
|
||
</Link>
|
||
|
||
{/* Logo and Title */}
|
||
<div className="text-center mb-8">
|
||
<div className="flex justify-center mb-4">
|
||
<div className="relative w-16 h-16">
|
||
<Image
|
||
src="/images/logo.png"
|
||
alt="FLNXI Logo"
|
||
fill
|
||
className="object-contain"
|
||
priority
|
||
/>
|
||
</div>
|
||
</div>
|
||
<h1 className="text-3xl font-bold text-apple-gray-900 mb-2">
|
||
登录 FLNXI
|
||
</h1>
|
||
<p className="text-apple-gray-600">
|
||
欢迎回来,请登录您的账户
|
||
</p>
|
||
</div>
|
||
|
||
{/* 登录卡片 */}
|
||
<div className="bg-white rounded-3xl apple-shadow-lg p-8">
|
||
{/* 错误提示 */}
|
||
{error && (
|
||
<div className="mb-6 p-4 bg-red-50 border border-red-200 rounded-xl flex items-start space-x-3">
|
||
<AlertCircle className="w-5 h-5 text-red-600 flex-shrink-0 mt-0.5" />
|
||
<div>
|
||
<p className="text-sm text-red-800 font-medium">{error}</p>
|
||
<p className="text-xs text-red-600 mt-1">
|
||
演示账户:admin@flnxi.com / 123456
|
||
</p>
|
||
</div>
|
||
</div>
|
||
)}
|
||
|
||
{/* 演示提示 */}
|
||
<div className="mb-6 p-4 bg-blue-50 border border-blue-200 rounded-xl">
|
||
<p className="text-sm text-blue-800 font-medium mb-2">
|
||
🎉 演示账户
|
||
</p>
|
||
<div className="text-xs text-blue-700 space-y-1">
|
||
<p>邮箱:<span className="font-mono font-semibold">admin@flnxi.com</span></p>
|
||
<p>密码:<span className="font-mono font-semibold">123456</span></p>
|
||
</div>
|
||
</div>
|
||
|
||
{/* 登录表单 */}
|
||
<form onSubmit={handleSubmit} className="space-y-5">
|
||
{/* 邮箱输入 */}
|
||
<div>
|
||
<label className="block text-sm font-medium text-apple-gray-700 mb-2">
|
||
邮箱地址
|
||
</label>
|
||
<div className="relative">
|
||
<Mail className="absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-apple-gray-400" />
|
||
<input
|
||
type="email"
|
||
value={email}
|
||
onChange={(e) => setEmail(e.target.value)}
|
||
className="w-full pl-12 pr-4 py-3 border-2 border-apple-gray-200 rounded-xl focus:ring-2 focus:ring-apple-blue focus:border-transparent outline-none transition-all"
|
||
placeholder="your@email.com"
|
||
required
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
{/* 密码输入 */}
|
||
<div>
|
||
<label className="block text-sm font-medium text-apple-gray-700 mb-2">
|
||
密码
|
||
</label>
|
||
<div className="relative">
|
||
<Lock className="absolute left-4 top-1/2 -translate-y-1/2 w-5 h-5 text-apple-gray-400" />
|
||
<input
|
||
type="password"
|
||
value={password}
|
||
onChange={(e) => setPassword(e.target.value)}
|
||
className="w-full pl-12 pr-4 py-3 border-2 border-apple-gray-200 rounded-xl focus:ring-2 focus:ring-apple-blue focus:border-transparent outline-none transition-all"
|
||
placeholder="••••••••"
|
||
required
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
{/* 登录按钮 */}
|
||
<button
|
||
type="submit"
|
||
disabled={loading}
|
||
className="w-full py-4 bg-gradient-to-r from-apple-blue to-blue-600 text-white font-semibold rounded-xl button-hover apple-shadow-lg disabled:opacity-50 disabled:cursor-not-allowed transition-all text-lg"
|
||
>
|
||
{loading ? (
|
||
<span className="flex items-center justify-center">
|
||
<svg className="animate-spin h-5 w-5 mr-3" viewBox="0 0 24 24">
|
||
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" fill="none" />
|
||
<path className="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />
|
||
</svg>
|
||
登录中...
|
||
</span>
|
||
) : (
|
||
'登录'
|
||
)}
|
||
</button>
|
||
</form>
|
||
|
||
{/* 底部说明 */}
|
||
<div className="mt-6 pt-6 border-t border-apple-gray-100 text-center text-sm text-apple-gray-600">
|
||
<p>
|
||
这是演示登录页面,实际部署时需要连接您的用户数据库
|
||
</p>
|
||
</div>
|
||
</div>
|
||
|
||
{/* 额外信息 */}
|
||
<div className="mt-6 text-center text-sm text-apple-gray-500">
|
||
<p>登录即表示您同意我们的服务条款和隐私政策</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
)
|
||
}
|
||
|