initial commit
This commit is contained in:
36
iva_electron/src/main.js
Normal file
36
iva_electron/src/main.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
require('dotenv').config({ debug: true, path: path.resolve(__dirname, '..', '.env') });
|
||||
|
||||
function createWindow() {
|
||||
const width = parseInt(process.env.WIDTH) || 800;
|
||||
const height = parseInt(process.env.HEIGHT) || 600;
|
||||
const appTitle = process.env.APP_TITLE || 'Electron App';
|
||||
const proxyEndpoint = process.env.PROXY_ENDPOINT || 'public/index.html';
|
||||
|
||||
const mainWindow = new BrowserWindow({
|
||||
width,
|
||||
height,
|
||||
webPreferences: {
|
||||
nodeIntegration: false,
|
||||
contextIsolation: true,
|
||||
},
|
||||
title: appTitle
|
||||
});
|
||||
|
||||
mainWindow.webContents.loadURL(proxyEndpoint);
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow();
|
||||
|
||||
app.on('activate', () => {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow();
|
||||
});
|
||||
});
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') app.quit();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user