mirror of https://github.com/TriliumNext/Notes
electron prototype
parent
0a793d0c47
commit
83243dd936
@ -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');
|
||||||
@ -1,3 +0,0 @@
|
|||||||
<h1><%= message %></h1>
|
|
||||||
<h2><%= error.status %></h2>
|
|
||||||
<pre><%= error.stack %></pre>
|
|
||||||
Loading…
Reference in New Issue