feat: 接入关卡配置 API 并支持降级到本地配置

- 新增 LevelDataManager 单例管理关卡数据
- 新增 HttpUtil 封装 XMLHttpRequest 请求
- 新增 LevelTypes 类型定义
- PageLoading 集成 API 数据预加载(0-80% 进度)
- PageLevel 支持优先使用 API 数据,失败时降级到本地配置
- 字段映射: hint1/2/3 → clue1/2/3, imageUrl → SpriteFrame
This commit is contained in:
richarjiang
2026-03-15 16:07:00 +08:00
parent c9fbc5212a
commit c54a404c12
5 changed files with 430 additions and 18 deletions

View File

@@ -0,0 +1,53 @@
import { SpriteFrame } from 'cc';
/**
* API 返回的单个关卡数据结构
*/
export interface ApiLevelData {
/** 关卡 ID */
id: number;
/** 关卡名称 */
name: string;
/** 主图 URL */
imageUrl: string;
/** 线索1映射到 clue1 */
hint1: string;
/** 线索2映射到 clue2 */
hint2: string;
/** 线索3映射到 clue3 */
hint3: string;
/** 答案 */
answer: string;
}
/**
* API 响应结构
*/
export interface ApiResponse {
/** 状态码0 表示成功 */
code: number;
/** 响应消息 */
message: string;
/** 关卡数据数组 */
data: ApiLevelData[];
}
/**
* 运行时关卡配置(包含已加载的图片)
*/
export interface RuntimeLevelConfig {
/** 关卡 ID */
id: number;
/** 关卡名称 */
name: string;
/** 主图 SpriteFrame可能为 null 如果加载失败) */
spriteFrame: SpriteFrame | null;
/** 线索1 */
clue1: string;
/** 线索2 */
clue2: string;
/** 线索3 */
clue3: string;
/** 答案 */
answer: string;
}