From 34d94a6b6bfe788d7714f94456ec263afcca52ea Mon Sep 17 00:00:00 2001 From: rayd1o Date: Thu, 9 Apr 2026 00:37:02 +0800 Subject: [PATCH] Redirect login success to admin --- frontend/src/pages/Login/Login.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/src/pages/Login/Login.tsx b/frontend/src/pages/Login/Login.tsx index 8eccc5a9..74f07bda 100644 --- a/frontend/src/pages/Login/Login.tsx +++ b/frontend/src/pages/Login/Login.tsx @@ -1,10 +1,12 @@ import { useState } from 'react' import { Input, Button, Form, message } from 'antd' import { UserOutlined, LockOutlined } from '@ant-design/icons' +import { useNavigate } from 'react-router-dom' import { useAuthStore } from '../../stores/auth' function Login() { const [loading, setLoading] = useState(false) + const navigate = useNavigate() const { login } = useAuthStore() const onFinish = async (values: { username: string; password: string }) => { @@ -12,6 +14,7 @@ function Login() { try { await login(values.username, values.password) message.success('登录成功') + navigate('/admin', { replace: true }) } catch (error: unknown) { const err = error as { response?: { data?: { detail?: string } } } message.error(err.response?.data?.detail || '登录失败')