Remote connection

This commit is contained in:
2026-01-09 19:49:38 +01:00
parent 87c722b5ae
commit 8c551a90f4
28 changed files with 3134 additions and 327 deletions

View File

@@ -1,8 +1,15 @@
const { app, BrowserWindow, ipcMain, desktopCapturer } = require('electron');
const fs = require('fs');
const fsp = fs.promises;
const path = require('path');
let mainWindow;
// Suppress Autofill devtools errors by disabling related features
app.commandLine.appendSwitch('disable-features', 'Autofill,AutofillAssistant,AutofillServerCommunication');
// Allow media autoplay without user gesture (bypasses Chromium autoplay policy)
app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required');
function createWindow() {
mainWindow = new BrowserWindow({
width: 1400,
@@ -23,7 +30,9 @@ function createWindow() {
// In development, load from Angular dev server
if (process.env.NODE_ENV === 'development') {
mainWindow.loadURL('http://localhost:4200');
mainWindow.webContents.openDevTools();
if (process.env.DEBUG_DEVTOOLS === '1') {
mainWindow.webContents.openDevTools();
}
} else {
// In production, load the built Angular app
// The dist folder is at the project root, not in electron folder
@@ -83,3 +92,29 @@ ipcMain.handle('get-sources', async () => {
ipcMain.handle('get-app-data-path', () => {
return app.getPath('userData');
});
// IPC for basic file operations used by renderer
ipcMain.handle('file-exists', async (_event, filePath) => {
try {
await fsp.access(filePath, fs.constants.F_OK);
return true;
} catch {
return false;
}
});
ipcMain.handle('read-file', async (_event, filePath) => {
const data = await fsp.readFile(filePath);
return data.toString('base64');
});
ipcMain.handle('write-file', async (_event, filePath, base64Data) => {
const buffer = Buffer.from(base64Data, 'base64');
await fsp.writeFile(filePath, buffer);
return true;
});
ipcMain.handle('ensure-dir', async (_event, dirPath) => {
await fsp.mkdir(dirPath, { recursive: true });
return true;
});

View File

@@ -16,4 +16,5 @@ contextBridge.exposeInMainWorld('electronAPI', {
readFile: (filePath) => ipcRenderer.invoke('read-file', filePath),
writeFile: (filePath, data) => ipcRenderer.invoke('write-file', filePath, data),
fileExists: (filePath) => ipcRenderer.invoke('file-exists', filePath),
ensureDir: (dirPath) => ipcRenderer.invoke('ensure-dir', dirPath),
});