mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 03:16:11 +01:00
electron prototype
This commit is contained in:
54
index.js
Normal file
54
index.js
Normal file
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
const electron = require('electron');
|
||||
|
||||
const app = electron.app;
|
||||
|
||||
// Adds debug features like hotkeys for triggering dev tools and reload
|
||||
require('electron-debug')();
|
||||
|
||||
// Prevent window being garbage collected
|
||||
let mainWindow;
|
||||
|
||||
function onClosed() {
|
||||
// Dereference the window
|
||||
// For multiple windows store them in an array
|
||||
mainWindow = null;
|
||||
}
|
||||
|
||||
function createMainWindow() {
|
||||
const win = new electron.BrowserWindow({
|
||||
width: 1200,
|
||||
height: 900
|
||||
});
|
||||
|
||||
win.setMenu(null);
|
||||
win.loadURL('http://localhost:3000');
|
||||
win.on('closed', onClosed);
|
||||
|
||||
win.webContents.on('new-window', (e, url) => {
|
||||
if (url !== mainWindow.webContents.getURL()) {
|
||||
e.preventDefault();
|
||||
require('electron').shell.openExternal(url);
|
||||
}
|
||||
});
|
||||
|
||||
return win;
|
||||
}
|
||||
|
||||
app.on('window-all-closed', () => {
|
||||
if (process.platform !== 'darwin') {
|
||||
app.quit();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('activate', () => {
|
||||
if (!mainWindow) {
|
||||
mainWindow = createMainWindow();
|
||||
}
|
||||
});
|
||||
|
||||
app.on('ready', () => {
|
||||
mainWindow = createMainWindow();
|
||||
});
|
||||
|
||||
require('./bin/www');
|
||||
Reference in New Issue
Block a user