修复手机端双触发弹窗:名单 item 和消息名字均支持 touchend double-tap 弹出用户名片
This commit is contained in:
@@ -73,7 +73,6 @@
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
|
|
||||||
@if ($user->id === 1 || $user->activePosition()->exists())
|
|
||||||
{{-- 欢迎语快捷按钮 + 下拉浮层 --}}
|
{{-- 欢迎语快捷按钮 + 下拉浮层 --}}
|
||||||
<div style="position:relative;display:inline-block;" id="welcome-btn-wrap">
|
<div style="position:relative;display:inline-block;" id="welcome-btn-wrap">
|
||||||
<button type="button" onclick="toggleWelcomeMenu(event)"
|
<button type="button" onclick="toggleWelcomeMenu(event)"
|
||||||
@@ -101,7 +100,6 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
|
||||||
|
|
||||||
@if (
|
@if (
|
||||||
$user->user_level >= (int) \App\Models\Sysparam::getValue('level_announcement', '10') ||
|
$user->user_level >= (int) \App\Models\Sysparam::getValue('level_announcement', '10') ||
|
||||||
|
|||||||
@@ -311,18 +311,25 @@
|
|||||||
document.getElementById('content').focus();
|
document.getElementById('content').focus();
|
||||||
}, 250);
|
}, 250);
|
||||||
};
|
};
|
||||||
// 双击打开用户名片弹窗(全局统一入口);手机端同时关闭名单抽屉
|
// 双击 / 手机端双触发 打开用户名片弹窗
|
||||||
item.ondblclick = () => {
|
const _openCardFromList = () => {
|
||||||
// 取消尚未执行的单击定时器
|
if (_clickTimer) { clearTimeout(_clickTimer); _clickTimer = null; }
|
||||||
if (_clickTimer) {
|
if (typeof closeMobileDrawer === 'function') { closeMobileDrawer(); }
|
||||||
clearTimeout(_clickTimer);
|
|
||||||
_clickTimer = null;
|
|
||||||
}
|
|
||||||
if (typeof closeMobileDrawer === 'function') {
|
|
||||||
closeMobileDrawer();
|
|
||||||
}
|
|
||||||
openUserCard(username);
|
openUserCard(username);
|
||||||
};
|
};
|
||||||
|
item.ondblclick = _openCardFromList;
|
||||||
|
// 手机端:检测 300ms 内两次 touchend 触发双击
|
||||||
|
let _tapTime = 0;
|
||||||
|
item.addEventListener('touchend', (e) => {
|
||||||
|
const now = Date.now();
|
||||||
|
if (now - _tapTime < 300) {
|
||||||
|
e.preventDefault();
|
||||||
|
_openCardFromList();
|
||||||
|
_tapTime = 0;
|
||||||
|
} else {
|
||||||
|
_tapTime = now;
|
||||||
|
}
|
||||||
|
}, { passive: false });
|
||||||
targetContainer.appendChild(item);
|
targetContainer.appendChild(item);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -490,7 +497,7 @@
|
|||||||
if (systemUsers.includes(uName) || isGameLabel(uName)) {
|
if (systemUsers.includes(uName) || isGameLabel(uName)) {
|
||||||
return `<span class="msg-user" style="color: ${color};">${uName}</span>`;
|
return `<span class="msg-user" style="color: ${color};">${uName}</span>`;
|
||||||
}
|
}
|
||||||
return `<span class="msg-user" style="color: ${color}; cursor: pointer;" onclick="switchTarget('${uName}')" ondblclick="openUserCard('${uName}')">${uName}</span>`;
|
return `<span class="msg-user" data-u="${uName}" style="color: ${color}; cursor: pointer;" onclick="switchTarget('${uName}')" ondblclick="openUserCard('${uName}')">${uName}</span>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 系统播报用户(不包含 AI小班长)使用军号图标,AI小班长用专属图,普通用户用头像
|
// 系统播报用户(不包含 AI小班长)使用军号图标,AI小班长用专属图,普通用户用头像
|
||||||
@@ -663,6 +670,30 @@
|
|||||||
if (typeof window.initChat === 'function') {
|
if (typeof window.initChat === 'function') {
|
||||||
window.initChat(window.chatContext.roomId);
|
window.initChat(window.chatContext.roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 手机端:在公屏(say1)和包厢(say2)容器上注册 touchend 委托
|
||||||
|
// 检测 300ms 内两次触摸同一 [data-u] 用户名 span,触发 openUserCard
|
||||||
|
let _msgTapTarget = null;
|
||||||
|
let _msgTapTime = 0;
|
||||||
|
['say1', 'say2'].forEach(id => {
|
||||||
|
const el = document.getElementById(id);
|
||||||
|
if (!el) { return; }
|
||||||
|
el.addEventListener('touchend', (e) => {
|
||||||
|
const span = e.target.closest('[data-u]');
|
||||||
|
if (!span) { return; }
|
||||||
|
const uName = span.dataset.u;
|
||||||
|
const now = Date.now();
|
||||||
|
if (uName === _msgTapTarget && now - _msgTapTime < 300) {
|
||||||
|
e.preventDefault();
|
||||||
|
openUserCard(uName);
|
||||||
|
_msgTapTarget = null;
|
||||||
|
_msgTapTime = 0;
|
||||||
|
} else {
|
||||||
|
_msgTapTarget = uName;
|
||||||
|
_msgTapTime = now;
|
||||||
|
}
|
||||||
|
}, { passive: false });
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ── WebSocket 事件监听 ────────────────────────────
|
// ── WebSocket 事件监听 ────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user