feat: CDP remote debugging + screenshot IPC handler
This commit is contained in:
@@ -37,6 +37,10 @@ const electron_1 = require("electron");
|
||||
const path = __importStar(require("path"));
|
||||
const child_process_1 = require("child_process");
|
||||
const fs = __importStar(require("fs"));
|
||||
// 远程调试端口 — Val 通过 CDP 远程控制窗口
|
||||
const REMOTE_DEBUG_PORT = 9222;
|
||||
electron_1.app.commandLine.appendSwitch('remote-debugging-port', String(REMOTE_DEBUG_PORT));
|
||||
electron_1.app.commandLine.appendSwitch('remote-debugging-address', '0.0.0.0');
|
||||
let mainWindow = null;
|
||||
let overlayProcess = null;
|
||||
let monitorProcess = null;
|
||||
@@ -226,6 +230,13 @@ electron_1.ipcMain.handle('open-external', async (_event, url) => {
|
||||
});
|
||||
electron_1.ipcMain.handle('get-resources-path', () => process.resourcesPath);
|
||||
electron_1.ipcMain.handle('fs:exists', (_event, p) => fs.existsSync(p));
|
||||
electron_1.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' };
|
||||
});
|
||||
// === 应用生命周期 ===
|
||||
electron_1.app.whenReady().then(createWindow);
|
||||
electron_1.app.on('window-all-closed', () => {
|
||||
|
||||
Reference in New Issue
Block a user