feat: CDP remote debugging + screenshot IPC handler
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user