Commit 417d718c authored by 毛线's avatar 毛线

弹窗优化

parent e7004b8e
...@@ -2,8 +2,9 @@ ...@@ -2,8 +2,9 @@
<Dialog <Dialog
:visible.sync="visible" :visible.sync="visible"
:show-close="false" :show-close="false"
:append-to-body="false" :append-to-body="true"
top="300px" :style="style"
top="0px"
custom-class="game-dialog" custom-class="game-dialog"
title="" title=""
width="542px" width="542px"
...@@ -28,6 +29,7 @@ ...@@ -28,6 +29,7 @@
import { import {
Dialog, Dialog,
} from 'element-ui' } from 'element-ui'
import { mapState } from 'vuex'
export default { export default {
components: { components: {
Dialog, Dialog,
...@@ -51,6 +53,24 @@ export default { ...@@ -51,6 +53,24 @@ export default {
visible: false, visible: false,
} }
}, },
computed: {
...mapState([
'zoom',
]),
style() {
const { zoom } = this
const style = {
zoom,
}
const { innerWidth, innerHeight } = window
if (innerWidth / innerHeight > 1080 / 608) {
style.top = `120px`
} else {
style.top = `${(innerHeight / 2 - (184 * zoom)) / zoom}px`
}
return style
},
},
methods: { methods: {
confirm() { confirm() {
this.$emit('confirm') this.$emit('confirm')
......
<template> <template>
<div class="root"> <div class="root">
<div :style="style" class="sceen"> <div :style="style" :class="{ margin : marginSceen }" class="sceen">
<nuxt /> <nuxt />
</div> </div>
<!-- 背景音乐组件 --> <!-- 背景音乐组件 -->
...@@ -18,6 +18,7 @@ export default { ...@@ -18,6 +18,7 @@ export default {
data() { data() {
return { return {
zoom: 1, zoom: 1,
marginSceen: false,
} }
}, },
computed: { computed: {
...@@ -41,6 +42,8 @@ export default { ...@@ -41,6 +42,8 @@ export default {
}), }),
...mapMutations([ ...mapMutations([
'SetZoom', 'SetZoom',
'SetInnerWidth',
'SetInnerHeight',
]), ]),
initSceen() { initSceen() {
let zoom = 1 let zoom = 1
...@@ -48,20 +51,24 @@ export default { ...@@ -48,20 +51,24 @@ export default {
if (innerWidth / innerHeight > 1080 / 608) { if (innerWidth / innerHeight > 1080 / 608) {
console.log('比例') console.log('比例')
zoom = window.innerHeight / 608 zoom = window.innerHeight / 608
this.marginSceen = true
} else { } else {
zoom = window.innerWidth / 1080 zoom = window.innerWidth / 1080
this.marginSceen = false
} }
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
return // return
} }
this.SetZoom(zoom) this.SetZoom(zoom)
// this.SetInnerWidth(innerWidth)
// this.SetInnerHeight(innerHeight)
this.zoom = zoom this.zoom = zoom
}, },
}, },
} }
</script> </script>
<style scoped> <style lang="scss" scoped>
.root{ .root{
left: 0; left: 0;
top: 0; top: 0;
...@@ -78,7 +85,9 @@ export default { ...@@ -78,7 +85,9 @@ export default {
width: 1080px; width: 1080px;
height: 608px; height: 608px;
position: relative; position: relative;
margin-left: auto; &.margin {
margin-right: auto; margin-left: auto;
margin-right: auto;
}
} }
</style> </style>
...@@ -33,6 +33,8 @@ export const state = () => ({ ...@@ -33,6 +33,8 @@ export const state = () => ({
deviceList: [], // 设备列表 deviceList: [], // 设备列表
device: {}, // 当前设备 device: {}, // 当前设备
zoom: 1, // 当前屏幕缩放比例 zoom: 1, // 当前屏幕缩放比例
innerWidth: window.innerWidth,
innerHeight: window.innerHeight,
appConfig: { appConfig: {
project_name: '——', // 项目名称 project_name: '——', // 项目名称
img_domain: '', // 图片名称 img_domain: '', // 图片名称
...@@ -156,6 +158,12 @@ export const mutations = { ...@@ -156,6 +158,12 @@ export const mutations = {
SetZoom(state, data) { SetZoom(state, data) {
state.zoom = data state.zoom = data
}, },
SetInnerWidth(state, data) {
state.innerWidth = data
},
SetInnerHeight(state, data) {
state.innerHeight = data
},
} }
export const actions = { export const actions = {
......
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