mirror of
https://github.com/SECTL/SecScore.git
synced 2026-07-19 19:04:23 +08:00
禁止触屏双指捏合与双击缩放
This commit is contained in:
+4
-1
@@ -2,7 +2,10 @@
|
|||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta
|
||||||
|
name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
||||||
|
/>
|
||||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||||
<title>SecScore</title>
|
<title>SecScore</title>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
@@ -77,6 +77,55 @@ const patchConsole = () => {
|
|||||||
}
|
}
|
||||||
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) => {
|
window.addEventListener("error", (e: any) => {
|
||||||
const error = e?.error
|
const error = e?.error
|
||||||
safeWriteLog({
|
safeWriteLog({
|
||||||
|
|||||||
Reference in New Issue
Block a user