房间id生成修改
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* 处理初始连接、创建通话和加入通话的功能
|
||||
*/
|
||||
|
||||
import { showNotification } from '../utils.js';
|
||||
import { showNotification, randomMeetingId } from '../utils.js';
|
||||
|
||||
const MAX_AVATAR_SIZE = 2 * 1024 * 1024; // 2MB
|
||||
|
||||
@@ -28,7 +28,9 @@ 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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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()}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user