fix:修复重连状态与认证流程关键缺陷
This commit is contained in:
@@ -91,6 +91,7 @@ var toast_manager: ToastManager
|
||||
|
||||
# 验证码冷却计时器
|
||||
var cooldown_timer: Timer = null
|
||||
var cooldown_email: String = ""
|
||||
|
||||
# 当前登录模式(从管理器同步)
|
||||
var current_login_mode: AuthManager.LoginMode = AuthManager.LoginMode.PASSWORD
|
||||
@@ -291,9 +292,6 @@ func _on_register_pressed():
|
||||
func _on_send_code_pressed():
|
||||
var email = register_email.text.strip_edges()
|
||||
auth_manager.send_email_verification_code(email)
|
||||
|
||||
# 开始冷却计时器
|
||||
_start_cooldown_timer(email)
|
||||
|
||||
# 获取登录验证码按钮
|
||||
func _on_get_login_code_pressed():
|
||||
@@ -374,8 +372,10 @@ func _on_controller_register_failed(_message: String):
|
||||
|
||||
# 验证码发送成功处理
|
||||
func _on_controller_verification_code_sent(_message: String):
|
||||
# 验证码发送成功,冷却计时器已经在按钮点击时启动
|
||||
pass
|
||||
var email = auth_manager.current_email
|
||||
if email == "":
|
||||
email = register_email.text.strip_edges()
|
||||
_start_cooldown_timer(email)
|
||||
|
||||
# 验证码发送失败处理
|
||||
func _on_controller_verification_code_failed(_message: String):
|
||||
@@ -429,12 +429,20 @@ func _on_controller_show_toast_message(message: String, is_success: bool):
|
||||
# ============ 验证码冷却管理 ============
|
||||
|
||||
# 开始冷却计时器
|
||||
func _start_cooldown_timer(_email: String):
|
||||
func _start_cooldown_timer(email: String):
|
||||
if cooldown_timer != null:
|
||||
cooldown_timer.queue_free()
|
||||
cooldown_timer = null
|
||||
|
||||
cooldown_email = email
|
||||
if cooldown_email == "":
|
||||
cooldown_email = register_email.text.strip_edges()
|
||||
|
||||
send_code_btn.disabled = true
|
||||
send_code_btn.text = "重新发送(60)"
|
||||
var remaining_time = auth_manager.get_remaining_cooldown_time(cooldown_email)
|
||||
if remaining_time <= 0:
|
||||
remaining_time = 60
|
||||
send_code_btn.text = "重新发送(%d)" % remaining_time
|
||||
|
||||
cooldown_timer = Timer.new()
|
||||
add_child(cooldown_timer)
|
||||
@@ -444,7 +452,8 @@ func _start_cooldown_timer(_email: String):
|
||||
|
||||
# 冷却计时器超时处理
|
||||
func _on_cooldown_timer_timeout():
|
||||
var remaining_time = auth_manager.get_remaining_cooldown_time(register_email.text.strip_edges())
|
||||
var email = cooldown_email if cooldown_email != "" else register_email.text.strip_edges()
|
||||
var remaining_time = auth_manager.get_remaining_cooldown_time(email)
|
||||
|
||||
if remaining_time > 0:
|
||||
send_code_btn.text = "重新发送(%d)" % remaining_time
|
||||
@@ -462,6 +471,7 @@ func _reset_verification_button():
|
||||
cooldown_timer.queue_free()
|
||||
cooldown_timer = null
|
||||
|
||||
cooldown_email = ""
|
||||
send_code_btn.disabled = false
|
||||
send_code_btn.text = "发送验证码"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user