feat 小程序模式下禁止缩放棋盘

This commit is contained in:
tsui110 2026-01-05 11:59:39 +08:00
parent 5691d0601d
commit 96555e690c
3 changed files with 39 additions and 72 deletions

View File

@ -990,16 +990,11 @@
border: 1px solid $border-dark;
// 确保格子始终保持正方形
aspect-ratio: 1 / 1;
// 阻止长按缩放
touch-action: none;
// 防止双击缩放
touch-action: manipulation;
user-select: none;
-webkit-user-select: none;
-webkit-touch-callout: none;
// 额外的防护
-webkit-tap-highlight-color: transparent;
outline: none;
// 禁用任何手势
overscroll-behavior: none;
}
.grid-cell {
@ -1014,16 +1009,11 @@
aspect-ratio: 1 / 1;
width: 100%;
height: auto;
// 阻止长按弹出菜单和缩放
touch-action: none;
// 防止双击缩放和长按菜单
touch-action: manipulation;
user-select: none;
-webkit-user-select: none;
-webkit-touch-callout: none;
// 额外的防护
-webkit-tap-highlight-color: transparent;
outline: none;
// 禁用任何手势
overscroll-behavior: none;
&:active {
transform: scale(0.95);

View File

@ -82,7 +82,7 @@
</view>
<!-- 游戏主界面 -->
<view v-else class="game-screen">
<view v-else class="game-screen" :class="{ 'spectator-mode': isSpectator }">
<!-- 顶部状态栏 -->
<view class="game-header">
<view class="round-badge">Round {{ gameState.globalTurnCount || gameState.round || 0 }}</view>
@ -170,9 +170,7 @@
}
]"
@tap="handleCellClick(i)"
@touchstart="handleCellTouchStart(i, $event)"
@touchend="handleCellTouchEnd($event)"
@touchmove="handleCellTouchMove($event)"
catchtap="handleCellCatchTap(i)"
>
<view v-if="cell.revealed">
<text v-if="cell.type === 'bomb'" class="cell-icon">💣</text>
@ -345,7 +343,8 @@ export default {
onlineCount: 0,
onlineCountInterval: null,
spectatorFlags: {}, // { cellIndex: true }
longPressTimer: null, //
lastTapTime: 0, //
lastTapIndex: -1, //
// Timers
matchInterval: null,
turnInterval: null,
@ -884,11 +883,27 @@ export default {
this.addLog('system', '已切断匹配信号');
},
handleCellClick(idx) {
//
//
if (this.isSpectator) {
//
const now = Date.now();
const timeDiff = now - this.lastTapTime;
const isSameCell = this.lastTapIndex === idx;
// 300ms
if (isSameCell && timeDiff < 300) {
//
this.handleCellLongPress(idx);
this.lastTapTime = 0;
this.lastTapIndex = -1;
} else {
//
this.lastTapTime = now;
this.lastTapIndex = idx;
}
return;
}
//
if (!this.gameState?.gameStarted) {
uni.showToast({ title: '游戏尚未开始', icon: 'none' });
return;
@ -903,9 +918,15 @@ export default {
//
nakamaManager.sendMatchState(this.matchId, 3, JSON.stringify({ index: idx }));
},
//
//
handleCellCatchTap(idx) {
// catchtap
// @tap
// catchtap
},
//
handleCellLongPress(idx) {
//
//
if (!this.isSpectator) return;
if (!this.gameState?.grid) return;
if (this.gameState.grid[idx].revealed) return;
@ -917,53 +938,11 @@ export default {
} else {
this.$set(this.spectatorFlags, idx, true);
this.addLog('system', `🚩 在位置 ${idx} 插上了旗帜`);
}
},
// -
handleCellTouchStart(idx, event) {
//
if (!this.isSpectator) return;
//
if (event) {
event.preventDefault();
event.stopPropagation();
}
//
if (this.longPressTimer) {
clearTimeout(this.longPressTimer);
}
// 800ms
this.longPressTimer = setTimeout(() => {
//
// #ifndef MP-ALIPAY
uni.vibrateShort();
// #endif
this.handleCellLongPress(idx);
this.longPressTimer = null;
}, 800);
},
// -
handleCellTouchEnd(event) {
//
if (!this.isSpectator) return;
if (this.longPressTimer) {
clearTimeout(this.longPressTimer);
this.longPressTimer = null;
}
},
// -
handleCellTouchMove(event) {
//
if (!this.isSpectator) return;
//
if (this.longPressTimer) {
clearTimeout(this.longPressTimer);
this.longPressTimer = null;
}
},
refreshAndPlayAgain() {
@ -986,12 +965,6 @@ export default {
clearInterval(this.turnInterval);
clearInterval(this.onlineCountInterval);
//
if (this.longPressTimer) {
clearTimeout(this.longPressTimer);
this.longPressTimer = null;
}
nakamaManager.disconnect();
},
async fetchOnlineCount() {

View File

@ -185,7 +185,11 @@
"navigationBarTitleText": "扫雷对战",
"disableScroll": true,
"mp-weixin": {
"disableSwipeBack": true
"disableSwipeBack": true,
"enablePullDownRefresh": false,
"disableShareMenu": true,
"disableScroll": true,
"disableScale": true
},
"h5": {
"titleNView": false