feat: 支持新的关卡数据结构

This commit is contained in:
richarjiang
2026-04-19 13:27:10 +08:00
parent 1d6cd0cdc0
commit e6079e4345
33 changed files with 882 additions and 2843 deletions

View File

@@ -91,8 +91,8 @@ Authorization: Bearer <token>
| 属性 | 值 |
|------|-----|
| 默认体力 | 5新用户注册时 |
| 上限 | 5 |
| 默认体力 | 50(新用户注册时) |
| 上限 | 50 |
| 恢复速度 | 每 **10 分钟** 恢复 1 点 |
| 消耗 | 进入**未通关**关卡时消耗 1 点 |
| 已通关关卡 | 再次进入不消耗体力 |
@@ -104,7 +104,7 @@ Authorization: Bearer <token>
```typescript
interface StaminaInfo {
current: number; // 当前体力值(已计算恢复)
max: number; // 体力上限,固定为 5
max: number; // 体力上限,固定为 50
nextRecoverAt: string | null; // 下一点体力恢复的时间ISO 8601满体力时为 null
}
```
@@ -113,8 +113,8 @@ interface StaminaInfo {
```json
{
"current": 3,
"max": 5,
"current": 45,
"max": 50,
"nextRecoverAt": "2026-04-10T12:10:00.000Z"
}
```
@@ -168,7 +168,7 @@ interface StaminaInfo {
"user": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"nickname": null,
"stamina": 5
"stamina": 50
}
},
"message": null,
@@ -211,8 +211,8 @@ interface StaminaInfo {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"nickname": null,
"stamina": {
"current": 3,
"max": 5,
"current": 45,
"max": 50,
"nextRecoverAt": "2026-04-10T12:10:00.000Z"
}
},
@@ -258,8 +258,8 @@ interface StaminaInfo {
"user": {
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"stamina": {
"current": 5,
"max": 5,
"current": 50,
"max": 50,
"nextRecoverAt": null
}
},
@@ -278,7 +278,7 @@ interface StaminaInfo {
### 4. 获取关卡列表
获取所有关卡列表。**已通关的关卡**返回答案和线索,**未通关的关卡**不返回敏感数据。
获取所有关卡列表。**已通关的关卡**返回答案、谐音梗说明和线索,**未通关的关卡**不返回敏感数据。
**接口地址**`GET /api/v1/levels`
@@ -297,8 +297,12 @@ interface StaminaInfo {
interface LevelListItem {
id: string; // 关卡 ID
level: number; // 关卡编号(从 1 开始)
imageUrl: string; // 关卡图片 URL
image1Url: string; // 图片1 URL
image1Description: string | null; // 图片1 文本说明
image2Url: string; // 图片2 URL
image2Description: string | null; // 图片2 文本说明
answer: string | null; // 答案(仅已通关时返回,否则 null
punchline: string | null; // 谐音梗说明(仅已通关时返回,否则 null
hint1: string | null; // 线索1仅已通关时返回否则 null
hint2: string | null; // 线索2仅已通关时返回否则 null
hint3: string | null; // 线索3仅已通关时返回否则 null
@@ -317,8 +321,12 @@ interface LevelListItem {
{
"id": "level_001",
"level": 1,
"imageUrl": "https://cdn.example.com/levels/001.png",
"image1Url": "https://cdn.example.com/levels/001_1.png",
"image1Description": "一只猫在看鱼",
"image2Url": "https://cdn.example.com/levels/001_2.png",
"image2Description": "一条鱼在飞",
"answer": "梗答案",
"punchline": "谐音梗:鱼和猫的故事",
"hint1": "这是一个经典的...",
"hint2": "和某个明星有关",
"hint3": null,
@@ -328,8 +336,12 @@ interface LevelListItem {
{
"id": "level_002",
"level": 2,
"imageUrl": "https://cdn.example.com/levels/002.png",
"image1Url": "https://cdn.example.com/levels/002_1.png",
"image1Description": "一个人在走路",
"image2Url": "https://cdn.example.com/levels/002_2.png",
"image2Description": "一辆车在跑",
"answer": null,
"punchline": null,
"hint1": null,
"hint2": null,
"hint3": null,
@@ -346,8 +358,9 @@ interface LevelListItem {
**客户端使用说明**
- 关卡选择页面使用此接口获取关卡列表
- 每个关卡有两张图片(`image1Url``image2Url`)和对应的文本说明
- 根据 `completed` 字段展示不同的 UI 状态(已通关/未通关)
- 未通关关卡的 `answer``hint1``hint2``hint3` 均为 `null`**客户端不应缓存这些字段**
- 未通关关卡的 `answer``punchline``hint1``hint2``hint3` 均为 `null`**客户端不应缓存这些字段**
---
@@ -373,8 +386,12 @@ interface LevelListItem {
{
id: string;
level: number;
imageUrl: string;
image1Url: string;
image1Description: string | null;
image2Url: string;
image2Description: string | null;
answer: string;
punchline: string | null;
hint1: string | null;
hint2: string | null;
hint3: string | null;
@@ -390,14 +407,18 @@ interface LevelListItem {
"data": {
"id": "level_002",
"level": 2,
"imageUrl": "https://cdn.example.com/levels/002.png",
"image1Url": "https://cdn.example.com/levels/002_1.png",
"image1Description": "一个人在走路",
"image2Url": "https://cdn.example.com/levels/002_2.png",
"image2Description": "一辆车在跑",
"answer": "这是答案",
"punchline": "谐音梗:走和跑的故事",
"hint1": "第一个线索",
"hint2": "第二个线索",
"hint3": null,
"stamina": {
"current": 2,
"max": 5,
"current": 47,
"max": 50,
"nextRecoverAt": "2026-04-10T12:10:00.000Z"
}
},
@@ -658,7 +679,9 @@ interface GameState {
currentLevel: { // 当前正在玩的关卡
id: string;
answer: string;
punchline: string | null;
hints: (string | null)[];
images: { url: string; description: string | null }[];
startTime: number; // 开始时间戳,用于计算 timeSpent
} | null;
}
@@ -823,8 +846,12 @@ async function loadGameData(): Promise<GameData> {
interface LevelListItem {
id: string;
level: number;
imageUrl: string;
image1Url: string;
image1Description: string | null;
image2Url: string;
image2Description: string | null;
answer: string | null;
punchline: string | null;
hint1: string | null;
hint2: string | null;
hint3: string | null;
@@ -847,8 +874,12 @@ async function getLevels(): Promise<LevelListItem[]> {
interface EnterLevelResponse {
id: string;
level: number;
imageUrl: string;
image1Url: string;
image1Description: string | null;
image2Url: string;
image2Description: string | null;
answer: string;
punchline: string | null;
hint1: string | null;
hint2: string | null;
hint3: string | null;
@@ -969,4 +1000,6 @@ export class GameEntry extends Component {
4. **已通关关卡免费进入**:已通关关卡再次进入不消耗体力
5. **通关上报仅限成功**:只在用户答对后调用 `complete` 接口,答错不需要上报
6. **hint 字段**`hint1/hint2/hint3` 可能为 `null`,表示该线索未配置
7. **网络异常处理**:建议所有接口调用加 loading 状态,并处理 401重新登录和网络错误
7. **punchline 字段**:谐音梗说明,仅已通关时返回,未通关时为 `null`
8. **双图结构**:每个关卡有两张图片(`image1Url``image2Url`),分别有对应的文本说明
9. **网络异常处理**:建议所有接口调用加 loading 状态,并处理 401重新登录和网络错误