import React, { useEffect } from "react"; import { useLocation, useNavigate } from "react-router-dom"; import { useAuth } from "@web/src/providers/auth-provider"; import { RegisterForm } from "./register"; import { LoginForm } from "./login"; import { Card, Typography, Button, Spin, Divider } from "antd"; import { AnimatePresence, motion } from "framer-motion"; import { useAuthForm } from "./useAuthForm"; const { Title, Text, Paragraph } = Typography; const AuthPage: React.FC = () => { const { showLogin, isLoading, toggleForm, handleLogin, handleRegister } = useAuthForm(); const { isAuthenticated } = useAuth(); 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 (
{/* Left Panel - Welcome Section */}
首长机关信箱
聆音于微,润心以答,纾难化雨,解忧惟勤 {showLogin && ( )}
{/* Right Panel - Form Section */}
{showLogin ? ( 登录 首次使用?{' '} ) : ( 注册账号 已有账号?{' '} )}
); }; export default AuthPage;