Optimize login

This commit is contained in:
2023-10-10 17:05:30 +08:00
parent 81c490853a
commit a10b418ae9
2 changed files with 42 additions and 38 deletions

View File

@@ -16,7 +16,8 @@ const Login: React.FC = () => {
const onFinish = (values: LoginForm) => { const onFinish = (values: LoginForm) => {
setIsLoggingIn(true) setIsLoggingIn(true)
void login(values.username, values.password).then((value) => { void login(values.username, values.password)
.then((value) => {
const res = value.data const res = value.data
const { code, data } = res const { code, data } = res
switch (code) { switch (code) {
@@ -53,6 +54,9 @@ const Login: React.FC = () => {
setIsLoggingIn(false) setIsLoggingIn(false)
} }
}) })
.catch(() => {
setIsLoggingIn(false)
})
} }
return ( return (

View File

@@ -12,7 +12,7 @@ import { message } from 'antd'
const service: AxiosInstance = axios.create({ const service: AxiosInstance = axios.create({
baseURL: import.meta.env.VITE_API_URL, baseURL: import.meta.env.VITE_API_URL,
timeout: 10000, timeout: 30000,
withCredentials: false withCredentials: false
}) })