platform.js 548 B

123456789101112131415161718192021222324
  1. export function isAndroid() {
  2. var ua = navigator.userAgent,
  3. _isAndroid = ua.indexOf('Android') > -1 || ua.indexOf('Linux') > -1;
  4. return _isAndroid;
  5. }
  6. export function isIOS() {
  7. return !!navigator.userAgent.match(/(i[^;]+\;(U;)? CPU.+Mac OS X)/);
  8. }
  9. export function isPad() {
  10. return navigator.userAgent.toLowerCase().match(/iPad/i) == "ipad";
  11. }
  12. export function isWinPad() {
  13. return navigator.userAgent.indexOf("Windows NT") >= 0;
  14. }
  15. export default {
  16. isAndroid,
  17. isIOS,
  18. isPad,
  19. isWinPad
  20. }