/** * 基础工具 * @author john * @date 2021/08/31 */ /** * 是否是苹果电脑 */ export const isMac = () => { return /macintosh|mac os x/i.test(navigator.userAgent) } /** * 是否是网页地址 * @param {String} url 链接地址 */ export const isHttpUrl = (url) => { if (!url) return false return url.startsWith('http://') || url.startsWith('https://') } // 是否火狐浏览器 export const isFirefox = (_) => { if (navigator.userAgent.toUpperCase().indexOf('FIREFOX') > -1) { return true } } export const isMobile = (_) => { const userAgent = navigator.userAgent const uaMobile = /iPad|Android|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test( userAgent ) const isSmallScreen = typeof window !== 'undefined' && window.innerWidth <= 768 return uaMobile || isSmallScreen }