platform.js 773 B

12345678910111213141516
  1. const u = navigator.userAgent
  2. // 移动终端浏览器版本信息
  3. export const platform = {
  4. ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), // ios终端
  5. android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, // android终端或uc浏览器
  6. iPhone: u.indexOf('iPhone') > -1, // 是否为iPhone或者QQHD浏览器
  7. iPad: u.indexOf('iPad') > -1, // 是否iPad
  8. isWeixin: u.toLowerCase().indexOf('micromessenger') !== -1,
  9. isAlipay: u.toLowerCase().indexOf('alipay') !== -1,
  10. uCBrowser: u.indexOf('UCBrowser') > -1,
  11. isChrome: u.indexOf('Chrome') !== -1,
  12. isBaidu: !!navigator.userAgent.match(/Baidu/i),
  13. isSafari: /Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent),
  14. u: u,
  15. isSinaWeiBo: u.toLowerCase().indexOf('weibo') !== -1
  16. }