From 7e81dc1a9dc91a2b163ecead53b5f56606c8977a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Mon, 3 Jul 2023 14:53:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E9=99=86=E5=8E=BB=E9=99=A4=E9=AA=8C?= =?UTF-8?q?=E8=AF=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/login.ts | 9 +----- src/pages/login/index.tsx | 63 ++++----------------------------------- 2 files changed, 6 insertions(+), 66 deletions(-) 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 && ( - - )} -
-