import React, { useState } from 'react'; import { useNavigate, useLocation } from 'react-router'; import { Form, Input, Button, Typography, message, Card } from 'antd'; import { UserOutlined, LockOutlined } from '@ant-design/icons'; import { useAppDispatch, useAppSelector } from '@/store/hooks'; import { loginLocal } from '@/store/slices/authSlice'; const { Title, Text } = Typography; const LoginPage: React.FC = () => { const navigate = useNavigate(); const location = useLocation(); const dispatch = useAppDispatch(); const { loading, error } = useAppSelector((state) => state.auth); const [messageApi, contextHolder] = message.useMessage(); const from = location.state?.from?.pathname || '/data'; const onFinish = (values: any) => { dispatch(loginLocal(values)); // The reducer updates state synchronously. if (values.username === 'admin' && values.password === '123456') { messageApi.success('登录成功'); navigate(from, { replace: true }); } else { messageApi.error('账号或密码错误'); } }; return (
{contextHolder} {/* Background Effects */}
{/* Simple grid pattern if possible, or just gradient */}
{/* Decorative line */}
DataBuilder 一站式数据工作平台
} placeholder="账号" className="!bg-white/5 !border-white/10 !text-white placeholder:!text-gray-600 hover:!border-blue-500/50 focus:!border-blue-500 !rounded-lg" /> } type="password" placeholder="密码" className="!bg-white/5 !border-white/10 !text-white placeholder:!text-gray-600 hover:!border-blue-500/50 focus:!border-blue-500 !rounded-lg" />
数据处理平台 · 安全接入
); }; export default LoginPage;