From 7ff53c2cfd39cfef668c3a91a7cee076c8b4e2a6 Mon Sep 17 00:00:00 2001 From: stary <834207172@qq.com> Date: Sun, 17 May 2026 20:59:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4id=E7=94=9F=E6=88=90=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/public/onebyone/connect/connect.js | 8 +++++--- client/public/onebyone/main.js | 7 ++++--- client/public/onebyone/utils.js | 9 +++++++++ 3 files changed, 18 insertions(+), 6 deletions(-) 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()}`; +} +