// 这里区分方式类似于区分不同浏览器, 这里是es6的写法,在react项目中使用过的。
const ua = typeof window === 'object' ? window.navigator.userAgent : '';
let _isIOS = -1;
let _isAndroid = -1;
let _isWechat = -1;
let _isAlipay = -1;
export function isIOS() {
if (_isIOS === -1) {
_isIOS = /iPhone|iPod|iPad/i.test(ua) ? 1 : 0;
}
return _isIOS === 1;
}
export function isAndroid() {
if (_isAndroid === -1) {
_isAndroid = /Android/i.test(ua) ? 1 : 0;
}
return _isAndroid === 1;
}
export function isWechat() {
if (_isWechat === -1) {
_isWechat = /MicroMessenger/i.test(ua) ? 1 : 0;
}
return _isWechat === 1;
}
export function isAlipay() {
if (_isAlipay === -1) {
_isAlipay = /Alipay/i.test(ua) ? 1 : 0;
}
return _isAlipay === 1;
}