diff --git a/src/App.tsx b/src/App.tsx
index a6d7383..0da7a5c 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -8,7 +8,7 @@ import GeneratePage from './pages/Generate';
import ManagePage from './pages/Manage';
import ProfilePage from './pages/Profile';
-const PrivateRoute = () => {
+const PrivatePrivateRoute = () => {
const user = authApi.getCurrentUser();
if (!user) {
return ;
@@ -16,6 +16,14 @@ const PrivateRoute = () => {
return ;
};
+const PublicRoute = ({ children }: { children: React.ReactNode }) => {
+ const user = authApi.getCurrentUser();
+ if (user) {
+ return ;
+ }
+ return <>{children}>;
+};
+
const AdminRoutes = () => {
return (
@@ -29,7 +37,11 @@ function App() {
} />
- } />
+
+
+
+ } />
} />
}>
@@ -46,4 +58,4 @@ function App() {
);
}
-export default App;
\ No newline at end of file
+export default App;
diff --git a/src/pages/Login.tsx b/src/pages/Login.tsx
index 53e23ac..5d62df0 100644
--- a/src/pages/Login.tsx
+++ b/src/pages/Login.tsx
@@ -1,4 +1,4 @@
-import { useState, useEffect } from 'react';
+import { useState } from 'react';
import { Form, Input, Button, Card, message, Checkbox } from 'antd';
import { UserOutlined, LockOutlined, LoginOutlined } from '@ant-design/icons';
import { useNavigate } from 'react-router-dom';
@@ -12,16 +12,6 @@ function LoginPage() {
const [loading, setLoading] = useState(false);
const navigate = useNavigate();
- useEffect(() => {
- const token = localStorage.getItem('authToken');
- if (token) {
- const currentUser = authApi.getCurrentUser();
- if (currentUser) {
- navigate('/admin/dashboard', { replace: true });
- }
- }
- }, [navigate]);
-
const handleLogin = async (values: { username: string; password: string; remember?: boolean }) => {
setLoading(true);
try {