feat: add OpenCode update and in-app Browser features
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { app, BrowserWindow, dialog, ipcMain, Menu, nativeTheme, Notification, powerMonitor, session, shell } from 'electron';
|
||||
import { app, BrowserWindow, dialog, ipcMain, Menu, nativeTheme, Notification, powerMonitor, session, shell, webContents } from 'electron';
|
||||
import contextMenu from 'electron-context-menu';
|
||||
import log from 'electron-log/main.js';
|
||||
import dgram from 'node:dgram';
|
||||
@@ -1181,6 +1181,7 @@ const createBrowserWindow = ({ label, restoreGeometry, url }) => {
|
||||
backgroundThrottling: true,
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
webviewTag: true,
|
||||
// sandbox must stay off: the preload uses contextBridge + ipcRenderer
|
||||
// from Electron's Node layer. contextIsolation + nodeIntegration:false
|
||||
// keep the renderer world walled off from Node. Do NOT flip to true —
|
||||
@@ -1431,6 +1432,8 @@ const createMiniChatWindow = async ({ mode, sessionId = '', directory = '', proj
|
||||
backgroundThrottling: true,
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
webviewTag: true,
|
||||
// sandbox must stay off
|
||||
sandbox: false,
|
||||
},
|
||||
});
|
||||
@@ -1859,6 +1862,21 @@ const handleInvoke = async (browserWindow, command, args = {}) => {
|
||||
case 'desktop_get_app_version':
|
||||
return APP_VERSION;
|
||||
|
||||
case 'desktop_browser_capture_page': {
|
||||
const wcId = Number.isFinite(args.webContentsId) ? Math.trunc(args.webContentsId) : null;
|
||||
if (wcId === null || wcId < 0) throw new Error('webContentsId is required');
|
||||
const wc = webContents.fromId(wcId);
|
||||
if (!wc || wc.isDestroyed()) throw new Error('WebContents not found');
|
||||
const image = await wc.capturePage();
|
||||
const buffer = image.toJPEG(82);
|
||||
return {
|
||||
mime: 'image/jpeg',
|
||||
base64: buffer.toString('base64'),
|
||||
width: image.getSize().width,
|
||||
height: image.getSize().height,
|
||||
};
|
||||
}
|
||||
|
||||
case 'desktop_capture_page_rect': {
|
||||
if (!browserWindow || browserWindow.isDestroyed()) {
|
||||
throw new Error('Window is not available');
|
||||
|
||||
Reference in New Issue
Block a user