Browse Source

update code

yb 1 day ago
parent
commit
d7288bc3d2
2 changed files with 17 additions and 14 deletions
  1. 4 7
      src/types/index.ts
  2. 13 7
      src/views/live-stream/composables/usePTZ.ts

+ 4 - 7
src/types/index.ts

@@ -294,16 +294,13 @@ export type PTZAction =
   | 'down'
   | 'left'
   | 'right'
+  | 'up_left'
+  | 'up_right'
+  | 'down_left'
+  | 'down_right'
   | 'zoom_in'
   | 'zoom_out'
   | 'stop'
-  | 'UP'
-  | 'DOWN'
-  | 'LEFT'
-  | 'RIGHT'
-  | 'ZOOM_IN'
-  | 'ZOOM_OUT'
-  | 'STOP'
 
 // PTZ 直接控制请求 (pan/tilt/zoom 方式)
 export interface PTZControlRequest {

+ 13 - 7
src/views/live-stream/composables/usePTZ.ts

@@ -14,11 +14,17 @@ import type { LiveStreamDTO, PTZAction } from '@/types'
 import type { PTZCapabilities, LocalPreset, TimelinePoint } from '../types'
 
 const directionToAction: Record<string, PTZAction> = {
-  UP: 'up',
-  DOWN: 'down',
-  LEFT: 'left',
-  RIGHT: 'right',
-  STOP: 'stop'
+  up: 'up',
+  down: 'down',
+  left: 'left',
+  right: 'right',
+  up_left: 'up_left',
+  up_right: 'up_right',
+  down_left: 'down_left',
+  down_right: 'down_right',
+  zoom_in: 'zoom_in',
+  zoom_out: 'zoom_out',
+  stop: 'stop'
 }
 
 export function usePTZ(
@@ -54,8 +60,8 @@ export function usePTZ(
       return
     }
     try {
-      const command = directionToAction[direction] || 'stop'
-      const res = await ptzControl({ cameraId, command, speed: ptzSpeed.value })
+      const command = directionToAction[direction]
+      const res = await ptzControl({ cameraId, action: command, speed: ptzSpeed.value })
       if (!res.success) {
         console.error('PTZ 控制失败', res.errMsg)
       }