2025-01-23 23:59:49 +08:00
|
|
|
|
import React, { useEffect } from "react";
|
2025-01-22 23:19:58 +08:00
|
|
|
|
import { useLocation, useNavigate } from "react-router-dom";
|
|
|
|
|
|
import { useAuth } from "@web/src/providers/auth-provider";
|
|
|
|
|
|
import { RegisterForm } from "./register";
|
|
|
|
|
|
import { LoginForm } from "./login";
|
2025-01-23 23:59:49 +08:00
|
|
|
|
import { Card, Typography, Button, Spin, Divider } from "antd";
|
|
|
|
|
|
import { AnimatePresence, motion } from "framer-motion";
|
|
|
|
|
|
import { useAuthForm } from "./useAuthForm";
|
|
|
|
|
|
|
|
|
|
|
|
const { Title, Text, Paragraph } = Typography;
|
2025-01-22 23:19:58 +08:00
|
|
|
|
|
|
|
|
|
|
const AuthPage: React.FC = () => {
|
2025-01-23 23:59:49 +08:00
|
|
|
|
const {
|
|
|
|
|
|
showLogin,
|
|
|
|
|
|
isLoading,
|
|
|
|
|
|
toggleForm,
|
|
|
|
|
|
handleLogin,
|
|
|
|
|
|
handleRegister
|
|
|
|
|
|
} = useAuthForm();
|
|
|
|
|
|
const { isAuthenticated } = useAuth();
|
2025-01-22 23:19:58 +08:00
|
|
|
|
const location = useLocation();
|
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
if (isAuthenticated) {
|
|
|
|
|
|
const params = new URLSearchParams(location.search);
|
|
|
|
|
|
const redirectUrl = params.get("redirect_url") || "/";
|
|
|
|
|
|
navigate(redirectUrl, { replace: true });
|
|
|
|
|
|
}
|
|
|
|
|
|
}, [isAuthenticated, location]);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
2025-01-23 23:59:49 +08:00
|
|
|
|
<div className="min-h-screen flex items-center justify-center p-4">
|
2025-01-22 23:19:58 +08:00
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ opacity: 0, y: 20 }}
|
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
2025-01-23 23:59:49 +08:00
|
|
|
|
transition={{ duration: 0.5 }}
|
2025-01-22 23:19:58 +08:00
|
|
|
|
>
|
2025-01-25 20:48:16 +08:00
|
|
|
|
<div
|
|
|
|
|
|
className="w-full max-w-5xl shadow-elegant border-2 border-white rounded-xl overflow-hidden transition-all duration-300 relative"
|
2025-01-23 23:59:49 +08:00
|
|
|
|
>
|
|
|
|
|
|
<div className="flex flex-col md:flex-row min-h-[650px]">
|
|
|
|
|
|
{/* Left Panel - Welcome Section */}
|
2025-01-25 20:48:16 +08:00
|
|
|
|
<div className="w-full md:w-1/2 p-12 bg-gradient-to-br from-primary to-primary-600 text-white flex flex-col justify-center relative overflow-hidden">
|
2025-01-23 23:59:49 +08:00
|
|
|
|
<motion.div
|
|
|
|
|
|
initial={{ opacity: 0, y: 20 }}
|
|
|
|
|
|
animate={{ opacity: 1, y: 0 }}
|
|
|
|
|
|
transition={{ delay: 0.2, duration: 0.5 }}
|
|
|
|
|
|
>
|
2025-01-25 20:48:16 +08:00
|
|
|
|
<div className="text-4xl text-white mb-4 font-serif">
|
2025-01-26 12:48:10 +08:00
|
|
|
|
烽火建言
|
2025-01-22 23:19:58 +08:00
|
|
|
|
</div>
|
2025-01-25 20:48:16 +08:00
|
|
|
|
<Paragraph className="text-lg mb-8 text-blue-100 leading-relaxed text-justify">
|
2025-01-26 12:48:10 +08:00
|
|
|
|
用真心聆听每一位官兵的心声,第一时间回应大家的关切,把战友们的烦心事当作自己的心头事,用心用情解决每一个难题,全心全意办好每一件实事,让贴心服务成为军营最温暖的底色
|
2025-01-23 23:59:49 +08:00
|
|
|
|
</Paragraph>
|
|
|
|
|
|
{showLogin && (
|
|
|
|
|
|
<Button
|
|
|
|
|
|
type="default"
|
|
|
|
|
|
ghost
|
|
|
|
|
|
size="large"
|
|
|
|
|
|
onClick={toggleForm}
|
|
|
|
|
|
className="w-fit hover:bg-white hover:text-blue-700 transition-all"
|
|
|
|
|
|
>
|
2025-01-25 20:48:16 +08:00
|
|
|
|
注册账号
|
2025-01-23 23:59:49 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
</div>
|
2025-01-22 23:19:58 +08:00
|
|
|
|
|
2025-01-23 23:59:49 +08:00
|
|
|
|
{/* Right Panel - Form Section */}
|
|
|
|
|
|
<div className="w-full md:w-1/2 p-10 lg:p-16 bg-white relative rounded-xl">
|
2025-01-22 23:19:58 +08:00
|
|
|
|
|
2025-01-23 23:59:49 +08:00
|
|
|
|
<AnimatePresence mode="wait">
|
|
|
|
|
|
{showLogin ? (
|
|
|
|
|
|
<motion.div
|
|
|
|
|
|
key="login"
|
|
|
|
|
|
initial={{ opacity: 0, x: 50 }}
|
|
|
|
|
|
animate={{ opacity: 1, x: 0 }}
|
|
|
|
|
|
exit={{ opacity: 0, x: -50 }}
|
|
|
|
|
|
transition={{ duration: 0.3 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<motion.div className="mb-8">
|
|
|
|
|
|
<Title level={3} className="mb-2">登录</Title>
|
|
|
|
|
|
<Text type="secondary">
|
2025-01-25 20:48:16 +08:00
|
|
|
|
首次使用?{' '}
|
2025-01-23 23:59:49 +08:00
|
|
|
|
<Button
|
|
|
|
|
|
type="link"
|
|
|
|
|
|
onClick={toggleForm}
|
|
|
|
|
|
className="p-0 font-medium"
|
|
|
|
|
|
>
|
2025-01-25 20:48:16 +08:00
|
|
|
|
注册账号
|
2025-01-23 23:59:49 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
<LoginForm
|
|
|
|
|
|
onSubmit={handleLogin}
|
|
|
|
|
|
isLoading={isLoading}
|
|
|
|
|
|
/>
|
2025-01-22 23:19:58 +08:00
|
|
|
|
|
2025-01-23 23:59:49 +08:00
|
|
|
|
</motion.div>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<motion.div
|
|
|
|
|
|
key="register"
|
|
|
|
|
|
initial={{ opacity: 0, x: 50 }}
|
|
|
|
|
|
animate={{ opacity: 1, x: 0 }}
|
|
|
|
|
|
exit={{ opacity: 0, x: -50 }}
|
|
|
|
|
|
transition={{ duration: 0.3 }}
|
|
|
|
|
|
>
|
|
|
|
|
|
<motion.div className="mb-8">
|
2025-01-25 20:48:16 +08:00
|
|
|
|
<Title level={3} className="mb-2">注册账号</Title>
|
2025-01-23 23:59:49 +08:00
|
|
|
|
<Text type="secondary">
|
2025-01-25 20:48:16 +08:00
|
|
|
|
已有账号?{' '}
|
2025-01-23 23:59:49 +08:00
|
|
|
|
<Button
|
|
|
|
|
|
type="link"
|
|
|
|
|
|
onClick={toggleForm}
|
|
|
|
|
|
className="p-0 font-medium"
|
|
|
|
|
|
>
|
2025-01-25 20:48:16 +08:00
|
|
|
|
登录平台
|
2025-01-23 23:59:49 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
</Text>
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
<RegisterForm
|
|
|
|
|
|
onSubmit={handleRegister}
|
|
|
|
|
|
isLoading={isLoading}
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
</motion.div>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</AnimatePresence>
|
|
|
|
|
|
</div>
|
2025-01-22 23:19:58 +08:00
|
|
|
|
</div>
|
2025-01-25 20:48:16 +08:00
|
|
|
|
</div>
|
2025-01-22 23:19:58 +08:00
|
|
|
|
</motion.div>
|
|
|
|
|
|
</div>
|
2025-01-23 23:59:49 +08:00
|
|
|
|
|
2025-01-22 23:19:58 +08:00
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default AuthPage;
|