Browse Source

添加左侧右键菜单打开监控关闭监控功能

master
chendingwei 2 years ago
parent
commit
6b16fce685
  1. 2
      components.d.ts
  2. 13
      src/views/page/aside/cameraLeftMenu.vue
  3. 66
      src/views/page/cameraCenter.vue

2
components.d.ts

@ -8,7 +8,6 @@ export {}
declare module '@vue/runtime-core' { declare module '@vue/runtime-core' {
export interface GlobalComponents { export interface GlobalComponents {
AButton: typeof import('ant-design-vue/es')['Button'] AButton: typeof import('ant-design-vue/es')['Button']
ADirectoryTree: typeof import('ant-design-vue/es')['DirectoryTree']
ADropdown: typeof import('ant-design-vue/es')['Dropdown'] ADropdown: typeof import('ant-design-vue/es')['Dropdown']
AForm: typeof import('ant-design-vue/es')['Form'] AForm: typeof import('ant-design-vue/es')['Form']
AFormItem: typeof import('ant-design-vue/es')['FormItem'] AFormItem: typeof import('ant-design-vue/es')['FormItem']
@ -21,7 +20,6 @@ declare module '@vue/runtime-core' {
ARow: typeof import('ant-design-vue/es')['Row'] ARow: typeof import('ant-design-vue/es')['Row']
ASelect: typeof import('ant-design-vue/es')['Select'] ASelect: typeof import('ant-design-vue/es')['Select']
ATree: typeof import('ant-design-vue/es')['Tree'] ATree: typeof import('ant-design-vue/es')['Tree']
ATreeNode: typeof import('ant-design-vue/es')['TreeNode']
Draggable: typeof import('./src/components/Draggable.vue')['default'] Draggable: typeof import('./src/components/Draggable.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink'] RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView'] RouterView: typeof import('vue-router')['RouterView']

13
src/views/page/aside/cameraLeftMenu.vue

@ -94,8 +94,9 @@ const onContextMenuClick = (treeKey: string, menuKey: string) => {
arr.push(treeKey) arr.push(treeKey)
arr = [...new Set(arr)] arr = [...new Set(arr)]
expandedKeys.value = arr expandedKeys.value = arr
piniaStore.updateCurSelectKey(NodeTreeItem.value.cbCameraId.toString())
} else if (menuKey == "close") { } else if (menuKey == "close") {
piniaStore.updateCloseVideoKey(NodeTreeItem.value.cbCameraId.toString())
expandedKeys.value = expandedKeys.value.filter((item: any) => { expandedKeys.value = expandedKeys.value.filter((item: any) => {
return item != treeKey return item != treeKey
}) })
@ -103,14 +104,15 @@ const onContextMenuClick = (treeKey: string, menuKey: string) => {
} }
}; };
// //
function selectCamera(treeKeyArr: any, item: any) { function selectCamera(treeKeyArr: any, item: any) {
if (treeKeyArr.length != 0) { // if (treeKeyArr.length != 0) {
console.log(treeKeyArr); // console.log(treeKeyArr);
piniaStore.updateCurTreeKey(treeKeyArr[0].toString()) // piniaStore.updateCurTreeKey(treeKeyArr[0].toString())
} // }
// if (!item.node.isGroup) { // if (!item.node.isGroup) {
piniaStore.updateCurSelectKey(item.node.cbCameraId.toString()) piniaStore.updateCurSelectKey(item.node.cbCameraId.toString())
// } // }
@ -145,7 +147,6 @@ function loadTreeData() {
console.log(res); console.log(res);
if (res.data.code == 200) { if (res.data.code == 200) {
treeData.value = againTreeData(res.data.data) treeData.value = againTreeData(res.data.data)
console.log(treeData.value[0]);
} }
}) })

66
src/views/page/cameraCenter.vue

@ -1,8 +1,6 @@
<template> <template>
<div id="videoWrapper"> <div id="videoWrapper">
<canvas ref="videoCanvas" id="videoCanvas" :width="canvasWidth" :height="canvasHeight">
</canvas>
<!-- <video ref="videoPlayer" id="videoPlayer" disablePictureInPicture autoplay muted <!-- <video ref="videoPlayer" id="videoPlayer" disablePictureInPicture autoplay muted
@loadedmetadata="changeVideoCanvasSize" @mouseover="mouseOverVideo" @mouseout="mouseOutVideo" @loadedmetadata="changeVideoCanvasSize" @mouseover="mouseOverVideo" @mouseout="mouseOutVideo"
@mousedown="mouseDownVideo"> @mousedown="mouseDownVideo">
@ -82,10 +80,10 @@ import VideoControlSimple from './VideoControl/VideoControlSimple.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
let piniaStore = useStore(); let piniaStore = useStore();
let player = <HTMLVideoElement>document.querySelector('#videoPlayer') let player = <HTMLVideoElement>document.querySelector('#videoPlayer')
let canvas = <HTMLCanvasElement>document.querySelector('#videoCanvas')
let canvasWidth = ref(0) let canvasWidth = ref(0)
let canvasHeight = ref(0) let canvasHeight = ref(0)
let curSelectKey = storeToRefs(piniaStore).curSelectKey let curSelectKey = storeToRefs(piniaStore).curSelectKey
let closeVideoKey = storeToRefs(piniaStore).closeVideoKey
let cameraMap = storeToRefs(piniaStore).cameraMap let cameraMap = storeToRefs(piniaStore).cameraMap
let isActiveChoose = ref(false) let isActiveChoose = ref(false)
let labelList = ref<any[]>([]) let labelList = ref<any[]>([])
@ -93,11 +91,10 @@ let addLabel = storeToRefs(piniaStore).addLabel
let addLabelLeft = ref(0); let addLabelLeft = ref(0);
let addLabelTop = ref(0); let addLabelTop = ref(0);
var jessibuca = ref(); var jessibuca = ref();
const curVideoKey=ref() const curVideoKey = ref()
onMounted(() => { onMounted(() => {
{ {
player = <HTMLVideoElement>document.querySelector('#videoPlayer'); player = <HTMLVideoElement>document.querySelector('#videoPlayer');
canvas = <HTMLCanvasElement>document.querySelector('#videoCanvas');
loadVideoPlayer(); loadVideoPlayer();
loadVideoCanvas(); loadVideoCanvas();
changeVideoCanvasSize(); changeVideoCanvasSize();
@ -110,6 +107,14 @@ onMounted(() => {
watch(curSelectKey, (newVal, oldVal) => { watch(curSelectKey, (newVal, oldVal) => {
switchCamera(newVal) switchCamera(newVal)
}) })
watch(closeVideoKey, (newVal, oldVal) => {
if (curVideoKey.value == newVal) {
destroyVideo()
piniaStore.updateCloseVideoKey("")
piniaStore.updateCurSelectKey("")
}
})
watch(addLabel, (newVal, oldVal) => { watch(addLabel, (newVal, oldVal) => {
if (newVal.isAddLabel) { if (newVal.isAddLabel) {
isActiveChoose.value = true isActiveChoose.value = true
@ -120,6 +125,11 @@ watch(addLabel, (newVal, oldVal) => {
} }
} }
}) })
function destroyVideo() {
jessibuca.value.destroy();
create()
labelList.value = []
}
// //
function create() { function create() {
var showOperateBtns = false; // var showOperateBtns = false; //
@ -226,18 +236,7 @@ function changeVideoCanvasSize() {
canvasWidth.value = player.clientWidth; canvasWidth.value = player.clientWidth;
canvasHeight.value = player.clientHeight; canvasHeight.value = player.clientHeight;
} }
function mouseOverVideo() {
// console.log("");
if (!isActiveChoose.value) return;
player.classList.add('activeChoose');
}
function mouseOutVideo() {
// console.log("");
if (!isActiveChoose) return;
player.classList.remove('activeChoose');
}
function mouseDownVideo(e: MouseEvent) { function mouseDownVideo(e: MouseEvent) {
if (!isActiveChoose.value) return; if (!isActiveChoose.value) return;
@ -316,12 +315,10 @@ function switchCamera(cameraId: string) {
return; return;
} }
jessibuca.value.destroy(); destroyVideo()
create()
labelList.value = []
console.log('connect webrtc-steamer.'); console.log('connect webrtc-steamer.');
jessibuca.value.play("ws://192.168.1.119:8080/jessica/live/test.flv") jessibuca.value.play("ws://192.168.1.117:8080/jessica/live/test.flv")
curVideoKey.value=cameraId curVideoKey.value = cameraId
// step4, active camera searcher. // step4, active camera searcher.
markSearchApi.IsExistsSearcher({ markSearchApi.IsExistsSearcher({
'cameraId': cameraObj.id 'cameraId': cameraObj.id
@ -350,11 +347,6 @@ function switchCamera(cameraId: string) {
// step5, load camera labels. // step5, load camera labels.
} }
function getRtspUrl(cameraObj: any): string {
// onvif
// return `rtsp://admin:hk123456@192.168.1.65:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1`;
return `rtsp://${cameraObj.userName}:${cameraObj.password}@${cameraObj.ip}:554/Streaming/Channels/101?transportmode=unicast&profile=Profile_1`;
}
function getLabel(cbCameraId: string | number) { function getLabel(cbCameraId: string | number) {
let str = JSON.stringify({ cbCameraId }) let str = JSON.stringify({ cbCameraId })
markLabelApi.GetList({ queryJson: str }).then((res: any) => { markLabelApi.GetList({ queryJson: str }).then((res: any) => {
@ -404,27 +396,8 @@ function loadMarkLabels(cameraObj: any) {
}); });
}); });
drawMarkLabels(list);
}); });
} }
function drawMarkLabels(markLabels: Array<any>) {
let ctx = canvas.getContext('2d');
if (!ctx) return;
ctx.clearRect(0, 0, canvasWidth.value, canvasHeight.value);
for (let markLabel of markLabels) {
if (!markLabel.inFlag) continue;
let x = Math.round(canvasWidth.value * markLabel.canvasLeftRatio);
let y = Math.round(canvasHeight.value * markLabel.canvasTopRatio);
x = canvasWidth.value * markLabel.canvasLeftRatio;
y = canvasHeight.value * markLabel.canvasTopRatio;
// console.log(markLabel);
ctx.beginPath();
ctx.arc(x, y, 5, 0, 2 * Math.PI);
ctx.fillStyle = "red";
ctx.fill();
ctx.closePath();
}
}
// //
window.onbeforeunload = () => { window.onbeforeunload = () => {
jessibuca.value.destroy() jessibuca.value.destroy()
@ -442,9 +415,6 @@ onUnmounted(() => {
position: relative; position: relative;
overflow: hidden; overflow: hidden;
#videoCanvas {
position: absolute;
}
#videoPlayer { #videoPlayer {
height: 100%; height: 100%;

Loading…
Cancel
Save