fix: 登录成功后跳转首页
Build and Deploy / build (push) Successful in 2m6s
Build and Deploy / deploy (push) Has been skipped

This commit is contained in:
2026-07-16 19:28:04 +00:00
parent 349b5985b7
commit 8c79918daa
+3
View File
@@ -1,10 +1,12 @@
import { useState } from 'react'
import { useNavigate } from 'react-router-dom'
interface Props {
onLogin: (token: string) => void
}
export default function LoginPage({ onLogin }: Props) {
const navigate = useNavigate()
const [username, setUsername] = useState('')
const [password, setPassword] = useState('')
const [error, setError] = useState('')
@@ -31,6 +33,7 @@ export default function LoginPage({ onLogin }: Props) {
localStorage.setItem('token', data.access_token)
onLogin(data.access_token)
navigate('/')
} catch {
setError('网络错误')
} finally {