mo 1 year ago
parent
commit
b1c03640e2
3 changed files with 86 additions and 25 deletions
  1. 62 18
      index.html
  2. 5 6
      src/App.tsx
  3. 19 1
      src/router/router-guards.ts

+ 62 - 18
index.html

@@ -27,8 +27,37 @@
   <meta name="referrer" content="no-referrer" />
   <title>老师端</title>
 </head>
+<style>
+  body {
+    background: #f1f5ff;
+    width: 100%;
+  }
 
-<body>
+  .bgImg {
+    width: 456px;
+  }
+
+  .btnImg {
+    width: 288px;
+    position: absolute;
+    left: 50%;
+    margin-left: -144px;
+    bottom: 31px;
+    cursor: pointer;
+  }
+
+  .imgWrap {
+    width: 456px;
+    position: absolute;
+    top: 141px;
+    left: 50%;
+    margin-left: -288px;
+  }
+</style>
+<!-- 按钮 https://gyt.ks3-cn-beijing.ksyuncs.com/basic/1688699779209.png -->
+<!-- 背景 https://gyt.ks3-cn-beijing.ksyuncs.com/basic/1688699993534.png -->
+
+<body class="myBody">
   <script type="text/javascript">
     function getChromeVersion() {
       var arr = navigator.userAgent.split(' ');
@@ -42,7 +71,14 @@
         return false;
       }
     };
+    function IsFF() {
+      var sAgent = window.navigator.userAgent.toLowerCase();
 
+      if (sAgent.indexOf("firefox") != -1) {
+        return true;
+      }
+      return false;
+    }
 
     function isChrome() {
       var isChromium = window.chrome;
@@ -90,24 +126,32 @@
     }
     (function (window) {
 
-      if (IEVersion() != -1) {
-        var str = "你的浏览器版本太低了,请升级后重试 :(";
-        var str2 = "推荐使用:<a href='https://www.google.cn/intl/zh-CN/chrome/' target='_blank' style='color:blue;'>谷歌浏览器</a>,"
-          ;
-        document.writeln("<pre style='text-align:center;color:#fff;background-color:#0cc; height:100%;border:0;position:fixed;top:0;left:0;width:100%;z-index:1234'>" +
-          "<h2 style='padding-top:200px;margin:0'><strong>" + str + "<br/></strong></h2><h2>" +
-          str2 + "</h2>");
-        document.execCommand("Stop");
-      };
-      console.log(isChrome(), getChromeVersion())
-      if (isChrome() && getChromeVersion() < 87) {
-        var str = "你的浏览器版本太低了,请升级后重试 :(";
-        var str2 = "推荐使用:<a href='https://www.google.cn/intl/zh-CN/chrome/' target='_blank' style='color:blue;'>谷歌浏览器</a>,"
-          ;
-        document.writeln("<pre style='text-align:center;color:#fff;background-color:#0cc; height:100%;border:0;position:fixed;top:0;left:0;width:100%;z-index:1234'>" +
-          "<h2 style='padding-top:200px;margin:0'><strong>" + str + "<br/></strong></h2><h2>" +
-          str2 + "</h2>");
+      // if (IEVersion() != -1) {
+
+      //   document.writeln("<pre style='text-align:center;color:#fff;background-color:#0cc; height:100%;border:0;position:fixed;top:0;left:0;width:100%;z-index:1234'>" +
+      //     "<h2 style='padding-top:200px;margin:0'><strong>" + str + "<br/></strong></h2><h2>" +
+      //     str2 + "</h2>");
+      //   document.execCommand("Stop");
+      // };
+
+      if (!isChrome()) {
+        console.log(1)
+        document.writeln("<div class='imgWrap'><img src='https://gyt.ks3-cn-beijing.ksyuncs.com/basic/1688699993534.png' class='bgImg' alt=''><img src='https://gyt.ks3-cn-beijing.ksyuncs.com/basic/1688699779209.png' class='btnImg' alt=''></div>");
         document.execCommand("Stop");
+        // if (IsFF()) {
+        //   window.stop()
+        // } else {
+        //   document.execCommand("Stop");
+        // }
+
+      } else {
+        if (getChromeVersion() < 90) {
+          console.log(2)
+          document.writeln("<div class='imgWrap'><img src='https://gyt.ks3-cn-beijing.ksyuncs.com/basic/1688699993534.png' class='bgImg' alt=''><img src='https://gyt.ks3-cn-beijing.ksyuncs.com/basic/1688699779209.png' class='btnImg' alt=''></div>");
+          document.execCommand("Stop");
+        }
+
+        // if (IsFF()) {
       }
 
     })(window);

+ 5 - 6
src/App.tsx

@@ -24,7 +24,7 @@ export default defineComponent({
         }
       };
     });
-    const showModal = ref(false);
+    // const showModal = ref(false);
     const showModalMsg = ref('');
     // 判断浏览器
     const isChrome = () => {
@@ -59,13 +59,12 @@ export default defineComponent({
     };
 
     const isChromeFlag = isChrome();
-    console.log(isChromeFlag, 'isChromeFlag', isIOSChrome.value);
     if (isChromeFlag) {
       const chromeVersion = getChromeVersion();
       if (!chromeVersion || (chromeVersion && chromeVersion < 100)) {
         showModalMsg.value =
           '您当前的chrome版本过低,为了保证您的用户体验请升级后使用';
-        showModal.value = true;
+        // showModal.value = true;
       }
       // if (chromeVersion) {
       //   return Number(chromeVersion.split('/')[1].split('.')[0]);
@@ -74,7 +73,7 @@ export default defineComponent({
       // }
     } else {
       showModalMsg.value = '为了保证您的用户体验,请使用chrome打开,点击确定下载';
-      showModal.value = true;
+      // showModal.value = true;
       console.log('---');
     }
 
@@ -94,7 +93,7 @@ export default defineComponent({
             <RouterError />
           </AppProvider>
         </NConfigProvider>
-        <NModal
+        {/* <NModal
           show={showModal.value}
           closeOnEsc={false}
           closable={false}
@@ -103,7 +102,7 @@ export default defineComponent({
           title="确认"
           content={showModalMsg.value}
           positive-text="确认"
-          onPositiveClick={submitCallback}></NModal>
+          onPositiveClick={submitCallback}></NModal> */}
       </>
     );
   }

+ 19 - 1
src/router/router-guards.ts

@@ -7,11 +7,29 @@ import { ACCESS_TOKEN } from '@/store/mutation-types';
 const LOGIN_PATH = PageEnum.BASE_LOGIN;
 
 const whitePathList = [LOGIN_PATH]; // no redirect whitelist
-
+const isChrome = () => {
+  const isChromium = (window as any).chrome;
+  const winNav = window.navigator;
+  const vendorName = winNav.vendor;
+  const isOpera = typeof (window as any).opr !== 'undefined';
+  const isIEedge = winNav.userAgent.indexOf('Edge') > -1;
+  const isIOSChrome = winNav.userAgent.match('CriOS');
+  return (
+    isIOSChrome ||
+    (isChromium !== null &&
+      typeof isChromium !== 'undefined' &&
+      vendorName === 'Google Inc.' &&
+      isOpera === false &&
+      isIEedge === false)
+  );
+};
 export function createRouterGuards(router: Router) {
   const userStore = useUserStore();
   router.beforeEach(async (to, from, next) => {
     // console.log('access token');
+    if (!isChrome()) {
+      return;
+    }
     window.$loadingBar && window.$loadingBar.start();
 
     // console.log(window.$loadingBar, '232332');