From 420912b3a7e974391f293bb49df06a2f210fc675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=96=B9=E6=88=90?= Date: Sun, 4 Jan 2026 20:26:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=89=AB=E9=9B=B7?= =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=9C=A8=E7=BA=BF=E4=BA=BA=E6=95=B0=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=8F=8A=E5=AE=9A=E6=97=B6=E6=9B=B4=E6=96=B0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages-game/game/minesweeper/play.scss | 10 ++++++++++ pages-game/game/minesweeper/play.vue | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/pages-game/game/minesweeper/play.scss b/pages-game/game/minesweeper/play.scss index 16cf127..8f2c441 100644 --- a/pages-game/game/minesweeper/play.scss +++ b/pages-game/game/minesweeper/play.scss @@ -375,6 +375,16 @@ font-weight: 500; } +.online-number { + color: $accent-orange; + font-weight: 700; + font-size: 36rpx; +} + +.online-count-row { + margin-top: $spacing-sm; +} + // 按钮使用全局定义 .start-btn { width: 380rpx; diff --git a/pages-game/game/minesweeper/play.vue b/pages-game/game/minesweeper/play.vue index 3cdff4c..b1c086f 100644 --- a/pages-game/game/minesweeper/play.vue +++ b/pages-game/game/minesweeper/play.vue @@ -53,6 +53,10 @@ 🏆 胜者赢取全额奖励 + + 👥 + 当前在线: {{ onlineCount }} + @@ -329,6 +333,8 @@ export default { showSettlement: false, settlementWinnerId: '', showResultModal: false, + onlineCount: 0, + onlineCountInterval: null, // Timers matchInterval: null, turnInterval: null, @@ -482,6 +488,10 @@ export default { this.addLog('system', '✅ 已连接到远程节点'); this.setupSocketListeners(); + // 获取在线人数 + this.fetchOnlineCount(); + this.onlineCountInterval = setInterval(() => this.fetchOnlineCount(), 10000); + // 跨设备对局发现逻辑:调用 RPC 询问服务器我当前是否有正在进行的战局 if (!this.matchId) { try { @@ -862,8 +872,19 @@ export default { cleanup() { clearInterval(this.matchInterval); clearInterval(this.turnInterval); + clearInterval(this.onlineCountInterval); nakamaManager.disconnect(); }, + async fetchOnlineCount() { + try { + const result = await nakamaManager.rpc('get_online_count', {}); + if (result && typeof result.online_count === 'number') { + this.onlineCount = result.online_count; + } + } catch (e) { + console.warn('获取在线人数失败:', e); + } + }, getItemIcon(itemId) { const map = { medkit: '💊', bomb_timer: '⏰', poison: '☠️', shield: '🛡️', skip: '⏭️', magnifier: '🔍', knife: '🔪', revive: '💖', lightning: '⚡', chest: '📦', curse: '👻' }; return map[itemId] || '🎁';