소스 검색

修改判断

lex 1 년 전
부모
커밋
a68cd931b9
1개의 변경된 파일17개의 추가작업 그리고 5개의 파일을 삭제
  1. 17 5
      src/helpers/utils.ts

+ 17 - 5
src/helpers/utils.ts

@@ -6,6 +6,17 @@ import { state as helpState } from './helpState'
 export const browser = () => {
   const u = navigator.userAgent
   //   app = navigator.appVersion;
+
+  let instance: any
+  if (u.indexOf('ORCHESTRASTUDENT') > -1) {
+    instance =
+      (window as any).ORCHESTRA ||
+      (window as any).webkit?.messageHandlers?.ORCHESTRA
+  } else {
+    instance =
+      (window as any).COLEXIU ||
+      (window as any).webkit?.messageHandlers?.COLEXIU
+  }
   return {
     trident: u.indexOf('Trident') > -1, //IE内核
     presto: u.indexOf('Presto') > -1, //opera内核
@@ -16,11 +27,12 @@ export const browser = () => {
     // ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
     android: u.indexOf('COLEXIUAPPA') > -1 || u.indexOf('Adr') > -1, //android终端
     iPhone: u.indexOf('COLEXIUAPPI') > -1, //是否为iPhone或者QQHD浏览器
-    isApp:
-      u.indexOf('COLEXIUAPPI') > -1 ||
-      u.indexOf('COLEXIUAPPA') > -1 ||
-      u.indexOf('ORCHESTRASTUDENT') > -1 ||
-      u.indexOf('Adr') > -1,
+    isApp: instance ? true : false, // 临时处理
+    // isApp:
+    //   u.indexOf('COLEXIUAPPI') > -1 ||
+    //   u.indexOf('COLEXIUAPPA') > -1 ||
+    //   u.indexOf('ORCHESTRASTUDENT') > -1 ||
+    //   u.indexOf('Adr') > -1,
     isTeacher: u.indexOf('COLEXIUTEACHER') > -1,
     isStudent: u.indexOf('COLEXIUSTUDENT') > -1,
     isOrchestraStudent: u.indexOf('ORCHESTRASTUDENT') > -1, // 判断是否是管乐团学生端