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"; import { env } from "@web/src/env"; 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 */}
{env.APP_NAME || "心灵树洞"}
聆听细语 润泽心灵

勤勉解困 化雨无声
{showLogin && ( )}
{/* Right Panel - Form Section */}
{showLogin ? ( 登录 首次使用?{" "} ) : ( 注册账号 已有账号?{" "} )}
); }; export default AuthPage;