Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8217e694
authored
Aug 10, 2025
by
creamlike1024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 注册时发送邮件验证码没有等待时间
parent
2cabe4f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletions
+18
-1
web/src/components/auth/RegisterForm.js
+18
-1
No files found.
web/src/components/auth/RegisterForm.js
View file @
8217e694
...
...
@@ -80,6 +80,8 @@ const RegisterForm = () => {
const
[
verificationCodeLoading
,
setVerificationCodeLoading
]
=
useState
(
false
);
const
[
otherRegisterOptionsLoading
,
setOtherRegisterOptionsLoading
]
=
useState
(
false
);
const
[
wechatCodeSubmitLoading
,
setWechatCodeSubmitLoading
]
=
useState
(
false
);
const
[
disableButton
,
setDisableButton
]
=
useState
(
false
);
const
[
countdown
,
setCountdown
]
=
useState
(
30
);
const
logo
=
getLogo
();
const
systemName
=
getSystemName
();
...
...
@@ -106,6 +108,19 @@ const RegisterForm = () => {
}
},
[
status
]);
useEffect
(()
=>
{
let
countdownInterval
=
null
;
if
(
disableButton
&&
countdown
>
0
)
{
countdownInterval
=
setInterval
(()
=>
{
setCountdown
(
countdown
-
1
);
},
1000
);
}
else
if
(
countdown
===
0
)
{
setDisableButton
(
false
);
setCountdown
(
30
);
}
return
()
=>
clearInterval
(
countdownInterval
);
// Clean up on unmount
},
[
disableButton
,
countdown
]);
const
onWeChatLoginClicked
=
()
=>
{
setWechatLoading
(
true
);
setShowWeChatLoginModal
(
true
);
...
...
@@ -198,6 +213,7 @@ const RegisterForm = () => {
const
{
success
,
message
}
=
res
.
data
;
if
(
success
)
{
showSuccess
(
'验证码发送成功,请检查你的邮箱!'
);
setDisableButton
(
true
);
// 发送成功后禁用按钮,开始倒计时
}
else
{
showError
(
message
);
}
...
...
@@ -454,9 +470,10 @@ const RegisterForm = () => {
<
Button
onClick
=
{
sendVerificationCode
}
loading
=
{
verificationCodeLoading
}
disabled
=
{
disableButton
||
verificationCodeLoading
}
size
=
"small"
>
{
t
(
'获取验证码'
)}
{
disableButton
?
`
${
t
(
'重新发送'
)}
(
${
countdown
}
)`
:
t
(
'获取验证码'
)}
<
/Button
>
}
/
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment