Merge main into qbb0530-main: 解决冲突并保留聊天和位置同步功能
This commit is contained in:
@@ -102,9 +102,10 @@ var _game_token: String = "" # @deprecated 使用 _access_token 替代
|
||||
# 初始化管理器
|
||||
func _init() -> void:
|
||||
_load_auth_data()
|
||||
print("AuthManager 初始化完成")
|
||||
|
||||
# 清理资源
|
||||
func cleanup() -> void:
|
||||
func cleanup():
|
||||
# 取消所有活动的网络请求
|
||||
for request_id in active_request_ids:
|
||||
NetworkManager.cancel_request(request_id)
|
||||
@@ -265,6 +266,7 @@ func get_refresh_token() -> String:
|
||||
func get_user_info() -> Dictionary:
|
||||
return _user_info
|
||||
|
||||
|
||||
# ============ 登录相关方法 ============
|
||||
|
||||
# 执行密码登录
|
||||
@@ -593,21 +595,19 @@ func validate_verification_code(code: String) -> Dictionary:
|
||||
# ============ 网络响应处理 ============
|
||||
|
||||
# 处理登录响应
|
||||
func _on_login_response(success: bool, data: Dictionary, error_info: Dictionary) -> void:
|
||||
func _on_login_response(success: bool, data: Dictionary, error_info: Dictionary):
|
||||
_reset_login_state()
|
||||
|
||||
|
||||
var result = ResponseHandler.handle_login_response(success, data, error_info)
|
||||
|
||||
|
||||
if result.should_show_toast:
|
||||
show_toast_message.emit(result.message, result.success)
|
||||
|
||||
|
||||
if result.success:
|
||||
# 保存 Token 到内存和本地
|
||||
_save_tokens_to_memory(data)
|
||||
_save_tokens_to_local(data)
|
||||
|
||||
var username: String = _user_info.get("username", "")
|
||||
|
||||
var username = ""
|
||||
if data.has("data") and data.data.has("user") and data.data.user.has("username"):
|
||||
username = data.data.user.username
|
||||
|
||||
# 延迟发送登录成功信号
|
||||
await Engine.get_main_loop().create_timer(1.0).timeout
|
||||
login_success.emit(username)
|
||||
@@ -615,21 +615,19 @@ func _on_login_response(success: bool, data: Dictionary, error_info: Dictionary)
|
||||
login_failed.emit(result.message)
|
||||
|
||||
# 处理验证码登录响应
|
||||
func _on_verification_login_response(success: bool, data: Dictionary, error_info: Dictionary) -> void:
|
||||
func _on_verification_login_response(success: bool, data: Dictionary, error_info: Dictionary):
|
||||
_reset_login_state()
|
||||
|
||||
|
||||
var result = ResponseHandler.handle_verification_code_login_response(success, data, error_info)
|
||||
|
||||
|
||||
if result.should_show_toast:
|
||||
show_toast_message.emit(result.message, result.success)
|
||||
|
||||
|
||||
if result.success:
|
||||
# 保存 Token 到内存和本地
|
||||
_save_tokens_to_memory(data)
|
||||
_save_tokens_to_local(data)
|
||||
|
||||
var username: String = _user_info.get("username", "")
|
||||
|
||||
var username = ""
|
||||
if data.has("data") and data.data.has("user") and data.data.user.has("username"):
|
||||
username = data.data.user.username
|
||||
|
||||
await Engine.get_main_loop().create_timer(1.0).timeout
|
||||
login_success.emit(username)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user