按住说话时禁止浏览器默认选择/复制/长按菜单行为

录音期间在 body 上添加 is-voice-recording 类,全局强制
user-select: none、touch-action: none、-webkit-touch-callout: none,
防止按住录音时手指滑动误触浏览器的文字选择和复制功能。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
wsb1224 2026-06-07 15:22:00 +08:00
parent ab618f2e4b
commit d0d399e168

View File

@ -2256,6 +2256,14 @@ export default {
}
})
watch(isRecording, (recording) => {
if (recording) {
document.body.classList.add('is-voice-recording')
} else {
document.body.classList.remove('is-voice-recording')
}
})
watch([() => currentBackground.value?.id, () => activePetInChat.value?.pet?.id, () => currentPet.value?.id, () => backgroundPets.value.length], async () => {
syncSelectedHistoryPet()
historyPage.value = 1
@ -2310,6 +2318,7 @@ export default {
}
onUnmounted(() => {
document.body.classList.remove('is-voice-recording')
if (isInCall.value) {
chatStore.exitCallMode()
stopCallTimer()
@ -4360,6 +4369,16 @@ export default {
<!-- 全局样式teleported到body的单日期选择器 -->
<style>
/* 录音期间全局禁止选择和长按菜单,防止按住说话时误触浏览器行为 */
body.is-voice-recording,
body.is-voice-recording * {
-webkit-user-select: none !important;
user-select: none !important;
-webkit-touch-callout: none !important;
-webkit-tap-highlight-color: transparent;
touch-action: none !important;
}
@media (max-width: 768px) {
.history-date-single-popper {
background: rgba(18, 22, 34, 0.95) !important;