| 1234567891011121314151617 |
- /** 语句:swipe 滑动 */
- const types = ['swipe']
- function parse(action, parseContext) {
- return Object.assign({}, action, { type: 'swipe' })
- }
- async function execute(action, ctx) {
- const { device, resolution, api, calculateSwipeCoordinates } = ctx
- if (!api.sendSwipe) return { success: false, error: '滑动 API 不可用' }
- const { x1, y1, x2, y2 } = calculateSwipeCoordinates(action.value, resolution.width, resolution.height)
- const r = await api.sendSwipe(device, x1, y1, x2, y2, 300)
- if (!r.success) return { success: false, error: `滑动失败: ${r.error}` }
- return { success: true }
- }
- module.exports = { types, parse, execute }
|