Ver código fonte

fix 适配rem

zhaojijng 2 anos atrás
pai
commit
9e82febdb6

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/sgdaping/assets/background.5644033d.css


Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/sgdaping/assets/background.2c14299a.js


Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/sgdaping/assets/index.5eaba555.js


Diferenças do arquivo suprimidas por serem muito extensas
+ 16 - 16
dist/sgdaping/assets/index.6b7dea30.js


Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 1
dist/sgdaping/assets/index.59360d4a.js


+ 1 - 1
dist/sgdaping/assets/index.661f2b71.js

@@ -1 +1 @@
-import{h as e,r as n,o,k as t,_ as s,c as r,f as a}from"./index.6b7dea30.js";const c=e({setup(){return t(),n({}),o(()=>{}),{}}});function u(p,_,f,i,d,l){return a(),r("h2",null,"login\u9875\u9762")}const x=s(c,[["render",u]]);export{x as default};
+import{h as e,r as n,o,k as t,_ as s,c as r,f as a}from"./index.ae7b42cd.js";const c=e({setup(){return t(),n({}),o(()=>{}),{}}});function u(p,_,f,i,d,l){return a(),r("h2",null,"login\u9875\u9762")}const x=s(c,[["render",u]]);export{x as default};

+ 1 - 1
dist/sgdaping/index.html

@@ -5,7 +5,7 @@
     <link rel="icon" type="image/svg+xml" href="/sgdaping/vite.svg" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>daping</title>
-    <script type="module" crossorigin src="/sgdaping/assets/index.6b7dea30.js"></script>
+    <script type="module" crossorigin src="/sgdaping/assets/index.ae7b42cd.js"></script>
     <link rel="stylesheet" href="/sgdaping/assets/index.4f0b5577.css">
   </head>
   <body>

+ 3 - 0
src/components/pageHead.vue

@@ -43,6 +43,7 @@ import moment from "moment";
 import { storeToRefs } from "pinia";
 import useProjectStore from "@/store/useProjectStore";
 import { dapingImage } from "@/utils/dapingImage";
+import { setRem } from "@/utils/rem";
 
 export default defineComponent({
     props: {
@@ -82,9 +83,11 @@ export default defineComponent({
             changeScreen() {
                 if (allData.nowScreen == "vertical") {
                     allData.nowScreen = "horizontal";
+                    //setRem("horizontal");
                     router.push({ path: "/horiScreen" });
                 } else {
                     allData.nowScreen = "vertical";
+                    //setRem("vertical");
                     router.push({ path: "/verScreen" });
                 }
             },

+ 6 - 0
src/router/index.ts

@@ -3,6 +3,7 @@ import {
     createWebHistory,
     createWebHashHistory,
 } from "vue-router";
+import { setRem } from "@/utils/rem";
 
 const history = createWebHistory("/sgdaping/");
 const routes = [
@@ -42,9 +43,14 @@ router.beforeEach(async (to, from, next) => {
 
     await projectStore.setWeather();
     await projectStore.setProjectObj();
+
     next();
     // if (to.path.indexOf("login") == -1) {
     //     return { name: "login" };
     // }
 });
+router.afterEach((to, from) => {
+    //debugger;
+    setRem(to.path);
+});
 export default router;

+ 8 - 8
src/utils/rem.ts

@@ -4,13 +4,12 @@ import { ref, computed, onMounted } from "vue";
 // 基准大小
 const baseSize = 192;
 // 设置 rem 函数
-function getBodySize() {
-    // 当前页面宽度相对于 750 宽的缩放比例,可根据自己需要修改。
-
+function getBodySize(path: any) {
+    // 当前页面宽度相对于 1920或者1280 宽的缩放比例,可根据自己需要修改。
     // 设置页面根节点字体大小
 
     let baseWidth = 1920;
-    const href = window.location.href;
+    const href = path || window.location.href;
     if (href.indexOf("horiScreen") > -1) {
         baseWidth = 1920;
     }
@@ -21,15 +20,16 @@ function getBodySize() {
     let fontSize = baseSize * Math.min(scale, 1);
     return fontSize;
 }
-function setRem() {
+function setRem(path: any) {
     //debugger;
-    let fontSize = getBodySize();
+    let fontSize = getBodySize(path);
+    console.log("setRem-fontSize", fontSize);
     document.documentElement.style.fontSize = `${fontSize}px`;
 }
 // 初始化
-setRem();
+//setRem();
 // 改变窗口大小时重新设置 rem
 window.onresize = () => {
     setRem();
 };
-export { getBodySize };
+export { getBodySize, setRem };