Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/node_modules/
/public/
/unshared/
/dist/

/android/build/
/android/gradle/
Expand Down
58 changes: 58 additions & 0 deletions electron/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const { app, BrowserWindow } = require('electron');
const path = require('path');
const url = require('url');

// Keep a global reference of the window object to avoid
// the window being closed automatically when the JavaScript object is garbage collected
let mainWindow;

function createWindow() {
// Create the browser window
mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: false,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
},
icon: path.join(__dirname, '../src/assets/icons/icon.png')
});

// Load the app
const startUrl = process.env.ELECTRON_START_URL || url.format({
pathname: path.join(__dirname, '../public/index.html'),
protocol: 'file:',
slashes: true
});

mainWindow.loadURL(startUrl);

// Open the DevTools in development mode
if (process.env.NODE_ENV === 'development') {
mainWindow.webContents.openDevTools();
}

// Emitted when the window is closed
mainWindow.on('closed', function () {
// Dereference the window object
mainWindow = null;
});
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows
app.whenReady().then(createWindow);

// Quit when all windows are closed
app.on('window-all-closed', function () {
// On macOS it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') app.quit();
});

app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open
if (mainWindow === null) createWindow();
});
7 changes: 7 additions & 0 deletions electron/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// All of the Node.js APIs are available in the preload process.
// It has the same sandbox as a Chrome extension.
window.addEventListener('DOMContentLoaded', () => {
// You can add any initialization code here that should run
// before your app's content is loaded
console.log('Electron preload script loaded');
});
Loading