页面登录优化,team优化

This commit is contained in:
liamzi
2024-12-25 17:25:10 +08:00
parent 5eb069c63f
commit 4cbec25b53
18 changed files with 535 additions and 4816 deletions

View File

@@ -1,8 +1,9 @@
import React from "react";
import { Form, Input, Button, Divider, message } from "antd";
import { GoogleOutlined } from "@ant-design/icons";
import { GoogleOutlined, MailOutlined, LockOutlined } from "@ant-design/icons";
import { Link, useNavigate } from "react-router-dom";
import { useAuth } from "@/contexts/AuthContext";
import { supabaseService } from "@/hooks/supabaseService";
const Login = () => {
const navigate = useNavigate();
@@ -10,92 +11,100 @@ const Login = () => {
const [form] = Form.useForm();
const handleLogin = async (values) => {
try {
await login(values.email, values.password);
message.success("登录成功!");
navigate("/");
} catch (error) {
console.error("Login error:", error);
}
login(values.email, values.password);
};
const handleGoogleLogin = async () => {
try {
await signInWithGoogle();
} catch (error) {
console.error("Google login error:", error);
}
};
return (
<div className="min-h-screen flex bg-gradient-to-br from-[#f5f7fa] to-[#c3cfe2]">
<div className="w-full max-w-[1200px] mx-auto flex p-8 gap-16">
<div className="flex-1 bg-white p-12 rounded-[20px] shadow-[0_10px_30px_rgba(0,0,0,0.1)]">
<div className="mb-8 text-center">
<h1 className="text-3xl font-bold mb-2 bg-gradient-to-r from-primary-500 to-[#36cff0] bg-clip-text text-transparent">
Uppeta
</h1>
<p className="text-gray-500">欢迎回来请登录您的账户</p>
</div>
<Form
form={form}
name="login"
onFinish={handleLogin}
layout="vertical"
size="large"
>
<Form.Item
name="email"
rules={[
{ required: true, message: "请输入邮箱!" },
{ type: "email", message: "请输入有效的邮箱地址!" },
]}
>
<Input placeholder="邮箱" />
</Form.Item>
<Form.Item
name="password"
rules={[{ required: true, message: "请输入密码!" }]}
>
<Input.Password placeholder="密码" />
</Form.Item>
<div className="flex justify-between items-center mb-6">
<Form.Item name="remember" valuePropName="checked" noStyle>
<Link
to="/forgot-password"
className="text-primary-500 hover:text-primary-600"
>
忘记密码
</Link>
</Form.Item>
</div>
<Form.Item>
<Button type="primary" htmlType="submit" block>
登录
</Button>
</Form.Item>
<Divider></Divider>
<Button
icon={<GoogleOutlined />}
block
onClick={handleGoogleLogin}
className="mb-6"
loading={loading}
>
使用 Google 账号登录
</Button>
</Form>
<div className="min-h-screen flex items-center justify-center bg-[#f5f8ff] dark:bg-gray-900">
<div className="w-full max-w-[1200px] mx-auto flex p-4 md:p-0">
{/* 左侧登录表单 */}
<div className="w-full md:w-1/2 bg-white dark:bg-gray-800 p-8 md:p-12 rounded-3xl shadow-2xl dark:shadow-gray-800/50">
<div className="mb-10 text-center">
<h1 className="text-4xl font-bold mb-3 bg-gradient-to-r from-blue-600 to-cyan-500 bg-clip-text text-transparent">
Uppeta
</h1>
<p className="text-gray-500 dark:text-gray-400">
欢迎回来请登录您的账户
</p>
</div>
<div className="flex-1 hidden md:block rounded-[20px] bg-[url('https://uppeta.com/img/svg/main.svg')] bg-center bg-contain bg-no-repeat" />
<Form
form={form}
name="login"
onFinish={handleLogin}
layout="vertical"
size="large"
>
<Form.Item
name="email"
rules={[
{ required: true, message: "请输入邮箱!" },
{ type: "email", message: "请输入有效的邮箱地址!" },
]}
>
<Input
prefix={<MailOutlined className="text-gray-400" />}
placeholder="邮箱"
className="h-12 rounded-xl dark:bg-gray-700 dark:border-gray-600 dark:text-gray-100"
/>
</Form.Item>
<Form.Item
name="password"
rules={[{ required: true, message: "请输入密码!" }]}
>
<Input.Password
prefix={<LockOutlined className="text-gray-400" />}
placeholder="密码"
className="h-12 rounded-xl dark:bg-gray-700 dark:border-gray-600 dark:text-gray-100"
/>
</Form.Item>
<div className="flex justify-end mb-6">
<Link
to="/forgot-password"
className="text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 text-sm"
>
忘记密码
</Link>
</div>
<Form.Item>
<Button
type="primary"
htmlType="submit"
block
className="h-12 rounded-xl text-base font-medium bg-gradient-to-r from-blue-600 to-cyan-500 border-0 hover:from-blue-700 hover:to-cyan-600"
>
登录
</Button>
</Form.Item>
<Divider className="dark:border-gray-700">
<span className="text-gray-400"></span>
</Divider>
<Button
icon={<GoogleOutlined />}
block
onClick={signInWithGoogle}
loading={loading}
className="h-12 rounded-xl text-base font-medium mb-6 bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 border border-gray-200 dark:border-gray-600"
>
使用 Google 账号登录
</Button>
</Form>
</div>
{/* 右侧图片 */}
<div className="hidden md:flex md:w-1/2 items-center justify-center p-12">
<div className="w-full h-full rounded-3xl bg-[url('https://uppeta.com/img/svg/main.svg')] bg-center bg-contain bg-no-repeat dark:opacity-90 transform hover:scale-105 transition-all duration-500" />
</div>
</div>
</div>
);
};