Przeglądaj źródła

Merge branch 'beta' of https://git.cocorobo.cn/CocoRoboLabs/pbl-teacher-table into beta

SanHQin 2 dni temu
rodzic
commit
dff7500737

+ 4 - 3
src/components/pages/workPage/components/photo.vue

@@ -127,15 +127,16 @@ export default {
       this.changeWorkData(this.work);
       this.changeWorkData(this.work);
     },
     },
     checkMobile() {
     checkMobile() {
-      this.isMobile = window.innerWidth <= 1024;
+      const ua = navigator.userAgent;
+      const isMobileDevice = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|Android/i.test(ua);
+      const isTablet = /iPad|Android(?!.*Mobile)/i.test(ua);
+      this.isMobile = isMobileDevice || isTablet;
     }
     }
   },
   },
   mounted() {
   mounted() {
     this.checkMobile();
     this.checkMobile();
-    window.addEventListener('resize', this.checkMobile);
   },
   },
   beforeUnmount() {
   beforeUnmount() {
-    window.removeEventListener('resize', this.checkMobile);
   }
   }
 };
 };
 </script>
 </script>