fix: 修复微信内浏览器移动端检测问题

- isMobileDevice() 添加微信浏览器检测(micromessenger)
- 确保微信内浏览器使用 URL Scheme 跳转小程序

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
zdl
2025-12-15 10:53:36 +08:00
parent 2449619f43
commit fcdf135bd8

View File

@@ -43,12 +43,15 @@ export const isMobileDevice = () => {
// 方式4Safari 特定检测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);
}