/** * 结束通话界面逻辑 * 处理通话结束后的操作,如重新连接或返回连接界面 */ // 通知函数 function showNotification(message, type = 'info') { const notification = document.getElementById('notification'); const notificationText = document.getElementById('notificationText'); if (notification && notificationText) { notificationText.textContent = message; // 清除之前的类 notification.className = 'fixed top-20 left-1/2 transform -translate-x-1/2 glass px-6 py-3 rounded-full flex items-center gap-3 opacity-0 pointer-events-none transition-all duration-300 z-50 translate-y-[-20px]'; // 根据类型添加不同的图标 const iconElement = notification.querySelector('i'); if (iconElement) { iconElement.className = 'fas fa-info-circle text-indigo-400'; switch (type) { case 'success': iconElement.className = 'fas fa-check-circle text-green-400'; break; case 'error': iconElement.className = 'fas fa-exclamation-circle text-red-400'; break; case 'warning': iconElement.className = 'fas fa-exclamation-triangle text-yellow-400'; break; } } // 显示通知 notification.classList.remove('opacity-0', 'translate-y-[-20px]'); notification.classList.add('opacity-100', 'translate-y-0'); // 3秒后隐藏 setTimeout(() => { notification.classList.remove('opacity-100', 'translate-y-0'); notification.classList.add('opacity-0', 'translate-y-[-20px]'); }, 3000); } } // 重新连接 function reconnectCall() { showNotification('正在重新连接...'); // 跳转到通话界面 window.location.href = '../index.html'; } // 离开 function leaveCall() { // 清除本地存储中的连接ID localStorage.removeItem('connectionId'); // 跳转到连接界面 window.location.href = '../connect/connect.html'; } // 绑定事件监听器 function bindEvents() { // 重新连接按钮 const reconnectBtn = document.getElementById('reconnectBtn'); if (reconnectBtn) { reconnectBtn.addEventListener('click', reconnectCall); } // 离开按钮 const leaveBtn = document.getElementById('leaveBtn'); if (leaveBtn) { leaveBtn.addEventListener('click', leaveCall); } } // 页面加载完成后初始化 window.addEventListener('DOMContentLoaded', () => { bindEvents(); // 更新断开连接信息 const disconnectConnectionId = document.getElementById('disconnectConnectionId'); const disconnectTime = document.getElementById('disconnectTime'); if (disconnectConnectionId) { disconnectConnectionId.textContent = localStorage.getItem('connectionId') || '--'; } if (disconnectTime) { disconnectTime.textContent = new Date().toLocaleString(); } }); // 导出全局函数 window.showNotification = showNotification; window.reconnectCall = reconnectCall; window.leaveCall = leaveCall;