| | |
| | | |
| | | // 心跳 |
| | | let pingTimer = null |
| | | function startPing() { |
| | | stopPing() |
| | | // 每 25 秒发一次 ping(你后端有 PING/PONG) |
| | | pingTimer = setInterval(() => { |
| | | if (connected.value) send('ping', 'system', null) |
| | | }, 25000) |
| | | } |
| | | // function startPing() { |
| | | // stopPing() |
| | | // // 每 25 秒发一次 ping(你后端有 PING/PONG) |
| | | // pingTimer = setInterval(() => { |
| | | // if (connected.value) send('ping', 'system', null) |
| | | // }, 25000) |
| | | // } |
| | | |
| | | function stopPing() { |
| | | if (pingTimer) clearInterval(pingTimer) |
| | |
| | | ws.onopen = () => { |
| | | connected.value = true |
| | | log('WS 已连接 userId=', uid.value) |
| | | startPing() |
| | | // startPing() |
| | | } |
| | | |
| | | ws.onclose = () => { |
| | |
| | | if (contact.userId) { |
| | | peerUid.value = contact.userId |
| | | contactName.value = contact.nickName || '未知联系人' |
| | | // log('🔗 从contact参数获取peerUid:', peerUid.value) |
| | | // log('👤 联系人名称:', contactName.value) |
| | | } |
| | | } catch (e) { |
| | | log('❌ 解析contact参数失败:', String(e)) |
| | |
| | | gap: 20px; |
| | | max-width: 600px; |
| | | margin: 0 auto; |
| | | height: 100vh; |
| | | height: 100%; |
| | | justify-content: center; |
| | | align-items: center; |
| | | } |
| | |
| | | |
| | | /* 头像样式 */ |
| | | .contactAvatar { |
| | | margin-top: 150px; |
| | | width: 180px; |
| | | height: 180px; |
| | | display: flex; |