|
@@ -4,6 +4,33 @@ import { getQuery } from "./queryString";
|
|
|
/** 获取浏览器信息 */
|
|
|
export const browser = () => {
|
|
|
const u = navigator.userAgent;
|
|
|
+ const isAndroid = /(?:Android)/.test(u);
|
|
|
+ const isFireFox = /(?:Firefox)/.test(u);
|
|
|
+ function isIpadFun() {
|
|
|
+ const ua = window.navigator.userAgent;
|
|
|
+ let IsIPad = false;
|
|
|
+ if (/ipad/i.test(ua)) {
|
|
|
+ IsIPad = true;
|
|
|
+ }
|
|
|
+ // iPad from IOS13
|
|
|
+ const macApp = ua.match(/Macintosh/i) != null;
|
|
|
+ if (macApp) {
|
|
|
+ // need to distinguish between Macbook and iPad
|
|
|
+ const canvas = document.createElement('canvas');
|
|
|
+ if (canvas != null) {
|
|
|
+ const context: any =
|
|
|
+ canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
|
|
|
+ if (context) {
|
|
|
+ const info = context.getExtension('WEBGL_debug_renderer_info');
|
|
|
+ if (info) {
|
|
|
+ const renderer = context.getParameter(info.UNMASKED_RENDERER_WEBGL);
|
|
|
+ if (renderer.indexOf('Apple') != -1) IsIPad = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return IsIPad;
|
|
|
+ }
|
|
|
return {
|
|
|
trident: u.indexOf("Trident") > -1, //IE内核
|
|
|
presto: u.indexOf("Presto") > -1, //opera内核
|
|
@@ -24,6 +51,11 @@ export const browser = () => {
|
|
|
isStudent: u.indexOf("ORCHESTRASTUDENT") > -1 || u.includes("COLEXIUSTUDENT"),
|
|
|
isSchool: u.indexOf("ORCHESTRASCHOOL") > -1,
|
|
|
iPad: u.indexOf("iPad") > -1, //是否iPad
|
|
|
+ isTablet:
|
|
|
+ /(?:iPad|PlayBook)/.test(u) ||
|
|
|
+ (isAndroid && !/(?:Mobile)/.test(u)) ||
|
|
|
+ (isFireFox && /(?:Tablet)/.test(u)) ||
|
|
|
+ isIpadFun(),
|
|
|
webApp: u.indexOf("Safari") == -1, //是否web应该程序,没有头部与底部
|
|
|
weixin: u.indexOf("MicroMessenger") > -1, //是否微信 (2015-01-22新增)
|
|
|
alipay: u.indexOf("AlipayClient") > -1, //是否支付宝
|