Quellcode durchsuchen

判断设备逻辑修改

wucl vor 3 Wochen
Ursprung
Commit
87679f134b
2 geänderte Dateien mit 20 neuen und 2 gelöschten Zeilen
  1. 2 2
      .env.production
  2. 18 0
      src/App.vue

+ 2 - 2
.env.production

@@ -48,7 +48,7 @@ VUE_APP_PRODUCTIVITY_PLATFORM_URL=http://doc.scdayou.com/prod/
 VUE_APP_WEBSOCKET = ws://mbs.scdayou.com/api/ws
 
 # 正式环境
-# VUE_APP_MOBILE = http://mbs.scdayou.com/mobile
+VUE_APP_MOBILE = http://mbs.scdayou.com/mobile
 
 # 测试环境
-VUE_APP_MOBILE = http://kps.scdayou.com:81/mobile
+#VUE_APP_MOBILE = http://kps.scdayou.com:81/mobile

+ 18 - 0
src/App.vue

@@ -11,11 +11,27 @@ export default {
       reload: this.reload,
     };
   },
+
+  watch: {
+    // 监听 $route 对象的变化
+    '$route'(to, from) {
+      // 防止重复判断设备
+      if (this.deviceType =='PC'){
+         return;
+      }
+      //排出手机扫码验证页面
+      if (to.path!="/prod/validate"){
+        this.detectDeviceType();
+      }
+    }
+  },
   data() {
     return {
       isRouterAlive: true,
+      deviceType:null
     };
   },
+
   created() {
     // 在组件创建时检测设备类型
     //this.detectDeviceType();
@@ -36,6 +52,8 @@ export default {
       if (isMobile) {
         // 跳转到移动端
         window.location.replace(process.env.VUE_APP_MOBILE);
+      }else{
+        this.deviceType='PC';
       }
     },
   },