refactor(game): 重构缺门花色处理逻辑并优化组件结构
- 移除硬编码的花色图标导入,改用动态加载方式 - 添加新的 flowerColorMap 配置文件统一管理缺门图标 - 引入 clearActiveRoom 函数用于清理活动房间状态 - 在游戏数据解析中添加缺失花色的读取函数 - 当房间数据为空时自动清理房间状态并跳转回大厅 - 统一玩家缺门花色数据处理逻辑 - 注释掉浮动状态显示区域以优化界面布局 - 调整CSS样式中缺门标记尺寸和旋转效果 - 在游戏存储模块中添加清除快照功能 - 重构座位玩家卡片组件中的花色图标计算逻辑 - 优化花色标签映射和归一化处理函数
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import wanIcon from '../../assets/images/flowerClolor/wan.png'
|
||||
import tongIcon from '../../assets/images/flowerClolor/tong.png'
|
||||
import tiaoIcon from '../../assets/images/flowerClolor/tiao.png'
|
||||
import defaultAvatarIcon from '../../assets/images/icons/avatar.svg'
|
||||
import { getLackSuitImage } from '../../config/flowerColorMap'
|
||||
import type { Suit } from '../../types/tile'
|
||||
import type { SeatPlayerCardModel } from './seat-player-card'
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -11,17 +10,26 @@ const props = defineProps<{
|
||||
player: SeatPlayerCardModel
|
||||
}>()
|
||||
|
||||
function normalizeMissingSuit(value: string): Suit | null {
|
||||
const normalized = value.trim().toLowerCase()
|
||||
const missingSuitMap: Record<string, Suit> = {
|
||||
万: 'W',
|
||||
筒: 'T',
|
||||
条: 'B',
|
||||
w: 'W',
|
||||
t: 'T',
|
||||
b: 'B',
|
||||
wan: 'W',
|
||||
tong: 'T',
|
||||
tiao: 'B',
|
||||
}
|
||||
|
||||
return missingSuitMap[normalized] ?? null
|
||||
}
|
||||
|
||||
const missingSuitIcon = computed(() => {
|
||||
if (props.player.missingSuitLabel === '万') {
|
||||
return wanIcon
|
||||
}
|
||||
if (props.player.missingSuitLabel === '筒') {
|
||||
return tongIcon
|
||||
}
|
||||
if (props.player.missingSuitLabel === '条') {
|
||||
return tiaoIcon
|
||||
}
|
||||
return ''
|
||||
const suit = normalizeMissingSuit(props.player.missingSuitLabel)
|
||||
return suit ? getLackSuitImage(suit) : ''
|
||||
})
|
||||
|
||||
const resolvedAvatarUrl = computed(() => {
|
||||
|
||||
Reference in New Issue
Block a user