feat: CDP remote debugging + screenshot IPC handler

This commit is contained in:
Chen Gu
2026-05-09 09:34:18 +08:00
parent a00abed20b
commit dc3db7549c
2 changed files with 23 additions and 0 deletions

View File

@@ -3,6 +3,11 @@ import * as path from 'path';
import { spawn, execSync, ChildProcess } from 'child_process';
import * as fs from 'fs';
// 远程调试端口 — Val 通过 CDP 远程控制窗口
const REMOTE_DEBUG_PORT = 9222;
app.commandLine.appendSwitch('remote-debugging-port', String(REMOTE_DEBUG_PORT));
app.commandLine.appendSwitch('remote-debugging-address', '0.0.0.0');
let mainWindow: BrowserWindow | null = null;
let overlayProcess: ChildProcess | null = null;
let monitorProcess: ChildProcess | null = null;
@@ -204,6 +209,13 @@ ipcMain.handle('open-external', async (_event, url: string) => {
});
ipcMain.handle('get-resources-path', () => process.resourcesPath);
ipcMain.handle('fs:exists', (_event, p: string) => fs.existsSync(p));
ipcMain.handle('app:screenshot', async () => {
if (mainWindow && !mainWindow.isDestroyed()) {
const img = await mainWindow.webContents.capturePage();
return { success: true, data: img.toPNG().toString('base64') };
}
return { success: false, error: 'No window' };
});
// === 应用生命周期 ===
app.whenReady().then(createWindow);