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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user