update pay ui

This commit is contained in:
2025-12-14 14:16:37 +08:00
parent 893a75fab9
commit 1862e26baf
3 changed files with 30 additions and 2 deletions

View File

@@ -24,11 +24,35 @@ export const isWeChatBrowser = () => {
/**
* 检测是否为移动端设备
* 使用多种检测方式,确保 Safari 兼容性
*/
export const isMobileDevice = () => {
if (typeof window === 'undefined') return false;
const ua = navigator.userAgent;
return /iPhone|iPad|iPod|Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(ua);
// 方式1User Agent 检测
const uaCheck = /iPhone|iPad|iPod|Android|webOS|BlackBerry|IEMobile|Opera Mini/i.test(ua);
// 方式2触摸屏检测Safari 兼容)
const touchCheck = 'ontouchstart' in window || navigator.maxTouchPoints > 0;
// 方式3屏幕宽度检测作为备用
const screenCheck = window.innerWidth <= 768;
// 方式4Safari 特定检测iOS Safari 不会在 UA 中包含 "Mobile" 但会有 "Safari"
const isSafariMobile = /Safari/i.test(ua) && /Apple/i.test(navigator.vendor) && touchCheck;
const result = uaCheck || (touchCheck && screenCheck) || isSafariMobile;
// 调试日志(仅在开发环境)
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] result:', result);
}
return result;
};
/**