fix: 修复GDScript警告和UID冲突问题
代码修复: - NetworkManager.gd: 修复参数名冲突和未使用变量警告 - StringUtils.gd: 修复变量名与内置函数char冲突 - ResponseHandler.gd: 移除static关键字,改为实例方法 - AuthScene.gd: 恢复正确的ResponseHandler调用方式 资源清理: - 删除assets/sprites/icon/下的重复图标文件 - 删除UI/Theme/下的重复字体和主题文件 - 统一使用assets/路径下的资源文件 配置修复: - 修复LoginWindow.tscn和main_scene.tscn中的UID引用 - 更新chinese_theme.tres中的字体路径引用 - 添加project.godot调试设置以减少渲染器警告 文档更新: - 更新项目设置指南中的主题和字体路径引用 解决问题: - 修复所有GDScript编译警告 - 解决UID重复冲突警告 - 统一资源文件路径结构 - 保持Web部署兼容性
This commit is contained in:
@@ -206,8 +206,8 @@ func send_request(endpoint: String, method: RequestType, headers: PackedStringAr
|
||||
active_requests[request_id] = request_info
|
||||
|
||||
# 连接信号
|
||||
http_request.request_completed.connect(func(result: int, response_code: int, headers: PackedStringArray, body: PackedByteArray):
|
||||
_on_request_completed(request_id, result, response_code, headers, body)
|
||||
http_request.request_completed.connect(func(result: int, response_code: int, response_headers: PackedStringArray, response_body: PackedByteArray):
|
||||
_on_request_completed(request_id, result, response_code, response_headers, response_body)
|
||||
)
|
||||
|
||||
# 发送请求
|
||||
@@ -243,7 +243,7 @@ func _on_request_completed(request_id: String, result: int, response_code: int,
|
||||
print("警告: 未找到请求ID ", request_id)
|
||||
return
|
||||
|
||||
var request_info = active_requests[request_id]
|
||||
var _request_info = active_requests[request_id]
|
||||
var response_text = body.get_string_from_utf8()
|
||||
|
||||
print("响应体长度: ", body.size(), " 字节")
|
||||
|
||||
@@ -84,7 +84,7 @@ const HTTP_STATUS_MESSAGES = {
|
||||
# ============ 主要处理方法 ============
|
||||
|
||||
# 处理登录响应
|
||||
static func handle_login_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
func handle_login_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
|
||||
if success:
|
||||
@@ -103,7 +103,7 @@ static func handle_login_response(success: bool, data: Dictionary, error_info: D
|
||||
return result
|
||||
|
||||
# 处理验证码登录响应
|
||||
static func handle_verification_code_login_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
func handle_verification_code_login_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
|
||||
if success:
|
||||
@@ -121,7 +121,7 @@ static func handle_verification_code_login_response(success: bool, data: Diction
|
||||
return result
|
||||
|
||||
# 处理发送验证码响应 - 支持邮箱冲突检测
|
||||
static func handle_send_verification_code_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
func handle_send_verification_code_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
|
||||
if success:
|
||||
@@ -149,7 +149,7 @@ static func handle_send_verification_code_response(success: bool, data: Dictiona
|
||||
return result
|
||||
|
||||
# 处理发送登录验证码响应
|
||||
static func handle_send_login_code_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
func handle_send_login_code_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
|
||||
if success:
|
||||
@@ -174,7 +174,7 @@ static func handle_send_login_code_response(success: bool, data: Dictionary, err
|
||||
return result
|
||||
|
||||
# 处理注册响应
|
||||
static func handle_register_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
func handle_register_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
|
||||
if success:
|
||||
@@ -193,7 +193,7 @@ static func handle_register_response(success: bool, data: Dictionary, error_info
|
||||
return result
|
||||
|
||||
# 处理邮箱验证响应
|
||||
static func handle_verify_email_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
func handle_verify_email_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
|
||||
if success:
|
||||
@@ -207,7 +207,7 @@ static func handle_verify_email_response(success: bool, data: Dictionary, error_
|
||||
return result
|
||||
|
||||
# 处理重新发送邮箱验证码响应
|
||||
static func handle_resend_email_verification_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
func handle_resend_email_verification_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
|
||||
if success:
|
||||
@@ -232,7 +232,7 @@ static func handle_resend_email_verification_response(success: bool, data: Dicti
|
||||
return result
|
||||
|
||||
# 处理忘记密码响应
|
||||
static func handle_forgot_password_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
func handle_forgot_password_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
|
||||
if success:
|
||||
@@ -257,7 +257,7 @@ static func handle_forgot_password_response(success: bool, data: Dictionary, err
|
||||
return result
|
||||
|
||||
# 处理重置密码响应
|
||||
static func handle_reset_password_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
func handle_reset_password_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
|
||||
if success:
|
||||
@@ -273,7 +273,7 @@ static func handle_reset_password_response(success: bool, data: Dictionary, erro
|
||||
# ============ 错误处理方法 ============
|
||||
|
||||
# 处理登录错误
|
||||
static func _handle_login_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
func _handle_login_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
var error_code = data.get("error_code", "")
|
||||
var message = data.get("message", "登录失败")
|
||||
@@ -297,7 +297,7 @@ static func _handle_login_error(data: Dictionary, error_info: Dictionary) -> Res
|
||||
return result
|
||||
|
||||
# 处理验证码登录错误
|
||||
static func _handle_verification_code_login_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
func _handle_verification_code_login_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
var error_code = data.get("error_code", "")
|
||||
var message = data.get("message", "验证码登录失败")
|
||||
@@ -317,7 +317,7 @@ static func _handle_verification_code_login_error(data: Dictionary, error_info:
|
||||
return result
|
||||
|
||||
# 处理发送验证码错误 - 支持邮箱冲突检测和频率限制
|
||||
static func _handle_send_code_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
func _handle_send_code_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
var error_code = data.get("error_code", "")
|
||||
var message = data.get("message", "发送验证码失败")
|
||||
@@ -361,7 +361,7 @@ static func _handle_send_code_error(data: Dictionary, error_info: Dictionary) ->
|
||||
return result
|
||||
|
||||
# 处理发送登录验证码错误
|
||||
static func _handle_send_login_code_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
func _handle_send_login_code_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
var error_code = data.get("error_code", "")
|
||||
var message = data.get("message", "发送登录验证码失败")
|
||||
@@ -382,7 +382,7 @@ static func _handle_send_login_code_error(data: Dictionary, error_info: Dictiona
|
||||
return result
|
||||
|
||||
# 处理注册错误 - 支持409冲突状态码
|
||||
static func _handle_register_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
func _handle_register_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
var error_code = data.get("error_code", "")
|
||||
var message = data.get("message", "注册失败")
|
||||
@@ -416,7 +416,7 @@ static func _handle_register_error(data: Dictionary, error_info: Dictionary) ->
|
||||
return result
|
||||
|
||||
# 处理邮箱验证错误
|
||||
static func _handle_verify_email_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
func _handle_verify_email_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
var error_code = data.get("error_code", "")
|
||||
var message = data.get("message", "邮箱验证失败")
|
||||
@@ -439,7 +439,7 @@ static func _handle_verify_email_error(data: Dictionary, error_info: Dictionary)
|
||||
return result
|
||||
|
||||
# 处理网络测试响应
|
||||
static func handle_network_test_response(success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
func handle_network_test_response(success: bool, _data: Dictionary, _error_info: Dictionary = {}) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
|
||||
if success:
|
||||
@@ -454,7 +454,7 @@ static func handle_network_test_response(success: bool, data: Dictionary, error_
|
||||
return result
|
||||
|
||||
# 处理重新发送邮箱验证码错误
|
||||
static func _handle_resend_email_verification_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
func _handle_resend_email_verification_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
var error_code = data.get("error_code", "")
|
||||
var message = data.get("message", "重新发送验证码失败")
|
||||
@@ -471,7 +471,7 @@ static func _handle_resend_email_verification_error(data: Dictionary, error_info
|
||||
return result
|
||||
|
||||
# 处理忘记密码错误
|
||||
static func _handle_forgot_password_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
func _handle_forgot_password_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
var error_code = data.get("error_code", "")
|
||||
var message = data.get("message", "发送重置验证码失败")
|
||||
@@ -490,7 +490,7 @@ static func _handle_forgot_password_error(data: Dictionary, error_info: Dictiona
|
||||
return result
|
||||
|
||||
# 处理重置密码错误
|
||||
static func _handle_reset_password_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
func _handle_reset_password_error(data: Dictionary, error_info: Dictionary) -> ResponseResult:
|
||||
var result = ResponseResult.new()
|
||||
var error_code = data.get("error_code", "")
|
||||
var message = data.get("message", "重置密码失败")
|
||||
@@ -509,7 +509,7 @@ static func _handle_reset_password_error(data: Dictionary, error_info: Dictionar
|
||||
# ============ 工具方法 ============
|
||||
|
||||
# 获取错误消息 - 支持更多状态码和错误处理
|
||||
static func _get_error_message(error_code: String, original_message: String, error_info: Dictionary) -> String:
|
||||
func _get_error_message(error_code: String, original_message: String, error_info: Dictionary) -> String:
|
||||
# 优先使用错误码映射
|
||||
if ERROR_CODE_MESSAGES.has(error_code):
|
||||
return ERROR_CODE_MESSAGES[error_code]
|
||||
@@ -544,17 +544,17 @@ static func _get_error_message(error_code: String, original_message: String, err
|
||||
return original_message if original_message != "" else "操作失败"
|
||||
|
||||
# 处理频率限制消息
|
||||
static func _handle_rate_limit_message(message: String, error_info: Dictionary) -> String:
|
||||
func _handle_rate_limit_message(message: String, _error_info: Dictionary) -> String:
|
||||
# 可以根据throttle_info提供更详细的信息
|
||||
return message + ",请稍后再试"
|
||||
|
||||
# 处理维护模式消息
|
||||
static func _handle_maintenance_message(message: String, error_info: Dictionary) -> String:
|
||||
func _handle_maintenance_message(_message: String, _error_info: Dictionary) -> String:
|
||||
# 可以根据maintenance_info提供更详细的信息
|
||||
return "系统维护中,请稍后再试"
|
||||
|
||||
# 通用响应处理器 - 支持更多操作类型
|
||||
static func handle_response(operation_type: String, success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
func handle_response(operation_type: String, success: bool, data: Dictionary, error_info: Dictionary = {}) -> ResponseResult:
|
||||
match operation_type:
|
||||
"login":
|
||||
return handle_login_response(success, data, error_info)
|
||||
|
||||
Reference in New Issue
Block a user