From a2cbaecfa1d6502e35aa5918b96f34b0f3bd3854 Mon Sep 17 00:00:00 2001 From: CaoWangrenbo Date: Sat, 1 Nov 2025 19:52:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E4=BA=91=E5=8F=B0?= =?UTF-8?q?=E6=95=B0=E7=A0=81=E5=8F=98=E7=84=A6=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 11 +++++++++++ templates/index.html | 21 ++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index fd62046..7d96fcb 100644 --- a/app.py +++ b/app.py @@ -108,6 +108,17 @@ def handle_gimbal_ir_mode(data): ptz.set_ir_mode(mode) logger.info(f"云台IR {mode}") +@socketio.on('gimbal_zoom_in') +def handle_gimbal_zoom_in(): + """处理云台缩放""" + ptz.zoom_in() + +@socketio.on('gimbal_zoom_out') +def handle_gimbal_zoom_out(): + """处理云台缩放""" + ptz.zoom_out() + + # @app.route('/get_joystick_data') # def get_joystick_data(): # """API 端点:获取当前摇杆数据""" diff --git a/templates/index.html b/templates/index.html index d570052..3f5158e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -245,12 +245,12 @@
未连接
- +
- +
- +
+ +
+ + +
@@ -336,6 +341,8 @@ const button_gimbal_center = document.getElementById('gimbal_center'); const select_gimbal_pip = document.getElementById('gimbal_pip'); const select_ir_mode = document.getElementById('ir_mode'); + const button_gimbal_zoom_in = document.getElementById('gimbal_zoom_in'); + const button_gimbal_zoom_out = document.getElementById('gimbal_zoom_out'); button_gimbal_center.addEventListener('click', function () { socket.emit('gimbal_center'); @@ -351,6 +358,14 @@ socket.emit('gimbal_ir_mode', selectedValue); }) + button_gimbal_zoom_in.addEventListener('click', function () { + socket.emit('gimbal_zoom_in'); + }); + + button_gimbal_zoom_out.addEventListener('click', function () { + socket.emit('gimbal_zoom_out'); + }) + // 获取摇杆元素 const joystick = document.querySelector('virtual-joystick');