Remote connection
This commit is contained in:
@@ -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;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user