/** 获取浏览器信息 */ export const browser = () => { const u = navigator.userAgent; // console.log("🚀 ~ u:", u) return { trident: u.indexOf("Trident") > -1, //IE内核 presto: u.indexOf("Presto") > -1, //opera内核 webKit: u.indexOf("AppleWebKit") > -1, //苹果、谷歌内核 gecko: u.indexOf("Gecko") > -1 && u.indexOf("KHTML") == -1, //火狐内核 mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端 ios: !!u.match(/Mac OS X/), //ios终端 // ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 android: u.indexOf("ORCHESTRAAPPA") > -1 || u.indexOf("Adr") > -1, //android终端 iPhone: u.indexOf("ORCHESTRAAPPI") > -1, //是否为iPhone或者QQHD浏览器 isApp: u.indexOf("ORCHESTRAAPPI") > -1 || u.indexOf("ORCHESTRAAPPA") > -1, isTeacher: u.indexOf("ORCHESTRATEACHER") > -1, isStudent: u.indexOf("ORCHESTRASTUDENT") > -1, isSchool: u.indexOf("ORCHESTRASCHOOL") > -1, iPad: u.indexOf("iPad") > -1, //是否iPad webApp: u.indexOf("Safari") == -1, //是否web应该程序,没有头部与底部 weixin: u.indexOf("MicroMessenger") > -1, //是否微信 (2015-01-22新增) alipay: u.indexOf("AlipayClient") > -1, //是否支付宝 huawei: !!u.match(/huawei/i) || !!u.match(/honor/i), xiaomi: !!u.match(/mi\s/i) || !!u.match(/redmi/i) || !!u.match(/mix/i), }; }; export const getRandomKey = () => { const key = "" + new Date().getTime() + Math.floor(Math.random() * 1000000); return key; }; export const AuthorizationKey = "AUTHORIZATION"; /** 设置token */ export const setToken = (value: any) => { sessionStorage.setItem(AuthorizationKey, value); }; /** 获取token */ export const getToken = () => { return sessionStorage.getItem(AuthorizationKey) || ""; };