diff --git a/client/public/onebyone/connect/connect.js b/client/public/onebyone/connect/connect.js index ccd4e35..0ace7b9 100644 --- a/client/public/onebyone/connect/connect.js +++ b/client/public/onebyone/connect/connect.js @@ -3,7 +3,7 @@ * 处理初始连接、创建通话和加入通话的功能 */ -import { showNotification } from '../utils.js'; +import { showNotification, randomMeetingId } from '../utils.js'; const MAX_AVATAR_SIZE = 2 * 1024 * 1024; // 2MB @@ -28,8 +28,10 @@ function createCall() { showNotification('正在创建通话...'); // 生成随机连接ID - const connectionId = 'conn_' + Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); - + //const connectionId = 'conn_' + Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); + const connectionId = randomMeetingId(); + showNotification(`已创建通话 (${connectionId})`); + // 保存连接ID到本地存储 localStorage.setItem('connectionId', connectionId); diff --git a/client/public/onebyone/main.js b/client/public/onebyone/main.js index 32373ff..00eab1c 100644 --- a/client/public/onebyone/main.js +++ b/client/public/onebyone/main.js @@ -5,14 +5,13 @@ */ import store from './store.js'; import UIRenderer from './renderer.js'; -import { showNotification } from './utils.js'; +import { showNotification, randomMeetingId } from './utils.js'; import chatMessage from './chatmessage.js'; import { bindConnectViewEvents, initWebSocket, loadUserSettings } from './connectview.js'; - // 全局变量 let connectionId = ""; // 当前视图状态:'connect' 或 'call'(可用于未来扩展) @@ -68,7 +67,9 @@ async function handleJoinCall(connectionId) { */ async function handleCreateCall() { showNotification('正在创建通话...'); - const connectionId = 'conn_' + Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); + //const connectionId = 'conn_' + Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15); + + const connectionId = randomMeetingId(); localStorage.setItem('connectionId', connectionId); await switchToCallView(connectionId); } diff --git a/client/public/onebyone/utils.js b/client/public/onebyone/utils.js index 213b170..4387121 100644 --- a/client/public/onebyone/utils.js +++ b/client/public/onebyone/utils.js @@ -92,3 +92,12 @@ export function toggleButtonState(button, active) { } } } +/** + * 生成随机会议ID + * @returns {string} 随机会议ID + */ +export function randomMeetingId() { + const part = () => Math.floor(100 + Math.random() * 900); + return `${part()}-${part()}-${part()}`; +} +