Commit 1c51974f authored by 毛线's avatar 毛线

进入后台停止auto

parent 5d626906
...@@ -59,6 +59,7 @@ export default { ...@@ -59,6 +59,7 @@ export default {
}, 500) }, 500)
}) })
}, false) }, false)
this.visibilitychange() // 监听页面是否进入后台
}, },
methods: { methods: {
...mapActions({ ...mapActions({
...@@ -68,6 +69,7 @@ export default { ...@@ -68,6 +69,7 @@ export default {
'SetZoom', 'SetZoom',
'SetInnerWidth', 'SetInnerWidth',
'SetInnerHeight', 'SetInnerHeight',
'SetHidePage',
]), ]),
initSceen() { initSceen() {
const { innerWidth, innerHeight } = window const { innerWidth, innerHeight } = window
...@@ -119,6 +121,17 @@ export default { ...@@ -119,6 +121,17 @@ export default {
} }
this.isMoblie = true this.isMoblie = true
}, },
visibilitychange() {
document.addEventListener('visibilitychange', () => {
if (document.hidden) {
console.log('H5已切换到后台或手机息屏')
this.SetHidePage(true)
} else {
console.log('H5已切换到网页')
this.SetHidePage(false)
}
})
},
}, },
} }
</script> </script>
......
...@@ -154,14 +154,14 @@ ...@@ -154,14 +154,14 @@
</div> </div>
</div> </div>
</div> </div>
{{ hidePage }}
<img v-audio class="spin btn" src="https://kuawai.s3.ap-east-1.amazonaws.com/resource/assets/Textures/mobileKeyboard/spin.png" alt="" @click="click().play()"> <img v-audio class="spin btn" src="https://kuawai.s3.ap-east-1.amazonaws.com/resource/assets/Textures/mobileKeyboard/spin.png" alt="" @click="click().play()">
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { mapGetters, mapMutations, } from 'vuex' import { mapGetters, mapMutations, mapState, } from 'vuex'
export default { export default {
filters: { filters: {
autoTimeFilter(value) { autoTimeFilter(value) {
...@@ -201,6 +201,9 @@ export default { ...@@ -201,6 +201,9 @@ export default {
} }
}, },
computed: { computed: {
...mapState([
'hidePage',
]),
...mapGetters([ ...mapGetters([
'is_mobile', 'is_mobile',
]), ]),
...@@ -237,6 +240,14 @@ export default { ...@@ -237,6 +240,14 @@ export default {
fullState(value) { fullState(value) {
this.SetHideHeader(value) // 全屏的时候隐藏头部 this.SetHideHeader(value) // 全屏的时候隐藏头部
}, },
hidePage(value) {
if (value) {
console.log('进入后台,停止游戏')
this.autoTime = 0
this.cancelAutoClick = 0
this.network().autoPlay('release')
}
},
}, },
created() { created() {
if (this.buttonValue) { if (this.buttonValue) {
......
...@@ -44,6 +44,7 @@ export const state = () => ({ ...@@ -44,6 +44,7 @@ export const state = () => ({
}, // app配置 }, // app配置
dictionary: {}, // 数据字典 dictionary: {}, // 数据字典
hideHeader: false, // 是否隐藏layout的header hideHeader: false, // 是否隐藏layout的header
hidePage: false,
ossConfig: { ossConfig: {
access_key: '', access_key: '',
secret: '', secret: '',
...@@ -187,6 +188,9 @@ export const mutations = { ...@@ -187,6 +188,9 @@ export const mutations = {
// console.log('SetInnerHeight', data) // console.log('SetInnerHeight', data)
state.hideHeader = data state.hideHeader = data
}, },
SetHidePage(state, data) {
state.hidePage = 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