Browse Source

'更新浏览器提示'

lex-xin 3 years ago
parent
commit
a37ad0677d
3 changed files with 47 additions and 22 deletions
  1. 23 11
      dist/index.html
  2. 23 11
      index.html
  3. 1 0
      vite.config.ts

+ 23 - 11
dist/index.html

@@ -24,9 +24,9 @@
       var ieAX = win.ActiveXObject;
       var ieMode = doc.documentMode;
       var REG_APPLE = /^Apple/;
-      var ieVer = _getIeVersion() || ieMode || 0;
+      // var ieVer = _getIeVersion() || ieMode || 0;
       var isIe = ieAX || ieMode;
-      var chromiumType = _getChromiumType();
+      // var chromiumType = _getChromiumType();
       /**
        * 检测 external 是否包含该字段
        * @param reg 正则
@@ -66,7 +66,7 @@
 
         var _track = 'track' in document.createElement('track');
         var webstoreKeysLength = win.chrome && win.chrome.webstore ? Object.keys(win.chrome.webstore).length : 0;
-
+        console.log(webstoreKeysLength)
         // 搜狗浏览器
         if (_testExternal(/^sogou/i, 0)) {
             return 'sogou';
@@ -78,7 +78,7 @@
         }
 
         // chrome 由于360极速浏览器 内核也是 chrome,所以先判断360极速浏览器
-        if (win.clientInformation && win.clientInformation.permissions && webstoreKeysLength <= 1) {
+        if (win.clientInformation && win.clientInformation.permissions) {
             return 'chrome';
         }
 
@@ -102,18 +102,30 @@
 
           return v > 4 ? v : 0;
       }
-      var isChrome = (function () {
-          return chromiumType === 'chrome';
-      })()
+
+      function getBrowserInfo() {
+        const userAgent = navigator.userAgent.toLocaleLowerCase();
+        if (userAgent.match(/chrome/) != null) {
+          if (userAgent.match(/wow64/) != null) {
+              return false
+            } else {
+              return true
+            }
+        }
+      }
+      var isChrome = getBrowserInfo()
       var isCloseBrowser = sessionStorage.getItem('isCloseBrowser')
-      // console.log(isChrome, isCloseBrowser)
+      console.log(isChrome, isCloseBrowser)
       // 如果不是360浏览器会提示
       if((!isChrome) && !isCloseBrowser) {
-        document.querySelector('#notification_1').classList.remove('hide')
+        console.log(document.getElementById('notification_1').className)
+        document.getElementById('notification_1').className = 'el-notification right'
+        // document.getElementById('notification_1').classList.remove('hide')
         sessionStorage.removeItem('isCloseBrowser')
       }
-      document.querySelector('#noClose').onclick = function() {
-        document.querySelector('#notification_1').classList.add('hide')
+      document.getElementById('noClose').onclick = function() {
+        // document.getElementById('notification_1').classList.add('hide')
+        document.getElementById('notification_1').className = 'el-notification right hide'
         sessionStorage.setItem('isCloseBrowser', 1)
       }
     </script>

+ 23 - 11
index.html

@@ -97,9 +97,9 @@
       var ieAX = win.ActiveXObject;
       var ieMode = doc.documentMode;
       var REG_APPLE = /^Apple/;
-      var ieVer = _getIeVersion() || ieMode || 0;
+      // var ieVer = _getIeVersion() || ieMode || 0;
       var isIe = ieAX || ieMode;
-      var chromiumType = _getChromiumType();
+      // var chromiumType = _getChromiumType();
       /**
        * 检测 external 是否包含该字段
        * @param reg 正则
@@ -139,7 +139,7 @@
 
         var _track = 'track' in document.createElement('track');
         var webstoreKeysLength = win.chrome && win.chrome.webstore ? Object.keys(win.chrome.webstore).length : 0;
-
+        console.log(webstoreKeysLength)
         // 搜狗浏览器
         if (_testExternal(/^sogou/i, 0)) {
             return 'sogou';
@@ -151,7 +151,7 @@
         }
 
         // chrome 由于360极速浏览器 内核也是 chrome,所以先判断360极速浏览器
-        if (win.clientInformation && win.clientInformation.permissions && webstoreKeysLength <= 1) {
+        if (win.clientInformation && win.clientInformation.permissions) {
             return 'chrome';
         }
 
@@ -175,18 +175,30 @@
 
           return v > 4 ? v : 0;
       }
-      var isChrome = (function () {
-          return chromiumType === 'chrome';
-      })()
+
+      function getBrowserInfo() {
+        const userAgent = navigator.userAgent.toLocaleLowerCase();
+        if (userAgent.match(/chrome/) != null) {
+          if (userAgent.match(/wow64/) != null) {
+              return false
+            } else {
+              return true
+            }
+        }
+      }
+      var isChrome = getBrowserInfo()
       var isCloseBrowser = sessionStorage.getItem('isCloseBrowser')
-      // console.log(isChrome, isCloseBrowser)
+      console.log(isChrome, isCloseBrowser)
       // 如果不是360浏览器会提示
       if((!isChrome) && !isCloseBrowser) {
-        document.querySelector('#notification_1').classList.remove('hide')
+        console.log(document.getElementById('notification_1').className)
+        document.getElementById('notification_1').className = 'el-notification right'
+        // document.getElementById('notification_1').classList.remove('hide')
         sessionStorage.removeItem('isCloseBrowser')
       }
-      document.querySelector('#noClose').onclick = function() {
-        document.querySelector('#notification_1').classList.add('hide')
+      document.getElementById('noClose').onclick = function() {
+        // document.getElementById('notification_1').classList.add('hide')
+        document.getElementById('notification_1').className = 'el-notification right hide'
         sessionStorage.setItem('isCloseBrowser', 1)
       }
     </script>

+ 1 - 0
vite.config.ts

@@ -69,6 +69,7 @@ export default defineConfig({
     // })
   ],
   server: {
+    host: '0.0.0.0',
     cors: true,
     proxy: {
       '/api-im': {