扫雷免费

This commit is contained in:
邹方成 2026-01-29 19:12:04 +08:00
parent ba89b0f2dc
commit 35932622e0

View File

@ -555,15 +555,20 @@ export default {
}, },
async initNakama(token, server, key, stableUid = null) { async initNakama(token, server, key, stableUid = null) {
try { try {
// : ,使 // : ,使
const serverUrl = (server && server.includes('yourdomain.com')) || !server const isInvalidServer = !server
|| server.includes('yourdomain.com')
|| server.includes('127.0.0.1')
|| server.includes('localhost');
const serverUrl = isInvalidServer
? 'wss://kdy.1024tool.vip' ? 'wss://kdy.1024tool.vip'
: server; : server;
const serverKey = key || 'defaultkey'; const serverKey = key || 'defaultkey';
// 使, // 使,
if (server && server.includes('yourdomain.com')) { if (isInvalidServer && server) {
console.warn('[Nakama] 检测到占位符服务器地址,已自动切换为默认服务器: kdy.1024tool.vip'); console.warn('[Nakama] 检测到无效服务器地址 (' + server + '),已自动切换为默认服务器: wss://kdy.1024tool.vip');
} }
nakamaManager.initClient(serverUrl, serverKey); nakamaManager.initClient(serverUrl, serverKey);
@ -629,6 +634,17 @@ export default {
} }
} }
// 线
if (!this.isConnected) {
try {
await nakamaManager.connect();
this.isConnected = true;
console.log('[Nakama] WebSocket 已连接(用于大厅和在线人数)');
} catch (err) {
console.warn('[Nakama] 建立连接失败:', err);
}
}
// 线 // 线
this.joinLobby(); this.joinLobby();
@ -1103,9 +1119,12 @@ export default {
}, },
async joinLobby() { async joinLobby() {
try { try {
// minesweeper_lobby , Type 1 (Room), Persistence True, Hidden False // minesweeper_lobby
await nakamaManager.joinChat('minesweeper_lobby', 1, true, false); // Type 1 = Room ()
console.log('Successfully joined minesweeper lobby'); // Persistence = true ()
// Hidden = false ()
const channel = await nakamaManager.joinChat('minesweeper_lobby', 1, true, false);
console.log('Successfully joined minesweeper lobby, channel ID:', channel?.id);
} catch (error) { } catch (error) {
console.warn('Failed to join lobby channel:', error); console.warn('Failed to join lobby channel:', error);
} }