From c69a48cc05f1ebe0cab5903c2f3824a50e2a0d11 Mon Sep 17 00:00:00 2001 From: MTrun <1262327911@qq.com> Date: Sat, 18 Sep 2021 19:36:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E9=80=82=E9=85=8D=E6=96=B9=E6=A1=88=EF=BC=8C=E4=BD=BF=E7=94=A8?= =?UTF-8?q?scale=E7=BC=A9=E6=94=BE=E8=BF=9B=E8=A1=8C=E9=80=82=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 12 +- src/assets/scss/_variables.scss | 15 +- src/assets/scss/index.scss | 94 +++++++--- src/assets/scss/style.scss | 2 +- src/common/echart/index.vue | 2 - src/common/flexible.js | 147 --------------- .../echart/bottom/bottomLeftChart/chart.vue | 2 +- .../echart/bottom/bottomRightChart/chart.vue | 2 +- .../echart/center/centerChartRate/index.vue | 4 +- .../centerLeft/centerLeft1Chart/chart.vue | 6 +- .../centerLeft/centerLeft1Chart/index.vue | 14 +- .../centerLeft/centerLeft2Chart/chart.vue | 98 +++++----- .../centerRight/centerRightChart/chart.vue | 5 +- .../centerRight/centerRightChart/index.vue | 9 +- src/main.js | 19 +- src/utils/drawMixin.js | 58 ++++++ src/utils/{resizeMixins.js => resizeMixin.js} | 0 src/views/bottomLeft.vue | 41 ++-- src/views/bottomRight.vue | 38 ++-- src/views/center.vue | 176 +++++++++++------- src/views/centerLeft1.vue | 115 +++++++----- src/views/centerLeft2.vue | 41 ++-- src/views/centerRight1.vue | 65 ++++--- src/views/centerRight2.vue | 56 +++--- src/views/index.vue | 94 +++++----- 25 files changed, 572 insertions(+), 543 deletions(-) delete mode 100644 src/common/flexible.js create mode 100644 src/utils/drawMixin.js rename src/utils/{resizeMixins.js => resizeMixin.js} (100%) diff --git a/src/App.vue b/src/App.vue index 1c8a32f..5b680b1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,13 +4,11 @@ - diff --git a/src/assets/scss/_variables.scss b/src/assets/scss/_variables.scss index a95b2e2..80edb92 100644 --- a/src/assets/scss/_variables.scss +++ b/src/assets/scss/_variables.scss @@ -1,6 +1,6 @@ // 颜色 $colors: ( - "primary": #db9e3f, + "primary": #1A5CD7, "info-1": #4394e4, "info": #4b67af, "white": #ffffff, @@ -11,6 +11,7 @@ $colors: ( "dark": #222222, "black-1": #171823, "black": #000000, + "icon": #5cd9e8 ); // 字体大小 @@ -86,12 +87,12 @@ $spacing-directions: ( b: bottom, l: left, ); -$spacing-base-size: 0.2rem; +$spacing-base-size: 0.5rem; $spacing-sizes: ( 0: 0, - 1: 0.25, - 2: 0.5, - 3: 1, - 4: 1.5, - 5: 3, + 1: 0.5, + 2: 1, + 3: 1.5, + 4: 2, + 5: 2.5, ); diff --git a/src/assets/scss/index.scss b/src/assets/scss/index.scss index 8e4a33b..e2c7683 100644 --- a/src/assets/scss/index.scss +++ b/src/assets/scss/index.scss @@ -1,56 +1,88 @@ #index { color: #d3d6dd; - background-color: #000000; - width: 100%; - height: 100%; - + width: 1920px; + height: 1080px; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + transform-origin: left top; + overflow: hidden; + .bg { - padding: 0.2rem 0.2rem 0 0.2rem; + width: 100%; + height: 100%; + padding: 16px 16px 0 16px; background-image: url("../assets/pageBg.png"); background-size: cover; background-position: center center; } .host-body { + .dv-dec-10, + .dv-dec-10-s { + width: 33.3%; + height: 5px; + } + .dv-dec-10-s { + transform: rotateY(180deg); + } + .dv-dec-8 { + width: 200px; + height: 50px; + } .title { position: relative; - width: 6.25rem; + width: 500px; text-align: center; background-size: cover; background-repeat: no-repeat; .title-text { - font-size: 0.3rem; + font-size: 24px; position: absolute; bottom: 0; left: 50%; transform: translate(-50%); } - .title-bototm { + .dv-dec-6 { position: absolute; - bottom: -0.375rem; + bottom: -30px; left: 50%; + width: 250px; + height: 8px; transform: translate(-50%); } } + // 第二行 + .aside-width { + width: 40%; + } + .react-r-s, + .react-l-s { + background-color: #0f1325; + } + // 平行四边形 - .react-left { - cursor: pointer; - font-size: 0.225rem; - width: 3.75rem; - height: 0.625rem; - line-height: 0.625rem; + .react-right { + &.react-l-s { + text-align: right; + width: 500px; + } + font-size: 18px; + width: 300px; + line-height: 50px; text-align: center; transform: skewX(-45deg); .react-after { position: absolute; - right: -0.3125rem; + right: -25px; top: 0; - height: 0.625rem; - width: 0.625rem; + height: 50px; + width: 50px; background-color: #0f1325; transform: skewX(45deg); } @@ -61,21 +93,25 @@ } } - .react-right { - cursor: pointer; - font-size: 0.225rem; - width: 3.75rem; - height: 0.625rem; - line-height: 0.625rem; + .react-left { + &.react-l-s { + width: 500px; + text-align: left; + } + font-size: 18px; + width: 300px; + height: 50px; + line-height: 50px; text-align: center; transform: skewX(45deg); + background-color: #0f1325; .react-before { position: absolute; - left: -0.3125rem; + left: -25px; top: 0; - height: 0.625rem; - width: 0.625rem; + height: 50px; + width: 50px; background-color: #0f1325; transform: skewX(-45deg); } @@ -87,7 +123,7 @@ } .body-box { - margin-top: 0.2rem; + margin-top: 16px; display: flex; flex-direction: column; @@ -99,7 +135,7 @@ // 底部数据 .bototm-box { - margin-top: 0.125rem; + margin-top: 10px; display: grid; grid-template-columns: repeat(2, 50%); } diff --git a/src/assets/scss/style.scss b/src/assets/scss/style.scss index e4c3a05..17b9778 100644 --- a/src/assets/scss/style.scss +++ b/src/assets/scss/style.scss @@ -5,8 +5,8 @@ margin: 0; padding: 0; list-style-type: none; - box-sizing: border-box; outline: none; + box-sizing: border-box; } html { diff --git a/src/common/echart/index.vue b/src/common/echart/index.vue index bce9d47..7db3a64 100644 --- a/src/common/echart/index.vue +++ b/src/common/echart/index.vue @@ -4,12 +4,10 @@ - - \ No newline at end of file + \ No newline at end of file diff --git a/src/main.js b/src/main.js index d119222..1cfdc05 100644 --- a/src/main.js +++ b/src/main.js @@ -3,8 +3,8 @@ import App from './App.vue'; import router from './router'; import store from './store'; import dataV from '@jiaminghi/data-view'; -Vue.use(dataV); - +// 引入全局css +import './assets/scss/style.scss'; // 按需引入vue-awesome图标 import Icon from 'vue-awesome/components/Icon'; import 'vue-awesome/icons/chart-bar.js'; @@ -13,16 +13,6 @@ import 'vue-awesome/icons/chart-pie.js'; import 'vue-awesome/icons/chart-line.js'; import 'vue-awesome/icons/align-left.js'; -// 全局注册图标 -Vue.component('icon', Icon); - -// 适配flex -import '@/common/flexible.js'; - -// 引入全局css -import './assets/scss/style.scss'; - - //引入echart //4.x 引用方式 import echarts from 'echarts' @@ -30,9 +20,12 @@ import echarts from 'echarts' //希望使用5.x版本的话,需要在package.json中更新版本号,并切换引用方式 //import * as echarts from 'echarts' Vue.prototype.$echarts = echarts - Vue.config.productionTip = false; +// 全局注册 +Vue.component('icon', Icon); +Vue.use(dataV); + new Vue({ router, store, diff --git a/src/utils/drawMixin.js b/src/utils/drawMixin.js new file mode 100644 index 0000000..f5aee1d --- /dev/null +++ b/src/utils/drawMixin.js @@ -0,0 +1,58 @@ +// 屏幕适配 mixin 函数 + +// * 默认缩放值 +const scale = { + width: '1', + height: '1', +} + +// * 设计稿尺寸(px) +const baseWidth = 1920 +const baseHeight = 1080 + +// * 需保持的比例(默认1.77778) +const baseProportion = parseFloat((baseWidth / baseHeight).toFixed(5)) + +export default { + data() { + return { + // * 定时函数 + drawTiming: null + } + }, + mounted () { + this.calcRate() + window.addEventListener('resize', this.resize) + }, + unMounted () { + window.removeEventListener('resize', this.resize) + }, + methods: { + calcRate () { + const appRef = this.$refs["appRef"] + console.log(appRef) + if (!appRef) return + // 当前宽高比 + const currentRate = parseFloat((window.innerWidth / window.innerHeight).toFixed(5)) + if (appRef) { + if (currentRate > baseProportion) { + // 表示更宽 + scale.width = ((window.innerHeight * baseProportion) / baseWidth).toFixed(5) + scale.height = (window.innerHeight / baseHeight).toFixed(5) + appRef.style.transform = `scale(${scale.width}, ${scale.height}) translate(-50%, -50%)` + } else { + // 表示更高 + scale.height = ((window.innerWidth / baseProportion) / baseHeight).toFixed(5) + scale.width = (window.innerWidth / baseWidth).toFixed(5) + appRef.style.transform = `scale(${scale.width}, ${scale.height}) translate(-50%, -50%)` + } + } + }, + resize () { + clearTimeout(this.drawTiming) + this.drawTiming = setTimeout(() => { + this.calcRate() + }, 200) + } + }, +} \ No newline at end of file diff --git a/src/utils/resizeMixins.js b/src/utils/resizeMixin.js similarity index 100% rename from src/utils/resizeMixins.js rename to src/utils/resizeMixin.js diff --git a/src/views/bottomLeft.vue b/src/views/bottomLeft.vue index b3ae1c0..3a17b3d 100644 --- a/src/views/bottomLeft.vue +++ b/src/views/bottomLeft.vue @@ -2,8 +2,8 @@
- {{item.text}} + {{ item.text }} (件)