diff --git a/resources/views/chat/partials/scripts.blade.php b/resources/views/chat/partials/scripts.blade.php index 906a702..d8c502e 100644 --- a/resources/views/chat/partials/scripts.blade.php +++ b/resources/views/chat/partials/scripts.blade.php @@ -37,6 +37,33 @@ const onlineCount = document.getElementById('online-count'); const onlineCountBottom = document.getElementById('online-count-bottom'); + // ── 消息区:手机端双触发打开用户名片(PC 端靠 ondblclick 内联属性)── + // span[data-u] 由 clickableUser() 生成,touchend 委托至容器避免每条消息单独绑定 + (function _bindMsgDoubleTap() { + let _lastTapTarget = null; + let _lastTapTime = 0; + + /** touchend 委托处理函数 */ + function _onMsgTouch(e) { + const span = e.target.closest('[data-u]'); + if (!span) return; + const now = Date.now(); + if (span === _lastTapTarget && now - _lastTapTime < 300) { + e.preventDefault(); + openUserCard(span.dataset.u); + _lastTapTarget = null; + _lastTapTime = 0; + } else { + _lastTapTarget = span; + _lastTapTime = now; + } + } + + // 两个聊天容器(公屏 + 包厢)都绑定 + [container, container2].forEach(c => { + if (c) { c.addEventListener('touchend', _onMsgTouch, { passive: false }); } + }); + })(); let onlineUsers = {}; let autoScroll = true; let _maxMsgId = 0; // 记录当前收到的最大消息 ID