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, // 判断是否是管乐团学生端