Browse Source

Detect platform

develop
CareyWong 5 years ago
parent
commit
715f61d25e
  1. 1
      src/main.js
  2. 20
      src/plugins/device.js

1
src/main.js

@ -6,6 +6,7 @@ require(`@/plugins/clipboard`)
require(`@/plugins/base64`) require(`@/plugins/base64`)
require(`@/plugins/particles`) require(`@/plugins/particles`)
require(`@/plugins/axios`) require(`@/plugins/axios`)
require(`@/plugins/device`)
import '@/icons' // icon import '@/icons' // icon

20
src/plugins/device.js

@ -0,0 +1,20 @@
import Vue from 'vue'
Vue.prototype.$getOS = () => {
let ua = navigator.userAgent,
isWindowsPhone = /(?:Windows Phone)/.test(ua),
isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone,
isAndroid = /(?:Android)/.test(ua),
isFireFox = /(?:Firefox)/.test(ua),
// isChrome = /(?:Chrome|CriOS)/.test(ua),
isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)),
isIPhone = /(?:iPhone)/.test(ua) && !isTablet,
isPc = !isIPhone && !isAndroid && !isSymbian && !isWindowsPhone;
return {
isTablet: isTablet,
isIPhone: isIPhone,
isAndroid: isAndroid,
isPc: isPc
};
}
Loading…
Cancel
Save