diff --git a/src/forge/Component/HeadSearch.jsx b/src/forge/Component/HeadSearch.jsx index fc5ac83a..5173288a 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 d9195837..441ad46e 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 cb7e01a4..d1226995 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);