From fcdf135bd849f14c8016288d95291bcd07cb0bdd Mon Sep 17 00:00:00 2001 From: zdl <3489966805@qq.com> Date: Mon, 15 Dec 2025 10:53:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=BE=AE=E4=BF=A1?= =?UTF-8?q?=E5=86=85=E6=B5=8F=E8=A7=88=E5=99=A8=E7=A7=BB=E5=8A=A8=E7=AB=AF?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - isMobileDevice() 添加微信浏览器检测(micromessenger) - 确保微信内浏览器使用 URL Scheme 跳转小程序 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- .../MiniProgramLauncher/hooks/useWechatEnvironment.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/MiniProgramLauncher/hooks/useWechatEnvironment.js b/src/components/MiniProgramLauncher/hooks/useWechatEnvironment.js index c3b19773..00b779ea 100644 --- a/src/components/MiniProgramLauncher/hooks/useWechatEnvironment.js +++ b/src/components/MiniProgramLauncher/hooks/useWechatEnvironment.js @@ -43,12 +43,15 @@ export const isMobileDevice = () => { // 方式4:Safari 特定检测(iOS Safari 不会在 UA 中包含 "Mobile" 但会有 "Safari") const isSafariMobile = /Safari/i.test(ua) && /Apple/i.test(navigator.vendor) && touchCheck; - const result = uaCheck || (touchCheck && screenCheck) || isSafariMobile; + // 方式5:微信浏览器检测(微信内必定是移动端) + const isWechat = ua.toLowerCase().includes('micromessenger'); + + const result = uaCheck || (touchCheck && screenCheck) || isSafariMobile || isWechat; // 调试日志(仅在开发环境) if (process.env.NODE_ENV === 'development') { console.log('[isMobileDevice] UA:', ua); - console.log('[isMobileDevice] uaCheck:', uaCheck, 'touchCheck:', touchCheck, 'screenCheck:', screenCheck, 'isSafariMobile:', isSafariMobile); + console.log('[isMobileDevice] uaCheck:', uaCheck, 'touchCheck:', touchCheck, 'screenCheck:', screenCheck, 'isSafariMobile:', isSafariMobile, 'isWechat:', isWechat); console.log('[isMobileDevice] result:', result); }