feat: 增加通知板场景

- 增加通知板与用户交互,点击E,弹出通知消息
- 预留前端调用后端获取通知的接口,当不可用时,使用mock data
This commit is contained in:
2026-01-11 01:55:19 +08:00
parent 449cd1e8f3
commit 75eb227b18
11 changed files with 387 additions and 6 deletions

View File

@@ -38,15 +38,17 @@ signal request_completed(request_id: String, success: bool, data: Dictionary)
# message: String - 错误消息
signal request_failed(request_id: String, error_type: String, message: String)
# 公告列表接收信号
signal notices_received(data: Array)
# ============ 常量定义 ============
# API基础URL - 所有请求的根地址
# [Remote] 正式环境地址 (实际正式项目用此地址)
# [Remote] 正式环境地址 (实际正式项目用此地址)
const API_BASE_URL = "https://whaletownend.xinghangee.icu"
# const API_BASE_URL = "https://whaletownend.xinghangee.icu"
# [Local] 本地调试地址 (本地调试用此地址)
# const API_BASE_URL = "http://localhost:3000"
const API_BASE_URL = "http://localhost:3000"
# 默认请求超时时间(秒)
const DEFAULT_TIMEOUT = 30.0
@@ -119,6 +121,7 @@ var request_counter: int = 0 # 请求计数器,用于
# 初始化网络管理器
# 在节点准备就绪时调用
func _ready():
process_mode = Node.PROCESS_MODE_ALWAYS
print("NetworkManager 已初始化")
# ============ 公共API接口 ============
@@ -441,6 +444,18 @@ func github_login(github_id: String, username: String, nickname: String, email:
return post_request("/auth/github", data, callback)
# TODO: 获取公告列表
func request_notices():
# 发送 GET 请求到 /notices 接口
get_request("/notices", _on_notices_response)
func _on_notices_response(success: bool, data: Dictionary, error_info: Dictionary):
if success and data.has("data"):
notices_received.emit(data["data"])
else:
# 失败或无数据时发送空数组
notices_received.emit([])
# ============ 核心请求处理 ============
# 发送请求的核心方法