From 393b0d67c997f4bf8c0147d9bd8a0da0a2d250f6 Mon Sep 17 00:00:00 2001 From: JSR Date: Thu, 19 Mar 2026 17:48:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A6=81=E6=AD=A2=E8=A7=A6=E5=B1=8F=E5=8F=8C?= =?UTF-8?q?=E6=8C=87=E6=8D=8F=E5=90=88=E4=B8=8E=E5=8F=8C=E5=87=BB=E7=BC=A9?= =?UTF-8?q?=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 5 ++++- src/main.tsx | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 5dc77af..90aeb6c 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,10 @@ - + SecScore diff --git a/src/main.tsx b/src/main.tsx index a0d52c0..2d29379 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -77,6 +77,55 @@ const patchConsole = () => { } patchConsole() +const disableTouchZoom = () => { + let lastTouchEnd = 0 + + // iOS Safari/WebView 手势事件,直接阻止页面缩放 + for (const type of ["gesturestart", "gesturechange", "gestureend"]) { + document.addEventListener( + type, + (event) => { + event.preventDefault() + }, + { passive: false } + ) + } + + // 双指触摸移动时阻止缩放 + document.addEventListener( + "touchmove", + (event) => { + if (event.touches.length > 1) { + event.preventDefault() + } + }, + { passive: false } + ) + + // 连续快速双击时阻止浏览器放大 + document.addEventListener( + "touchend", + (event) => { + const now = Date.now() + if (now - lastTouchEnd <= 300) { + event.preventDefault() + } + lastTouchEnd = now + }, + { passive: false } + ) + + // 部分环境下双击会触发 dblclick,补充阻止 + document.addEventListener( + "dblclick", + (event) => { + event.preventDefault() + }, + { passive: false } + ) +} +disableTouchZoom() + window.addEventListener("error", (e: any) => { const error = e?.error safeWriteLog({