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 path = __importStar(require("path"));
|
||||||
const child_process_1 = require("child_process");
|
const child_process_1 = require("child_process");
|
||||||
const fs = __importStar(require("fs"));
|
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 mainWindow = null;
|
||||||
let overlayProcess = null;
|
let overlayProcess = null;
|
||||||
let monitorProcess = 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('get-resources-path', () => process.resourcesPath);
|
||||||
electron_1.ipcMain.handle('fs:exists', (_event, p) => fs.existsSync(p));
|
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.whenReady().then(createWindow);
|
||||||
electron_1.app.on('window-all-closed', () => {
|
electron_1.app.on('window-all-closed', () => {
|
||||||
|
|||||||
@@ -3,6 +3,11 @@ import * as path from 'path';
|
|||||||
import { spawn, execSync, ChildProcess } from 'child_process';
|
import { spawn, execSync, ChildProcess } from 'child_process';
|
||||||
import * as fs from 'fs';
|
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 mainWindow: BrowserWindow | null = null;
|
||||||
let overlayProcess: ChildProcess | null = null;
|
let overlayProcess: ChildProcess | null = null;
|
||||||
let monitorProcess: 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('get-resources-path', () => process.resourcesPath);
|
||||||
ipcMain.handle('fs:exists', (_event, p: string) => fs.existsSync(p));
|
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);
|
app.whenReady().then(createWindow);
|
||||||
|
|||||||
Reference in New Issue
Block a user