diff --git a/src/api/login.ts b/src/api/login.ts index 0ff7cce..8b41e40 100644 --- a/src/api/login.ts +++ b/src/api/login.ts @@ -1,16 +1,9 @@ import client from "./internal/httpClient"; -export function login( - email: string, - password: string, - captchaKey: string, - captchaVal: string -) { +export function login(email: string, password: string) { return client.post("/api/v1/auth/login/password", { email: email, password: password, - captcha_key: captchaKey, - captcha_val: captchaVal, }); } diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index 5a7d043..93f1695 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -1,11 +1,11 @@ -import { Spin, Input, Button, message } from "antd"; +import { Input, Button, message } from "antd"; import React, { useState, useEffect } from "react"; import styles from "./index.module.scss"; import banner from "../../assets/images/login/banner.png"; -import { useDispatch, useSelector } from "react-redux"; +import { useDispatch } from "react-redux"; import { useNavigate } from "react-router-dom"; -import { loginAction, logoutAction } from "../../store/user/loginUserSlice"; -import { login, system, user } from "../../api/index"; +import { loginAction } from "../../store/user/loginUserSlice"; +import { login, user } from "../../api/index"; import { setToken } from "../../utils/index"; import { NoFooter } from "../../compenents"; @@ -13,25 +13,8 @@ const LoginPage: React.FC = () => { const dispatch = useDispatch(); const navigate = useNavigate(); const [loading, setLoading] = useState(false); - const [image, setImage] = useState(""); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); - const [captchaVal, setCaptchaVal] = useState(""); - const [captchaKey, setCaptchaKey] = useState(""); - const [captchaLoading, setCaptchaLoading] = useState(true); - - useEffect(() => { - fetchImageCaptcha(); - }, []); - - const fetchImageCaptcha = () => { - setCaptchaLoading(true); - system.imageCaptcha().then((res: any) => { - setImage(res.data.image); - setCaptchaKey(res.data.key); - setCaptchaLoading(false); - }); - }; const loginSubmit = (e: any) => { if (!email) { @@ -42,14 +25,6 @@ const LoginPage: React.FC = () => { message.error("请输入密码"); return; } - if (!captchaVal) { - message.error("请输入图形验证码"); - return; - } - if (captchaVal.length < 4) { - message.error("图形验证码错误"); - return; - } if (loading) { return; } @@ -68,7 +43,7 @@ const LoginPage: React.FC = () => { } setLoading(true); login - .login(email, password, captchaKey, captchaVal) + .login(email, password) .then((res: any) => { const token = res.data.token; setToken(token); @@ -76,8 +51,6 @@ const LoginPage: React.FC = () => { }) .catch((e) => { setLoading(false); - setCaptchaVal(""); - fetchImageCaptcha(); }); }; @@ -120,32 +93,6 @@ const LoginPage: React.FC = () => { placeholder="请输入密码" /> -
- { - setCaptchaVal(e.target.value); - }} - onKeyUp={(e) => keyUp(e)} - /> -
- {captchaLoading && ( -
- -
- )} - - {!captchaLoading && ( - - )} -
-