| 1234567891011121314151617181920212223242526272829303132 |
- const { contextBridge, ipcRenderer } = require('electron');
- contextBridge.exposeInMainWorld('electronAPI', {
- getAdbPathConfig: () => ipcRenderer.invoke('get-adb-path-config'),
- scanADBDevices: () => ipcRenderer.invoke('scan-adb-devices'),
- getADBDevices: () => ipcRenderer.invoke('get-adb-devices'),
- connectADBDevice: (ipPort) => ipcRenderer.invoke('connect-adb-device', ipPort),
- getDeviceResolution: (ipPort) => ipcRenderer.invoke('get-device-resolution', ipPort),
- captureScreenshot: (ipPort, options) => ipcRenderer.invoke('capture-screenshot', ipPort, options),
- sendTap: (ipPort, x, y) => ipcRenderer.invoke('send-tap', ipPort, x, y),
- sendSwipe: (ipPort, x1, y1, x2, y2, duration) => ipcRenderer.invoke('send-swipe', ipPort, x1, y1, x2, y2, duration),
- sendText: (ipPort, text) => ipcRenderer.invoke('send-text', ipPort, text),
- sendScroll: (ipPort, direction, width, height, scrollDistance, duration) => ipcRenderer.invoke('send-scroll', ipPort, direction, width, height, scrollDistance, duration),
- sendKeyEvent: (ipPort, keyCode) => ipcRenderer.invoke('send-key-event', ipPort, keyCode),
- // 监听设备发现事件
- onDeviceFound: (callback) => {
- ipcRenderer.on('device-found', (event, device) => callback(device));
- },
- // 移除设备发现事件监听器
- removeDeviceFoundListener: () => {
- ipcRenderer.removeAllListeners('device-found');
- },
- // 获取 static 目录下的文件夹列表
- getStaticFolders: () => ipcRenderer.invoke('get-static-folders'),
- // 图像匹配并获取坐标
- matchImageAndGetCoordinate: (ipPort, templateImagePath) => ipcRenderer.invoke('match-image-and-get-coordinate', ipPort, templateImagePath),
- // 读取 processing.json 文件
- readProcessingJson: (folderName) => ipcRenderer.invoke('read-processing-json', folderName),
- // 文字识别并获取坐标
- findTextAndGetCoordinate: (ipPort, targetText) => ipcRenderer.invoke('find-text-and-get-coordinate', ipPort, targetText),
- });
|