From 2d93fe0f2e41bba29e13e819ed99000a2b374b1a Mon Sep 17 00:00:00 2001
From: jjLv <1981429112@qq.com>
Date: Tue, 21 Jan 2025 14:19:05 +0800
Subject: [PATCH] =?UTF-8?q?feat(deviceManagement):=20=E4=BC=98=E5=8C=96?=
 =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=AE=BE=E5=A4=87=E7=9B=91=E6=8E=A7=E4=B8=8E?=
 =?UTF-8?q?=E8=B0=83=E8=AF=95=E9=A1=B5=E9=9D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 重构方向控制和缩放控制的按钮样式,使用 Element UI 的圆形按钮
- 优化 3D云台控制按钮样式,使用 round 属性
- 改进快捷键设置功能:
  - 添加键位重复检查逻辑
  -重构快捷键设置的数据结构,使其更加清晰
  - 通过计算属性自动生成 keyMap,提高代码可维护性
- 调整部分样式,如按钮间距、文本对齐等,提升页面视觉效果
---
 .../videoDeviceMgmt/monitoringAndDebug.vue    | 106 ++++++++++--------
 1 file changed, 62 insertions(+), 44 deletions(-)
diff --git a/src/views/deviceManagement/videoDeviceMgmt/monitoringAndDebug.vue b/src/views/deviceManagement/videoDeviceMgmt/monitoringAndDebug.vue
index 5e46123d..183f4b51 100644
--- a/src/views/deviceManagement/videoDeviceMgmt/monitoringAndDebug.vue
+++ b/src/views/deviceManagement/videoDeviceMgmt/monitoringAndDebug.vue
@@ -23,47 +23,43 @@
       
       
         
 
         
         
           
           
           
-            
+            
               
             
-            
+            
               
             
             光圈
@@ -99,8 +95,8 @@
       
       
         
-          关闭云台
-          开启云台
+          关闭云台
+          开启云台
         
        
 
@@ -129,7 +125,7 @@
               {{item.label}}
               
@@ -156,39 +152,27 @@ export default {
         line1: '',
         line2: ''
       },
-      keyMap: {
-        'w': 'up',
-        's': 'down',
-        'a': 'left',
-        'd': 'right',
-        'q': 'zoomIn',
-        'e': 'zoomOut',
-        'r': 'focusIn',
-        't': 'focusOut',
-        'f': 'capture',
-        'g': 'record'
-      },
-      // 快捷键设置数据结构
+      // 合并后的快捷键设置数据结构
       shortcutSettings: [
         [
-          { label: '上', key: 'W' },
-          { label: '放大', key: 'Q' }
+          { label: '上', key: 'W', action: 'up' },
+          { label: '放大', key: 'Q', action: 'zoomIn' }
         ],
         [
-          { label: '下', key: 'S' },
-          { label: '缩小', key: 'E' }
+          { label: '下', key: 'S', action: 'down' },
+          { label: '缩小', key: 'E', action: 'zoomOut' }
         ],
         [
-          { label: '左', key: 'A' },
-          { label: '远焦', key: 'R' }
+          { label: '左', key: 'A', action: 'left' },
+          { label: '远焦', key: 'R', action: 'focusIn' }
         ],
         [
-          { label: '右', key: 'D' },
-          { label: '近焦', key: 'T' }
+          { label: '右', key: 'D', action: 'right' },
+          { label: '近焦', key: 'T', action: 'focusOut' }
         ],
         [
-          { label: '抓拍', key: 'F' },
-          { label: '录像', key: 'G' }
+          { label: '抓拍', key: 'F', action: 'capture' },
+          { label: '录像', key: 'G', action: 'record' }
         ]
       ]
     }
@@ -210,15 +194,40 @@ export default {
       const key = event.key.toUpperCase();
       // 只允许字母键
       if (/^[A-Z]$/.test(key)) {
+        // 检查是否已经存在相同的键位
+        const isDuplicate = this.shortcutSettings.some(row =>
+          row.some(item => item.key === key && !(item.key === this.shortcutSettings[rowIndex][colIndex].key))
+        );
+
+        if (isDuplicate) {
+          this.$message.error('该键位已被使用,请选择其他键位');
+          return;
+        }
+
+        // 获取当前的键位
+        const oldKey = this.shortcutSettings[rowIndex][colIndex].key;
+
+        // 更新快捷键设置
         this.shortcutSettings[rowIndex][colIndex].key = key;
       }
     }
   },
+  computed: {
+    keyMap() {
+      return this.shortcutSettings.reduce((map, row) => {
+        row.forEach(item => {
+          map[item.key] = item.action;
+        });
+        return map;
+      }, {});
+    }
+  },
   mounted() {
     // 键盘事件监听
     window.addEventListener('keydown', (e) => {
-      if (this.keyMap[e.key]) {
-        this.control(this.keyMap[e.key])
+      const key = e.key.toUpperCase();
+      if (this.keyMap[key]) {
+        this.control(this.keyMap[key])
       }
     })
   }
@@ -290,7 +299,7 @@ export default {
 
 .horizontal-buttons {
   display: flex;
-  gap: 5px;
+  gap: 32px;
 }
 
 .zoom-controls {
@@ -312,6 +321,7 @@ export default {
 .cloud-buttons {
   display: flex;
   gap: 10px;
+  justify-content: space-evenly;
 }
 
 .view-controls {
@@ -336,6 +346,7 @@ export default {
 }
 
 .watermark-title{
+  cursor: pointer;
   font-size: 13px;
   display: flex;
   flex-direction: row-reverse;
@@ -379,6 +390,7 @@ export default {
   background: #f5f7fa;
   color: rgb(25, 190, 107);
   font-weight: bold;
+  text-align: center;
 }
 
 .control-title {
@@ -390,10 +402,16 @@ export default {
 }
 
 .el-button {
-  padding: 8px 15px;
+  padding: 8px 9px;
 }
 
 .el-button [class^="el-icon-"] {
   margin: 0;
 }
+
+.column-label{
+  display: flex;
+  flex-direction: column;
+  justify-content: center;
+}