Browse Source

🐞 fix: 解决手机页面显示异常问题

Pchen. 8 months ago
parent
commit
3ddc46ac0f
3 changed files with 10 additions and 2 deletions
  1. 1 1
      index.html
  2. 8 1
      src/router/index.js
  3. 1 0
      vite.config.js

+ 1 - 1
index.html

@@ -3,7 +3,7 @@
   <head>
   <head>
     <meta charset="UTF-8" />
     <meta charset="UTF-8" />
     <link rel="icon" type="image/svg+xml" href="/logo.svg" />
     <link rel="icon" type="image/svg+xml" href="/logo.svg" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <meta name="viewport" content="width=1280">
     <title>RunForge - 智能自助校园乐跑平台</title>
     <title>RunForge - 智能自助校园乐跑平台</title>
   </head>
   </head>
   <body>
   <body>

+ 8 - 1
src/router/index.js

@@ -21,7 +21,8 @@ const routes = [
         component: () => import('../pages/face/index.vue'),
         component: () => import('../pages/face/index.vue'),
         meta: {
         meta: {
             hideInMenu: true,
             hideInMenu: true,
-            onlyWeb: true
+            onlyWeb: true,
+            viewport: 'width=device-width, initial-scale=1'
         }
         }
     },
     },
     {
     {
@@ -443,6 +444,12 @@ router.beforeEach(async (to, from, next) => {
         }
         }
     }
     }
 
 
+    
+    if (to.meta.viewport) {
+        const meta = document.querySelector('meta[name="viewport"]')
+        meta.setAttribute('content', to.meta.viewport)
+    }
+
     if (to.meta && (to.meta.onlyWeb || to.meta.onlyElectron)) {
     if (to.meta && (to.meta.onlyWeb || to.meta.onlyElectron)) {
         const electronEnv = isElectron()
         const electronEnv = isElectron()
         if (to.meta.onlyWeb && electronEnv) return next('/proxy/openProxy')
         if (to.meta.onlyWeb && electronEnv) return next('/proxy/openProxy')

+ 1 - 0
vite.config.js

@@ -16,6 +16,7 @@ export default defineConfig({
     }
     }
   },
   },
   server: {
   server: {
+    host: true,
     proxy: {
     proxy: {
       '/cloud': {
       '/cloud': {
         target: 'https://xxoo365.top/cloud',
         target: 'https://xxoo365.top/cloud',