两步验证输入框自动聚焦

This commit is contained in:
whyour 2021-10-21 22:25:15 +08:00
parent 20893698ba
commit 10c07b0a09

View File

@ -23,7 +23,7 @@ const Login = () => {
const [waitTime, setWaitTime] = useState<any>(); const [waitTime, setWaitTime] = useState<any>();
const { theme } = useTheme(); const { theme } = useTheme();
const [twoFactor, setTwoFactor] = useState(false); const [twoFactor, setTwoFactor] = useState(false);
const [verifing, setVerifing] = useState(false); const [verifying, setVerifying] = useState(false);
const [loginInfo, setLoginInfo] = useState<any>(); const [loginInfo, setLoginInfo] = useState<any>();
const handleOk = (values: any) => { const handleOk = (values: any) => {
@ -56,7 +56,7 @@ const Login = () => {
}; };
const completeTowFactor = (values: any) => { const completeTowFactor = (values: any) => {
setVerifing(true); setVerifying(true);
request request
.put(`${config.apiPrefix}user/two-factor/login`, { .put(`${config.apiPrefix}user/two-factor/login`, {
data: { ...loginInfo, code: values.code }, data: { ...loginInfo, code: values.code },
@ -67,11 +67,11 @@ const Login = () => {
} else { } else {
checkResponse(data); checkResponse(data);
} }
setVerifing(false); setVerifying(false);
}) })
.catch((error: any) => { .catch((error: any) => {
console.log(error); console.log(error);
setVerifing(false); setVerifying(false);
}); });
}; };
@ -145,13 +145,13 @@ const Login = () => {
]} ]}
hasFeedback hasFeedback
> >
<Input placeholder="6位数字" autoComplete="off" /> <Input placeholder="6位数字" autoFocus autoComplete="off" />
</FormItem> </FormItem>
<Button <Button
type="primary" type="primary"
htmlType="submit" htmlType="submit"
style={{ width: '100%' }} style={{ width: '100%' }}
loading={verifing} loading={verifying}
> >
</Button> </Button>