Adapt to fatweb-api

This commit is contained in:
2023-10-10 16:37:02 +08:00
parent e506a9bf0e
commit e8efecfe64
5 changed files with 66 additions and 93 deletions

View File

@@ -1,6 +1,11 @@
import React from 'react'
import { login } from '@/utils/auth.ts'
import { LOGIN_SUCCESS, LOGIN_USERNAME_PASSWORD_ERROR } from '@/constants/Common.constants.ts'
import {
SYSTEM_LOGIN_SUCCESS,
SYSTEM_LOGIN_USERNAME_PASSWORD_ERROR,
SYSTEM_USER_DISABLE,
SYSTEM_USERNAME_NOT_FOUND
} from '@/constants/Common.constants.ts'
import { setToken } from '@/utils/common.ts'
import '@/assets/css/pages/login.scss'
@@ -15,14 +20,15 @@ const Login: React.FC = () => {
const res = value.data
const { code, data } = res
switch (code) {
case LOGIN_SUCCESS:
case SYSTEM_LOGIN_SUCCESS:
setToken(data?.token ?? '')
void messageApi.success('登录成功')
setTimeout(() => {
navigate('/')
}, 1500)
break
case LOGIN_USERNAME_PASSWORD_ERROR:
case SYSTEM_USERNAME_NOT_FOUND:
case SYSTEM_LOGIN_USERNAME_PASSWORD_ERROR:
void messageApi.error(
<>
<strong></strong><strong></strong>
@@ -30,6 +36,14 @@ const Login: React.FC = () => {
)
setIsLoggingIn(false)
break
case SYSTEM_USER_DISABLE:
void messageApi.error(
<>
<strong></strong>
</>
)
setIsLoggingIn(false)
break
default:
void messageApi.error(
<>