Commit fe4f4321 authored by 毛线's avatar 毛线

点击优化

parent 15c62341
...@@ -174,7 +174,7 @@ export default { ...@@ -174,7 +174,7 @@ export default {
width: 170px; width: 170px;
height: 140px; height: 140px;
background-image: url(./static/left-block-bg.png); background-image: url(./static/left-block-bg.png);
background-size: 100%; background-size: 100% 100%;
z-index: 1; z-index: 1;
.logo { .logo {
width: 136px; width: 136px;
......
...@@ -35,12 +35,28 @@ export default { ...@@ -35,12 +35,28 @@ export default {
mounted() { mounted() {
this.GetBaseInfo() this.GetBaseInfo()
this.GetDeviceList() this.GetDeviceList()
// this.network().isGaming()
}, },
methods: { methods: {
...mapActions([ ...mapActions([
'GetBaseInfo', 'GetBaseInfo',
'GetDeviceList', 'GetDeviceList',
]), ]),
network() {
return {
isGaming: () => {
const url = '/api/gaming/isGaming'
this.$request({
url,
method: 'get',
}).then(({ id }) => {
if (id) {
// this.$router.replace(`/game/${id}`)
}
})
},
}
},
}, },
} }
</script> </script>
......
<template> <template>
<video id="jswebrtc" ref="jswebrtc" style="width: 100%;height: 100%;object-fit: fill" @click="(e) => handler().click(e)"/> <video ref="jswebrtc" style="width: 100%;height: 100%;object-fit: fill" @click="(e) => handler().click(e)"/>
</template> </template>
<script> <script>
...@@ -53,7 +53,7 @@ export default { ...@@ -53,7 +53,7 @@ export default {
} }
// 获取承载元素dom // 获取承载元素dom
const videoDom = document.getElementById('jswebrtc') const videoDom = this.$refs.jswebrtc
// 初始化播放器 // 初始化播放器
this.player = new JSWebrtc.Player(url, { this.player = new JSWebrtc.Player(url, {
...@@ -77,13 +77,13 @@ export default { ...@@ -77,13 +77,13 @@ export default {
const video = this.$refs.jswebrtc const video = this.$refs.jswebrtc
const { offsetWidth, offsetHeight } = video // 组件宽高 const { offsetWidth, offsetHeight } = video // 组件宽高
const { offsetX, offsetY } = e // 点击位置 const { offsetX, offsetY } = e // 点击位置
const clickPercenX = (offsetHeight * zoom - offsetY) / (offsetHeight * zoom) const clickPercenY = (offsetHeight * zoom - offsetY) / (offsetHeight * zoom)
const clickPercenY = (offsetX) / (offsetWidth * zoom) const clickPercenX = (offsetX) / (offsetWidth * zoom)
// 计算点击区域对应的十六进制 // 计算点击区域对应的十六进制
const max = 32639 const max = 32639
const x16 = (+(max * clickPercenX).toFixed(0)).toString(16)
const y16 = (+(max * clickPercenY).toFixed(0)).toString(16) const y16 = (+(max * clickPercenY).toFixed(0)).toString(16)
const x16 = (+(max * clickPercenX).toFixed(0)).toString(16)
this.$emit('click', {x16, y16}) this.$emit('click', {x16, y16})
}, },
} }
......
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