EasyNVR通道关闭水印报错Cannot read properties of undefined

自前段时间EasyDSS新增添加水印功能后,EasyNVR也增加了该功能。在测试该功能期间,我们发现在EasyNVR内通道关闭水印提交报错,报错内容如下:

Error in event handler for “click”: “TypeError: Cannot read properties of undefined (reading ‘width’)”

经过对前端代码进行分析,发现是由于关闭水印时,提交了未使用到定义的水印图宽高信息,这才导致提交宽度与原本水印不匹配,产生报错。

解决问题:

水印提交添加判断,将水印宽高在开启水印时创建即可。

onSubmit() {
  var _this = this;
  var formdata = new FormData();
  if (Number(this.watermarkData.enable) === 0){
    formdata.append("channelId", this.channelData.Channel);
    formdata.append("enable", Number(this.watermarkData.enable));
  }else{
    let { w, mw, h, mh, id } = this.orientation;
    let width = 0;
    let height = 0;
    let mwl = (w / mw)>=701?mw+1:mw;
    let mhl = (h / mh)>=701?mw+1:mw;
    width = w / mwl - this.transform.width;
    height = h / mhl - this.transform.height;
    this.transform = {
      X: this.transform.x * mwl,
      Y: this.transform.y * mhl,
      Width: this.transform.width * mwl,
      Height: this.transform.height * mhl,
    }
  }

EasyNVR平台经过我们不断的改良,已经支持市面上大部分的RTSP/Onvif协议设备:IP Camera/NVR/DVR/编码器等,直播便捷稳定,是安防直播解决方案中一个不错的选择。目前EasyNVR所搭建的明厨亮灶、智慧校园等系统已经在很多项目中落地,如果大家有这方面的需求,欢迎联系我们获取方案。

原文地址:https://www.cnblogs.com/EasyNVR/p/15407651.html