fix 扫雷格子和头像

This commit is contained in:
tsui110 2026-01-02 22:44:17 +08:00
parent 41bf14eb8f
commit 191895567c
2 changed files with 28 additions and 2 deletions

View File

@ -712,6 +712,8 @@
background: $bg-dark-card;
border-radius: $radius-lg;
border: 1px solid $border-dark;
// 确保格子始终保持正方形
aspect-ratio: 1 / 1;
}
.grid-cell {
@ -722,6 +724,10 @@
align-items: center;
transition: all $transition-fast;
position: relative;
// 确保每个格子都是正方形
aspect-ratio: 1 / 1;
width: 100%;
height: auto;
&:active {
transform: scale(0.95);

View File

@ -103,7 +103,7 @@
'healed': healedPlayers.includes(p.userId)
}"
>
<text class="avatar">{{ p.avatar }}</text>
<text class="avatar">{{ getPlayerAvatar(p) }}</text>
<view class="player-info">
<text class="username">{{ p.username || '对手' }}</text>
<view class="hp-bar">
@ -193,7 +193,7 @@
'healed': healedPlayers.includes(myPlayer.userId)
}"
>
<text class="avatar lg">{{ myPlayer.avatar }}</text>
<text class="avatar lg">{{ getPlayerAvatar(myPlayer) }}</text>
<view class="player-info">
<text class="username font-bold"></text>
<view class="hp-bar">
@ -660,6 +660,26 @@ export default {
if (content === 'empty') return '✅';
return this.getItemIcon(content);
},
getPlayerAvatar(player) {
// avatar使
if (player.avatar) {
return player.avatar;
}
// userIdusername
const avatars = ['🐶', '🐘', '🐯', '🐵', '🦥', '🦛'];
// 使userIdusername
const seed = player.userId || player.username || player.id || '';
let hash = 0;
for (let i = 0; i < seed.length; i++) {
hash = ((hash << 5) - hash) + seed.charCodeAt(i);
hash = hash & hash; // 32
}
const index = Math.abs(hash) % avatars.length;
return avatars[index];
},
getNumColor(n) { return ['','blue','green','red','purple','orange'][n] || 'black'; },
getOpCodeName(code) {
const map = {