From feb07976eae0a1d908eae394e2c4d86ff575f7e9 Mon Sep 17 00:00:00 2001 From: Hclle Date: Mon, 27 Apr 2026 17:26:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20isMobile=20?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E5=B0=86=E8=A7=A6=E6=91=B8=E5=B1=8F=20PC=20?= =?UTF-8?q?=E8=AF=AF=E5=88=A4=E4=B8=BA=E7=A7=BB=E5=8A=A8=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 maxTouchPoints 的优先判断,因为它无法区分触摸屏 PC 和移动设备 - 调整判断顺序,先通过 platform 判断桌面系统 - Windows/Mac 触摸屏设备不再被误判为移动设备 --- src/utils/util.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/util.ts b/src/utils/util.ts index 30b4bf0..1f51b60 100644 --- a/src/utils/util.ts +++ b/src/utils/util.ts @@ -130,9 +130,11 @@ function isMobileByUa () { } function isMobile () { - const {platform, maxTouchPoints} = navigator; - if (typeof maxTouchPoints === 'number') { - return maxTouchPoints > 1; + // @ts-ignore + const {platform, maxTouchPoints, userAgentData} = navigator; + // userAgentData 是较新的 API,直接提供 mobile 属性 + if (userAgentData?.mobile) { + return userAgentData.mobile; } if (typeof platform === 'string') { const v = platform.toLowerCase();