Bläddra i källkod

移动端和pc端跳转

shaogen1995 2 år sedan
förälder
incheckning
c870200b3b
2 ändrade filer med 57 tillägg och 2 borttagningar
  1. 30 2
      web/src/App.vue
  2. 27 0
      webM/src/App.vue

+ 30 - 2
web/src/App.vue

@@ -1,13 +1,41 @@
 <template>
   <div id="app">
-    <Router-view/>
+    <Router-view />
   </div>
 </template>
 
+
+<script>
+
+export default {
+
+  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("shouBo/main.html#/")) {
+        window.location.href = window.location.href.replace("shouBo/main.html#/", "shouBoM/index.html#/");
+        setTimeout(() => {
+          location.reload(true);
+        }, 200);
+      }
+    }
+  }
+
+}
+</script>
+
+
 <style lang='less' scoped>
-#app{
+#app {
   width: 100%;
   // min-width: 1280px;
 }
 </style>
 
+
+

+ 27 - 0
webM/src/App.vue

@@ -4,6 +4,33 @@
   </div>
 </template>
 
+
+<script>
+
+export default {
+
+  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("shouBoM/index.html#/")) {
+        window.location.href = window.location.href.replace("shouBoM/index.html#/", "shouBo/main.html#/");
+        setTimeout(() => {
+          location.reload(true);
+        }, 1000);
+      }
+    }
+  }
+
+}
+</script>
+
 <style lang="less">
 #app{
   max-width: 500px;