Commit a7aa82e7 authored by 毛线's avatar 毛线

点击逻辑优化

parent 1d2c6f25
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
</template> </template>
<script> <script>
import { mapActions } from 'vuex' import { mapActions, mapMutations } from 'vuex'
import Audio from '@/components/common/audio/index' import Audio from '@/components/common/audio/index'
export default { export default {
components: { components: {
...@@ -39,6 +39,9 @@ export default { ...@@ -39,6 +39,9 @@ export default {
...mapActions({ ...mapActions({
GetConfig: 'GetConfig', GetConfig: 'GetConfig',
}), }),
...mapMutations([
'SetZoom',
]),
initSceen() { initSceen() {
let zoom = 1 let zoom = 1
const { innerWidth, innerHeight } = window const { innerWidth, innerHeight } = window
...@@ -48,6 +51,7 @@ export default { ...@@ -48,6 +51,7 @@ export default {
} else { } else {
zoom = window.innerWidth / 1080 zoom = window.innerWidth / 1080
} }
this.SetZoom(zoom)
this.zoom = zoom this.zoom = zoom
}, },
}, },
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
</template> </template>
<script> <script>
import { mapState } from 'vuex'
export default { export default {
name: "WebRTCPlayer", name: "WebRTCPlayer",
props: { props: {
...@@ -17,6 +18,11 @@ export default { ...@@ -17,6 +18,11 @@ export default {
player: null player: null
} }
}, },
computed: {
...mapState([
'zoom',
]),
},
mounted() { mounted() {
this.$watch('videoSrc', () => { this.$watch('videoSrc', () => {
if (this.videoSrc) { if (this.videoSrc) {
...@@ -67,12 +73,12 @@ export default { ...@@ -67,12 +73,12 @@ export default {
handler() { handler() {
return { return {
click: (e) => { click: (e) => {
console.log('click', e) const { zoom } = this
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 - offsetY) / offsetHeight const clickPercenX = (offsetHeight * zoom - offsetY) / (offsetHeight * zoom)
const clickPercenY = (offsetX) / offsetWidth const clickPercenY = (offsetX) / (offsetWidth * zoom)
// 计算点击区域对应的十六进制 // 计算点击区域对应的十六进制
const max = 32639 const max = 32639
......
...@@ -32,6 +32,7 @@ export const state = () => ({ ...@@ -32,6 +32,7 @@ export const state = () => ({
authBtnIdList: [], // 权限按钮id列表 authBtnIdList: [], // 权限按钮id列表
deviceList: [], // 设备列表 deviceList: [], // 设备列表
device: {}, // 当前设备 device: {}, // 当前设备
zoom: 1, // 当前屏幕缩放比例
appConfig: { appConfig: {
project_name: '——', // 项目名称 project_name: '——', // 项目名称
img_domain: '', // 图片名称 img_domain: '', // 图片名称
...@@ -152,6 +153,9 @@ export const mutations = { ...@@ -152,6 +153,9 @@ export const mutations = {
SetDevice(state, data) { SetDevice(state, data) {
state.device = data state.device = data
}, },
SetZoom(state, data) {
state.zoom = 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