浏览代码

ua-redirect

hare8999@163.com 2 年之前
父节点
当前提交
013aaa7878
共有 3 个文件被更改,包括 21 次插入19 次删除
  1. 5 1
      src/App.vue
  2. 0 2
      src/permission.js
  3. 16 16
      src/utils/uaredirect.js

+ 5 - 1
src/App.vue

@@ -5,9 +5,13 @@
 </template>
 
 <script>
+import { uaRedirect } from '@/utils/uaredirect'
 
 export default {
-  name: 'App'
+  name: 'App',
+  mounted() {
+    setTimeout(uaRedirect, 50)
+  }
 }
 </script>
 <style>

+ 0 - 2
src/permission.js

@@ -3,7 +3,6 @@ import store from './store'
 import NProgress from 'nprogress'
 import 'nprogress/nprogress.css'
 import auth from '@/utils/auth'
-import { uaredirect } from '@/utils/uaredirect'
 
 NProgress.configure({
   showSpinner: false
@@ -55,7 +54,6 @@ router.beforeEach((to, from, next) => {
     // 没有token
     if (whiteList.indexOf(to.path) !== -1) {
       // 在免登录白名单,直接进入
-      // if (!uaWhiteList.includes(to.path)) uaredirect() // TODO: hht 22.7.4 临时注释测试班牌打不开的问题
       next()
     } else {
       // next()

+ 16 - 16
src/utils/uaredirect.js

@@ -1,16 +1,16 @@
-export function uaredirect() {
-    try {
-        if (document.getElementById("bdmark") != null) {
-            return;
-        }
-        var urlhash = window.location.hash;
-        if (!urlhash.match("fromapp")) {
-            if ((navigator.userAgent.match(/(iPhone|iPod|ios)/i) ||
-                (navigator.userAgent.match(/(Android)/i) && navigator.userAgent.match(/(Mobile)/i)))) {
-                if (process.env.VUE_APP_MOBILE) {
-                    window.location.href = process.env.VUE_APP_MOBILE;
-                }
-            }
-        }
-    } catch (err) { }
-}
+export function uaRedirect() {
+    try {
+        if (document.getElementById("bdmark") != null) {
+            return;
+        }
+        var urlhash = window.location.hash;
+        if (!urlhash.match("fromapp")) {
+            if ((navigator.userAgent.match(/(iPhone|iPod|ios)/i) ||
+                (navigator.userAgent.match(/(Android)/i) && navigator.userAgent.match(/(Mobile)/i)))) {
+                if (process.env.VUE_APP_MOBILE) {
+                    window.location.href = process.env.VUE_APP_MOBILE;
+                }
+            }
+        }
+    } catch (err) { }
+}