feat(game): 支持玩家显示名称的多种数据源

- 在麻将游戏页面中添加本地缓存头像URL的优先级处理
- 为玩家座位信息添加自定义显示名称功能
- 支持从player_name或PlayerName字段获取玩家名称
- 实现当前用户显示名称的回退逻辑
- 更新API接口定义以支持可选的玩家名称字段
This commit is contained in:
2026-03-25 21:15:40 +08:00
parent 6168117eb2
commit ae5d8d48c4
3 changed files with 8 additions and 1 deletions

View File

@@ -131,6 +131,10 @@ function mapRoomPlayers(room: RoomItem): RoomPlayerState[] {
.map((item, fallbackIndex) => ({
index: Number.isFinite(item.index) ? item.index : fallbackIndex,
playerId: item.player_id,
displayName:
(typeof item.player_name === 'string' && item.player_name) ||
(typeof item.PlayerName === 'string' && item.PlayerName) ||
(item.player_id === currentUserId.value ? displayName.value : undefined),
ready: Boolean(item.ready),
hand: [],
melds: [],