shaogen1995 %!s(int64=3) %!d(string=hai) anos
pai
achega
415819b1d6
Modificáronse 3 ficheiros con 33 adicións e 2 borrados
  1. 15 0
      web/src/views/Home.vue
  2. 2 2
      webM/src/utils/request.js
  3. 16 0
      webM/src/views/Home.vue

+ 15 - 0
web/src/views/Home.vue

@@ -198,6 +198,21 @@ export default {
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   async created() {
+    // 移动端和pc端的切换
+    if (
+      window.navigator.userAgent.match(
+        /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
+      )
+    ) {
+      // 移动端
+      if (window.location.href.includes("web")) {
+        window.location.href = window.location.href.replace("web", "webM");
+        setTimeout(() => {
+          location.reload(true);
+        }, 1000);
+      }
+    }
+
     let res = await getStatistics();
     this.numAll = res.data.visitCount;
     this.numDay = res.data.visitToday;

+ 2 - 2
webM/src/utils/request.js

@@ -1,8 +1,8 @@
 import axios from 'axios'
 const service = axios.create({
   // baseURL: 'http://192.168.0.135:8016', // 本地调试
-  baseURL: 'http://project.4dage.com:8016', // 线上调试
-  // baseURL: '', // build
+  // baseURL: 'http://project.4dage.com:8016', // 线上调试
+  baseURL: '', // build
   timeout: 5000
 })
 // 请求拦截器

+ 16 - 0
webM/src/views/Home.vue

@@ -86,6 +86,22 @@ export default {
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   async created() {
+    // 移动端和pc端的切换
+    if (
+      window.navigator.userAgent.match(
+        /(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
+      )
+    ) {
+      // 移动端
+    } else {
+      // PC端
+      if (window.location.href.includes("webM")) {
+        window.location.href = window.location.href.replace("webM", "web");
+        setTimeout(() => {
+          location.reload(true);
+        }, 1000);
+      }
+    }
     let res = await getStatistics();
     this.numAll = res.data.visitCount;
     this.numDay = res.data.visitToday;