Commit c5947dea by zsh

修改App.vue

parent 46ab1237
Subproject commit 25a10e17bcef2d7bb93902088f9f46371801e0d5 Subproject commit 9ce9836f46d3271f3f82ad8011b90c838afa4d6c
<template> <template>
<div id="app"> <div id="app"
:style="{width: designWidth + 'px', height: designHeight + 'px'}"
>
<router-view></router-view> <router-view></router-view>
</div> </div>
</template> </template>
<script> <script>
import { refreshScale } from 'runner/common/utils/refreshSize' import setScale from 'runner/common/utils/refreshSize'
import utils from 'utils'
export default { export default {
name: 'app', name: 'app',
mixins: [setScale],
data () { data () {
return { return {
designWidth: 3840, // 设计稿宽度 designWidth: 1920, // 设计稿宽度
designHeight: 2160 // 设计稿高度 designHeight: 1080 // 设计稿高度
} }
}, },
...@@ -23,31 +26,14 @@ export default { ...@@ -23,31 +26,14 @@ export default {
bodyStyle.overflow = 'auto' bodyStyle.overflow = 'auto'
// 如无需设置自动适配则注释该方法即可 // 如无需设置自动适配则注释该方法即可
this.initScale() this.initScale(this.designWidth, this.designHeight)
}, },
methods: { methods: {}
/**
* @method initScale 设置页面缩放事件
*/
initScale () {
const appStyle = document.getElementById('app').style
appStyle.position = 'fixed'
refreshScale(this.designWidth, this.designHeight)
// 窗口缩放时重新做适配
window.addEventListener('resize', utils.throttle(() => {
refreshScale(this.designWidth, this.designHeight)
}, false))
}
}
} }
</script> </script>
<style lang="less"> <style lang="less">
@designWidth: 1920px;
@designHeight: 1080px;
body { body {
background-color: #011428; background-color: #011428;
} }
...@@ -57,11 +43,8 @@ body { ...@@ -57,11 +43,8 @@ body {
left: 50%; left: 50%;
right: 0; right: 0;
bottom: 0; bottom: 0;
width: @designWidth;
height: @designHeight;
overflow: hidden; overflow: hidden;
user-select: none; user-select: none;
background-size: @designWidth @designHeight;
background-position: center bottom; background-position: center bottom;
} }
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment