From dc09c7e4874932347864f28b4dd980520500533c Mon Sep 17 00:00:00 2001 From: wsy182 <2392948297@qq.com> Date: Fri, 27 Mar 2026 16:14:22 +0800 Subject: [PATCH] =?UTF-8?q?feat(game):=20=E5=AE=9E=E7=8E=B0=E9=BA=BB?= =?UTF-8?q?=E5=B0=86=E6=89=8B=E7=89=8C=E6=8C=89=E8=8A=B1=E8=89=B2=E5=88=86?= =?UTF-8?q?=E7=BB=84=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 HandSuitLabel 类型定义区分万筒条三种花色 - 创建手牌花色排序映射和标签映射配置 - 实现 visibleHandTileGroups 计算属性按花色对手牌进行分组 - 新增 player-hand-group 样式类支持分组布局 - 调整 tile-chip 尺寸适配新的分组显示方式 - 修改底部控制面板位置避免遮挡手牌区域 --- src/assets/styles/room.css | 23 ++++++---- src/views/ChengduGamePage.vue | 80 +++++++++++++++++++++++++++++------ 2 files changed, 81 insertions(+), 22 deletions(-) diff --git a/src/assets/styles/room.css b/src/assets/styles/room.css index fe06ac1..2675b63 100644 --- a/src/assets/styles/room.css +++ b/src/assets/styles/room.css @@ -807,7 +807,7 @@ .bottom-control-panel { position: absolute; left: 50%; - bottom: 8px; + bottom: 100px; transform: translateX(-50%); width: min(100% - 120px, 1180px); padding: 8px 14px 12px; @@ -880,17 +880,24 @@ display: flex; align-items: flex-end; justify-content: center; - gap: 4px; + gap: 12px; overflow-x: auto; padding-bottom: 2px; } +.player-hand-group { + display: flex; + align-items: flex-end; + gap: 0; + flex-shrink: 0; +} + .tile-chip { display: flex; align-items: flex-end; justify-content: center; - min-width: 90px; - height: 126px; + min-width: 74px; + height: 104px; padding: 0; border: 0; background: transparent; @@ -1083,8 +1090,8 @@ } .tile-chip { - min-width: 70px; - height: 102px; + min-width: 60px; + height: 88px; font-size: 24px; } @@ -1160,8 +1167,8 @@ } .tile-chip { - min-width: 48px; - height: 76px; + min-width: 42px; + height: 64px; font-size: 16px; } diff --git a/src/views/ChengduGamePage.vue b/src/views/ChengduGamePage.vue index a00bbe7..927a832 100644 --- a/src/views/ChengduGamePage.vue +++ b/src/views/ChengduGamePage.vue @@ -51,6 +51,7 @@ type DisplayPlayer = PlayerState & { } type GameActionPayload = Extract['payload'] +type HandSuitLabel = '万' | '筒' | '条' interface SeatViewModel { key: SeatKey @@ -132,6 +133,51 @@ const myHandTiles = computed(() => { return myPlayer.value?.handTiles ?? [] }) +const handSuitOrder: Record = { + W: 0, + T: 1, + B: 2, +} + +const handSuitLabelMap: Record = { + W: '万', + T: '筒', + B: '条', +} + +const visibleHandTileGroups = computed(() => { + const grouped = new Map() + + myHandTiles.value + .slice() + .sort((left, right) => { + const suitDiff = handSuitOrder[left.suit] - handSuitOrder[right.suit] + if (suitDiff !== 0) { + return suitDiff + } + + const valueDiff = left.value - right.value + if (valueDiff !== 0) { + return valueDiff + } + + return left.id - right.id + }) + .forEach((tile) => { + const label = handSuitLabelMap[tile.suit] + const current = grouped.get(label) ?? [] + current.push(tile) + grouped.set(label, current) + }) + + return (['万', '筒', '条'] as HandSuitLabel[]) + .map((suit) => ({ + suit, + tiles: grouped.get(suit) ?? [], + })) + .filter((group) => group.tiles.length > 0) +}) + const visibleHandTiles = computed(() => { if (gameStore.phase === 'waiting') { return [] @@ -1517,21 +1563,27 @@ onBeforeUnmount(() => {
- - + +