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] || '🎁';