device.js 502 B

123456789101112131415
  1. export function isPadDevice() {
  2. const userAgent = navigator.userAgent || navigator.vendor || window.opera;
  3. const platform = navigator.platform || '';
  4. const maxTouchPoints = navigator.maxTouchPoints || 0;
  5. // 检查是否是iPad
  6. if (/MacIntel/.test(platform) && maxTouchPoints > 1) {
  7. return true; // iOS 13+ iPad
  8. }
  9. // 使用正则表达式匹配用户代理字符串以确定是否为移动设备
  10. return /iPad|Tablet|Android|Mobile|iPod|iPhone/i.test(userAgent);
  11. }