Explorar el Código

摄像头逻辑修改

tianyabing hace 2 años
padre
commit
4536c4f224
Se han modificado 7 ficheros con 20 adiciones y 267 borrados
  1. 0 1
      index.html
  2. 11 11
      package-lock.json
  3. 1 1
      package.json
  4. 0 246
      src/components/hkws/hikComp.vue
  5. 5 4
      src/components/security/camera/hkwsCamera.vue
  6. 2 3
      src/main.js
  7. 1 1
      vite.config.js

+ 0 - 1
index.html

@@ -6,7 +6,6 @@
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title>智慧楼宇平台</title>
     <script type="module" src="/src/plugins/gverify.js"></script>
-    <script type="module" src="/src/plugins/hkws/web-control_1.2.5.min.js"></script>
   </head>
   <body>
     <div id="app"></div>

+ 11 - 11
package-lock.json

@@ -14,8 +14,8 @@
         "echarts": "^5.4.1",
         "echarts-liquidfill": "^3.1.0",
         "element-resize-detector": "^1.2.4",
+        "hikvs-web": "^1.0.4",
         "html2canvas": "^1.4.1",
-        "jsencrypt": "^3.3.2",
         "jspdf": "^2.5.1",
         "moment": "^2.29.4",
         "pinia": "^2.0.16",
@@ -3638,6 +3638,11 @@
         "he": "bin/he"
       }
     },
+    "node_modules/hikvs-web": {
+      "version": "1.0.4",
+      "resolved": "https://registry.npmmirror.com/hikvs-web/-/hikvs-web-1.0.4.tgz",
+      "integrity": "sha512-TUpIDhzTEf6uwPw/IZ0auv6Kau2Jg3n264/x79XzDflE//4gUbJT+tPCH+BoHRvsSRz0YW//Vbp6IsAuT/uFog=="
+    },
     "node_modules/hosted-git-info": {
       "version": "2.8.9",
       "resolved": "https://registry.npmmirror.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
@@ -4137,11 +4142,6 @@
         "js-yaml": "bin/js-yaml.js"
       }
     },
-    "node_modules/jsencrypt": {
-      "version": "3.3.2",
-      "resolved": "https://registry.npmmirror.com/jsencrypt/-/jsencrypt-3.3.2.tgz",
-      "integrity": "sha512-arQR1R1ESGdAxY7ZheWr12wCaF2yF47v5qpB76TtV64H1pyGudk9Hvw8Y9tb/FiTIaaTRUyaSnm5T/Y53Ghm/A=="
-    },
     "node_modules/jsesc": {
       "version": "3.0.2",
       "resolved": "https://registry.npmmirror.com/jsesc/-/jsesc-3.0.2.tgz",
@@ -9601,6 +9601,11 @@
       "resolved": "https://registry.npmmirror.com/he/-/he-1.2.0.tgz",
       "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
     },
+    "hikvs-web": {
+      "version": "1.0.4",
+      "resolved": "https://registry.npmmirror.com/hikvs-web/-/hikvs-web-1.0.4.tgz",
+      "integrity": "sha512-TUpIDhzTEf6uwPw/IZ0auv6Kau2Jg3n264/x79XzDflE//4gUbJT+tPCH+BoHRvsSRz0YW//Vbp6IsAuT/uFog=="
+    },
     "hosted-git-info": {
       "version": "2.8.9",
       "resolved": "https://registry.npmmirror.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
@@ -10006,11 +10011,6 @@
         "argparse": "^2.0.1"
       }
     },
-    "jsencrypt": {
-      "version": "3.3.2",
-      "resolved": "https://registry.npmmirror.com/jsencrypt/-/jsencrypt-3.3.2.tgz",
-      "integrity": "sha512-arQR1R1ESGdAxY7ZheWr12wCaF2yF47v5qpB76TtV64H1pyGudk9Hvw8Y9tb/FiTIaaTRUyaSnm5T/Y53Ghm/A=="
-    },
     "jsesc": {
       "version": "3.0.2",
       "resolved": "https://registry.npmmirror.com/jsesc/-/jsesc-3.0.2.tgz",

+ 1 - 1
package.json

@@ -14,8 +14,8 @@
     "echarts": "^5.4.1",
     "echarts-liquidfill": "^3.1.0",
     "element-resize-detector": "^1.2.4",
+    "hikvs-web": "^1.0.4",
     "html2canvas": "^1.4.1",
-    "jsencrypt": "^3.3.2",
     "jspdf": "^2.5.1",
     "moment": "^2.29.4",
     "pinia": "^2.0.16",

+ 0 - 246
src/components/hkws/hikComp.vue

@@ -1,246 +0,0 @@
-<script>
-//import {WebControl} from '@/plugins/hkws/jsWebControl.min.js'
-export default {
-    props: {
-        nameId: {
-            type: String,
-            required: true,
-            default: 'playWnd'
-        },
-        cameraIndexCode: {
-            type: String,
-            required: true
-        },
-        playConfig: {
-            type: Object,
-            required: true
-        }
-    },
-    data() {
-        return {
-            pubKey: "",           // 秘钥
-            oWebControl: null,    // 播放插件的实例对象
-            swfWidth: "",         // 播放器窗口宽
-            swfHeight: "",        // 播放器窗口高
-            initCount: 0,         // 创建实例次数,
-            flag: true,           // 全屏的辅助参数
-            /** start 监控点信息配置 */
-            cameraConfig: {
-                cameraIndexCode: this.cameraIndexCode.trim(),// 监控点编号值,必填
-                streamMode: 0,      // 主子码流标识:0-主码流,1-子码流
-                transMode: 1,       // 传输协议:0-UDP,1-TCP
-                gpuMode: 0,         // 是否启用GPU硬解,0-不启用,1-启用
-                wndId: -1,          // 播放窗口序号(在2x2以上布局下可指定播放窗口)
-            }
-            /** end 监控点信息配置 */
-        }
-    },
-    render(h) {
-        return h(
-            'div', {
-                attrs: {
-                    id: this.nameId
-                }
-            }
-        )
-    },
-    mounted() {
-        // 获取播放器宽高,便于自适应设置
-        this.swfWidth = document.getElementById(this.nameId).offsetWidth;
-        this.swfHeight = document.getElementById(this.nameId).offsetHeight;
-        // 创建播放实例化
-        this.initPlugin();
-        // 监听窗口缩放resize事件,使插件窗口尺寸跟随DIV窗口变化
-        window.addEventListener('resize', () => {
-            this.autoOffset();
-        });
-        // 监听滚动条scroll事件,使插件窗口跟随浏览器滚动而移动
-        window.addEventListener('scroll', () => {
-            this.autoOffset();
-        })
-        // 4s后执行,防止加载顺序错误
-        setTimeout(() => {
-            this.startPreview();
-        }, 4000)
-    },
-    methods: {
-        // 创建播放实例
-        initPlugin() {
-            this.oWebControl = new WebControl({
-                szPluginContainer: this.nameId,                       // 指定容器id
-                iServicePortStart: 15900,                           // 指定起止端口号,建议使用该值
-                iServicePortEnd: 15900,
-                szClassId: "23BF3B0A-2C56-4D97-9C03-0CB103AA8F11",   // 用于IE10使用ActiveX的clsid
-                cbConnectSuccess: () => {
-                    // 创建WebControl实例成功
-                    this.oWebControl.JS_StartService("window", {         // WebControl实例创建成功后需要启动服务
-                        dllPath: "./VideoPluginConnect.dll"         // 值"./VideoPluginConnect.dll"写死
-                    }).then(() => {                               // 启动插件服务成功
-                        this.oWebControl.JS_SetWindowControlCallback({   // 设置消息回调
-                            cbIntegrationCallBack: this.cbIntegrationCallBack
-                        });
-                        this.oWebControl.JS_CreateWnd(this.nameId, this.swfWidth, this.swfHeight).then(() => { //JS_CreateWnd创建视频播放窗口,宽高可设定
-                            this.init();  // 创建播放实例成功后初始化
-                        });
-                    }, function () { // 启动插件服务失败
-                        document.getElementById(this.nameId).innerHTML = `插件启动失败,请检查插件安装状态,<a href = '/static/VideoWebPlugin.exe'">点击下载安装</a>,安装后重启浏览器重试`
-                    });
-                },
-                cbConnectError: () => { // 创建WebControl实例失败
-                    this.oWebControl = null;
-                    document.getElementById(this.nameId).innerText = "插件未启动,请稍候..."
-                    WebControl.JS_WakeUp("VideoWebPlugin://"); // 程序未启动时执行error函数,采用wakeup来唤醒程序
-                    this.initCount++;
-                    if (this.initCount < 3) {
-                        setTimeout(() => {
-                            this.initPlugin();
-                        }, 2000)
-                    } else {
-                        document.getElementById(this.nameId).innerHTML = `插件启动失败,请检查插件安装状态,<a href = '/static/VideoWebPlugin.exe'">点击下载安装</a>,安装后重启浏览器重试`
-                    }
-                },
-                cbConnectClose: (bNormalClose) => {
-                    // 异常断开:bNormalClose = false
-                    // JS_Disconnect正常断开:bNormalClose = true
-                    document.getElementById(this.nameId).innerHTML = `插件启动失败,请检查插件安装状态,<a href = '/static/VideoWebPlugin.exe'">点击下载安装</a>,安装后重启浏览器重试`
-                    console.log("cbConnectClose", bNormalClose);
-                    this.oWebControl = null;
-                }
-            });
-        },
-        // 设置窗口控制回调(好像没用,官方示例有,先留着)
-        setCallbacks() {
-            this.oWebControl.JS_SetWindowControlCallback({
-                cbIntegrationCallBack: cbIntegrationCallBack
-            });
-        },
-        // 推送消息(事件交互)
-        cbIntegrationCallBack(oData) {
-            if(oData.responseMsg.type == 7) {   // 如果双击
-                if(this.flag) {
-                    this.oWebControl.JS_RequestInterface({
-                        funcName: "setFullScreen"   // 那么全屏
-                    })
-                } else {
-                    this.oWebControl.JS_RequestInterface({
-                        funcName: "exitFullScreen"   // 退出全屏
-                    })
-                }
-            }
-            if(oData.responseMsg.msg.result == 1024) {  // 进入全屏的状态码
-                this.flag = false;
-            }
-            if(oData.responseMsg.msg.result == 1025) {  // 退出全屏后的状态码
-                this.flag = true;
-            }
-        },
-        // 初始化
-        init() {
-            this.getPubKey(() => {
-                this.oWebControl.JS_RequestInterface({
-                    funcName: "init",
-                    argument: JSON.stringify({
-                        appkey: this.playConfig.appkey,                               // 综合安防管理平台(API网关)提供的appkey,必填
-                        secret: this.setEncrypt(this.playConfig.secret),  // 综合安防管理平台(API网关)提供的secret,必填
-                        ip: this.playConfig.ip,                                  // 综合安防管理平台(API网关)IP地址,必填
-                        playMode: this.playConfig.playMode,                                  // 初始播放模式,(决定显示预览还是回放界面):0-预览,1-回放
-                        port: this.playConfig.port,                                  // 综合安防管理平台(API网关)端口,若启用HTTPS协议,默认443
-                        snapDir: this.playConfig.snapDir,                                  // 抓图存储路径
-                        videoDir: this.playConfig.videoDir,                                  // 紧急录像或录像剪辑存储路径
-                        layout: this.playConfig.layout,                                  // playMode指定模式的布局
-                        enableHTTPS: this.playConfig.enableHTTPS,                                  // 是否启用HTTPS协议与综合安防管理平台交互,这里总是填1
-                        encryptedFields: this.playConfig.encryptedFields,                                  // 加密字段,默认加密领域为secret
-                        showToolbar: this.playConfig.showToolbar,                                  // 是否显示工具栏,0-不显示,非0-显示
-                        showSmart: this.playConfig.showSmart,                                  // 是否显示智能信息(如配置移动侦测后画面上的线框),0-不显示,非0-显示
-                        buttonIDs: this.playConfig.buttonIDs,                                  // 自定义工具条按钮 上(具体参数见文档:p13 - p14)
-                        toolBarButtonIDs: this.playConfig.toolBarButtonIDs,                                  // 自定义工具条按钮 下(具体参数见文档:p14 - p15)
-                    })
-                }).then((oData) => {
-                    this.oWebControl.JS_Resize(this.swfWidth, this.swfHeight);  // 初始化后resize一次,规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题
-                });
-            });
-        },
-        //获取公钥
-        getPubKey(callback) {
-            this.oWebControl.JS_RequestInterface({
-                funcName: "getRSAPubKey",
-                argument: JSON.stringify({
-                    keyLength: 1024
-                })
-            }).then((oData) => {
-                if (oData.responseMsg.data) {
-                    this.pubKey = oData.responseMsg.data;
-                    callback()
-                }
-            })
-        },
-        // RSA加密
-        setEncrypt(value) {
-            var encrypt = new this.$jsEncrypt;
-            encrypt.setPublicKey(this.pubKey);
-            return encrypt.encrypt(value);
-        },
-        // 视频预览功能 - 单个预览
-        startPreview() {
-            this.oWebControl.JS_RequestInterface({
-                funcName: "startPreview",
-                argument: JSON.stringify(this.cameraConfig)
-            })
-        },
-        // 停止预览
-        closePreview() {
-            this.oWebControl.JS_RequestInterface({
-                funcName: "stopAllPreview"
-            });
-        },
-        // 设置窗口裁剪,当因滚动条滚动导致窗口需要被遮住的情况下需要JS_CuttingPartWindow部分窗口
-        setWndCover() {
-            let iWidth = document.documentElement.clientWidth;
-            let iHeight = document.documentElement.clientHeight;
-            let oDivRect = document.getElementById(this.nameId).getBoundingClientRect();
-            let iCoverLeft = oDivRect.left < 0 ? Math.abs(oDivRect.left) : 0;
-            let iCoverTop = oDivRect.top < 0 ? Math.abs(oDivRect.top) : 0;
-            let iCoverRight = oDivRect.right - iWidth > 0 ? Math.round(oDivRect.right - iWidth) : 0;
-            let iCoverBottom = oDivRect.bottom - iHeight > 0 ? Math.round(oDivRect.bottom - iHeight) : 0;
-            iCoverLeft = iCoverLeft > this.swfWidth ? this.swfWidth : iCoverLeft;
-            iCoverTop = iCoverTop > this.swfHeight ? this.swfHeight : iCoverTop;
-            iCoverRight = iCoverRight > this.swfWidth ? this.swfWidth : iCoverRight;
-            iCoverBottom = iCoverBottom > this.swfHeight ? this.swfHeight : iCoverBottom;
-            this.oWebControl.JS_RepairPartWindow(0, 0, this.swfWidth + 1, this.swfHeight); // 多1个像素点防止还原后边界缺失一个像素条
-            if (iCoverLeft != 0) {
-                this.oWebControl.JS_CuttingPartWindow(0, 0, iCoverLeft, this.swfHeight);
-            }
-            if (iCoverTop != 0) {
-                this.oWebControl.JS_CuttingPartWindow(0, 0, this.swfWidth + 1, iCoverTop); // 多剪掉一个像素条,防止出现剪掉一部分窗口后出现一个像素条
-            }
-            if (iCoverRight != 0) {
-                this.oWebControl.JS_CuttingPartWindow(this.swfWidth - iCoverRight, 0, iCoverRight, this.swfHeight);
-            }
-            if (iCoverBottom != 0) {
-                this.oWebControl.JS_CuttingPartWindow(0, this.swfHeight - iCoverBottom, this.swfWidth, iCoverBottom);
-            }
-        },
-        // 播放器窗口大小位置设置
-        autoOffset() {
-            if (this.oWebControl != null) {
-                this.oWebControl.JS_Resize(this.swfWidth, this.swfHeight);
-                this.setWndCover();
-            }
-        }
-    },
-    destroyed() {
-        // 销毁播放实例
-        this.oWebControl.JS_RequestInterface({
-            funcName: "destroyWnd"
-        });
-        this.oWebControl.JS_StopService('window')
-            .then(() => {
-            })
-            .catch((err) => console.log(err))
-        this.oWebControl.JS_DestroyWnd()
-            .then(() => {
-            })
-            .catch((err) => console.log(err))
-    }
-}
-</script>

+ 5 - 4
src/components/security/camera/hkwsCamera.vue

@@ -1,15 +1,13 @@
 <template>
-    <HikComp v-if="show" ref="hkws" class="hkws-camera" :playConfig.sync="playConfig"
+    <hik-comp v-if="show" ref="hkws" class="hkws-camera" :playConfig.sync="playConfig"
              :nameId="jkInfo.nameId" :cameraIndexCode.sync="jkInfo.cameraIndexCode"/>
 
 </template>
 
 <script>
 import apiSecurityCamera from "@/api/security/apiSecurityCamera";
-import HikComp from "@/components/hkws/hikComp.vue";
 
 export default {
-    components: {HikComp},
     data() {
         return {
             show: false,
@@ -29,7 +27,7 @@ export default {
             this.jkInfo.cameraIndexCode = val;
             this.$refs.hkws.cameraConfig.cameraIndexCode = val;
             this.$refs.hkws.startPreview();
-        }
+        },
     },
     computed: {
         playConfig: function () {
@@ -83,6 +81,9 @@ export default {
     },
     beforeDestroy() {
         if (this.$refs.hkws && this.$refs.hkws.oWebControl) {
+            this.$refs.hkws.oWebControl.JS_RequestInterface({
+                funcName: "destroyWnd"
+            });
             this.$refs.hkws.oWebControl.JS_StopService('window')
                 .then(() => {
                 })

+ 2 - 3
src/main.js

@@ -25,9 +25,8 @@ Vue.prototype.$constant = constant
 Vue.prototype.$echarts = echarts
 Vue.prototype.$moment = moment
 
-
-import JsEncrypt from 'jsencrypt'
-Vue.prototype.$jsEncrypt = JsEncrypt
+import hikComp from 'hikvs-web'
+Vue.use(hikComp)
 
 Vue.use(Antd) 
 Vue.use(PiniaVuePlugin)

+ 1 - 1
vite.config.js

@@ -113,7 +113,7 @@ export default defineConfig(({ command }) => {
       proxy: {
         "/ioc-api": {
            //target: "http://127.0.0.1:10099",
-          target: "http://121.43.55.7:10091/ioc-server",
+          target: "http://10.12.242.163:10091/ioc-server",
           changeOrigin: true,
           rewrite: (path) => path.replace(/^\/ioc-api/, ""),
         },