Files
intc-website/src/Util.js

24 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 常用函数工具类
*/
'use strict'
const userAgent = navigator.userAgent
export default class Util {
static os = {
trident: userAgent.indexOf('Trident') > -1, // IE内核
presto: userAgent.indexOf('Presto') > -1, // opera内核
webKit: userAgent.indexOf('AppleWebKit') > -1, // 苹果、谷歌内核
gecko: userAgent.indexOf('Gecko') > -1 && userAgent.indexOf('KHTML') === -1, // 火狐内核
ios: !!userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), // ios终端
android: userAgent.indexOf('Android') > -1 || userAgent.indexOf('Linux') > -1, // android终端或者uc浏览器
iPhone: userAgent.indexOf('iPhone') > -1, // 是否为iPhone
mobile: !!userAgent.match(/AppleWebKit.*Mobile.*/), // 是否为移动终端
iPad: userAgent.indexOf('iPad') > -1, // 是否iPad
webApp: userAgent.indexOf('Safari') === -1, // 是否web应该程序没有头部与底部
wechat: userAgent.indexOf('MicroMessenger') > -1, // 是否微信浏览器
isapp: window.innerWidth < 768, // 是否微信浏览器
harmonyOS: userAgent.indexOf('HarmonyOS') > -1,
}
}