feat(game): 添加游戏大厅音频控制和用户协议功能

- 实现音频资源配置和音频商店状态管理
- 添加用户协议和游戏规则的多语言支持
- 集成音频播放解锁机制和声音开关功能
- 更新API客户端以支持根路径候选
- 优化游戏历史记录组件的滚动加载逻辑
- 添加桌面端控制按钮的动画效果和交互反馈
- 实现语言切换和音效控制的UI组件
- 增加下注相关的状态管理和错误提示
- 完善应用偏好设置的存储和持久化逻辑
This commit is contained in:
JiaJun
2026-05-16 18:02:59 +08:00
parent 5dd4e31db4
commit 85b4d9481f
46 changed files with 1500 additions and 362 deletions

View File

@@ -0,0 +1,81 @@
import { DEFAULT_CHIP_AMOUNTS } from '@/constants'
import { DEFAULT_GAME_CHIP_COLORS, GAME_MAX_SELECTION_CELLS } from './constants'
import type {
AnnouncementState,
Chip,
ConnectionState,
DashboardState,
GameBootstrapSnapshot,
RoundSnapshot,
} from './types'
function createEmptyRoundSnapshot(nowIso: string): RoundSnapshot {
return {
bettingClosesAt: nowIso,
id: '',
phase: 'waiting',
revealingAt: nowIso,
settledAt: null,
startedAt: nowIso,
winningCellId: null,
}
}
function createEmptyAnnouncementState(): AnnouncementState {
return {
activeAnnouncementId: null,
items: [],
lastUpdatedAt: null,
}
}
function createEmptyConnectionState(): ConnectionState {
return {
connectedAt: null,
lastError: null,
lastMessageAt: null,
latencyMs: null,
reconnectAttempt: 0,
status: 'idle',
transport: 'offline',
}
}
function createEmptyDashboardState(nowIso: string): DashboardState {
return {
countdownMs: 0,
featuredCellId: null,
onlinePlayers: 0,
tableLimitMax: 0,
tableLimitMin: 0,
totalPoolAmount: 0,
updatedAt: nowIso,
}
}
function createDefaultChips(): Chip[] {
return DEFAULT_CHIP_AMOUNTS.map((chip, index) => ({
amount: chip.amount,
color: DEFAULT_GAME_CHIP_COLORS[index] ?? DEFAULT_GAME_CHIP_COLORS[0],
id: chip.id,
isDefault: chip.id === 'chip-5',
label: String(chip.amount),
}))
}
export function createEmptyGameBootstrapSnapshot(
nowIso = new Date().toISOString(),
): GameBootstrapSnapshot {
return {
announcements: createEmptyAnnouncementState(),
cells: [],
chips: createDefaultChips(),
connection: createEmptyConnectionState(),
dashboard: createEmptyDashboardState(nowIso),
history: [],
maxSelectionCount: GAME_MAX_SELECTION_CELLS,
round: createEmptyRoundSnapshot(nowIso),
selections: [],
trends: [],
}
}