trilium/index.js

57 lines
1.2 KiB
JavaScript
Raw Normal View History

2017-10-21 11:43:20 +08:00
'use strict';
const electron = require('electron');
2017-10-21 12:19:13 +08:00
const path = require('path');
2017-10-21 11:43:20 +08:00
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,
2017-10-21 12:19:13 +08:00
height: 900,
icon: path.join(__dirname, 'public/images/app-icons/png/256x256.png')
2017-10-21 11:43:20 +08:00
});
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');