您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

detectDevices.js 474B

1234567891011121314151617181920212223
  1. /**
  2. * Returns true if user agent is run on Android.
  3. *
  4. * @returns {boolean}
  5. */
  6. export function detectAndroid() {
  7. return Boolean(navigator.userAgent.match(/Android/i));
  8. }
  9. /**
  10. * Returns true if user agent is run on iOS.
  11. *
  12. * @returns {boolean}
  13. */
  14. export function detectIOS() {
  15. if (navigator.userAgent.match(/iPhone/i)
  16. || navigator.userAgent.match(/iPad/i)
  17. || navigator.userAgent.match(/iPod/i)) {
  18. return true;
  19. }
  20. return false;
  21. }