From 4e18d13b6b08586e2a1ddf2cff2318ea4d8ec70e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=A2=E6=80=9D?= <2897217417@qq.com> Date: Thu, 18 Nov 2021 15:37:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B3=A8=E5=86=8C=E5=92=8C=E6=89=BE=E5=9B=9E?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/forge/Component/HeadSearch.jsx | 6 ++++-- src/modules/loginRegister/Register.jsx | 11 ++++++++--- src/modules/loginRegister/ResetPassword.jsx | 5 +++-- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/forge/Component/HeadSearch.jsx b/src/forge/Component/HeadSearch.jsx index fc5ac83a2..5173288a0 100644 --- a/src/forge/Component/HeadSearch.jsx +++ b/src/forge/Component/HeadSearch.jsx @@ -6,11 +6,13 @@ export default ({history}) => { const [searchValue, setSearchValue] = useState(""); function onGlobalSearch(e) { - history.push('/search?value=' + e.target.value); + window.location.href = `/search?value=${e.target.value}`; } return ( -
setSearchValue("")}> +
{setTimeout(() => { + setSearchValue(""); + }, 500)}}> onGlobalSearch({target:{value:searchValue}})}> setSearchValue(value.target.value)} value={searchValue}>
diff --git a/src/modules/loginRegister/Register.jsx b/src/modules/loginRegister/Register.jsx index d9195837f..441ad46e5 100644 --- a/src/modules/loginRegister/Register.jsx +++ b/src/modules/loginRegister/Register.jsx @@ -8,7 +8,10 @@ import './LoginRegisterPage.scss'; function Register(props){ const {form} = props; const {getFieldDecorator } = form; + //用户输入的符合规则的邮箱(用于获取验证码) const [emailStr, setEmailStr] = useState(undefined); + //用户输入的符合规则的用户名,用于当用户输入符合规则的用户名之后再更改又去触发check.json接口 + const [loginStr, setLoginStr] = useState(undefined); const [secondsStr, setSecondsStr] = useState(60); const [countDown, setCountDown] = useState(false); const [getCaptchaBut, setGetCaptchaBut] = useState(false); @@ -50,27 +53,29 @@ function Register(props){ //判断用户名(username)是否注册 function usernameConfirm(rule, value, callback){ setUserNameGo(true); - value && userNameGo ? axios.post(`/accounts/check.json`, { + value && (userNameGo || value !== loginStr) ? axios.post(`/accounts/check.json`, { value: value, type: 1 }).then(response => { if (response.data.status === -1) { callback('该名称已经被使用'); } else { + setLoginStr(value); setUserNameGo(false); callback(); } - }):callback() + }):callback();setLoginStr(undefined); } //判断邮箱是否注册 function emailConfirm(rule, value, callback) { setEmailGo(true); - value && emailGo ? axios.post(`/accounts/check.json`, { + value && (emailGo || value !== emailStr) ? axios.post(`/accounts/check.json`, { value: value, type: 2 }).then(response => { if (response.data.status === -1) { + setGetCaptchaBut(false); callback('该邮箱已被注册'); } else { setEmailStr(value); diff --git a/src/modules/loginRegister/ResetPassword.jsx b/src/modules/loginRegister/ResetPassword.jsx index cb7e01a44..d1226995a 100644 --- a/src/modules/loginRegister/ResetPassword.jsx +++ b/src/modules/loginRegister/ResetPassword.jsx @@ -57,16 +57,17 @@ function ResetPassword(props) { //判断邮箱是否注册 function emailConfirm(rule, value, callback) { setEmailGo(true); - value && emailGo ? axios.post(`/accounts/check.json`, { + value && (emailGo || value !== emailStr) ? axios.post(`/accounts/check.json`, { value: value, type: 2 }).then(response => { if (response.data && response.data.status === -1) { - setEmailStr(value) + setEmailStr(value); setGetCaptchaBut(true); setEmailGo(false); callback(); } else { + setGetCaptchaBut(false); callback('此邮箱未注册'); } }):callback();setEmailStr(undefined);