mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
electron prototype
This commit is contained in:
parent
0a793d0c47
commit
83243dd936
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');
|
22
package.json
22
package.json
@ -3,13 +3,17 @@
|
|||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node ./bin/www"
|
"start": "node ./bin/www",
|
||||||
|
"test-electron": "xo",
|
||||||
|
"start-electron": "electron .",
|
||||||
|
"build-electron": "electron-packager . --out=dist --asar --overwrite --all"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"body-parser": "~1.18.2",
|
"body-parser": "~1.18.2",
|
||||||
"cookie-parser": "~1.4.3",
|
"cookie-parser": "~1.4.3",
|
||||||
"debug": "~3.1.0",
|
"debug": "~3.1.0",
|
||||||
"ejs": "~2.5.7",
|
"ejs": "~2.5.7",
|
||||||
|
"electron": "^1.7.9",
|
||||||
"express": "~4.16.2",
|
"express": "~4.16.2",
|
||||||
"express-session": "^1.15.6",
|
"express-session": "^1.15.6",
|
||||||
"express-sessions": "^1.0.6",
|
"express-sessions": "^1.0.6",
|
||||||
@ -20,6 +24,20 @@
|
|||||||
"scrypt": "^6.0.3",
|
"scrypt": "^6.0.3",
|
||||||
"serve-favicon": "~2.4.5",
|
"serve-favicon": "~2.4.5",
|
||||||
"session-file-store": "^1.1.2",
|
"session-file-store": "^1.1.2",
|
||||||
"sqlite": "^2.8.0"
|
"sqlite": "^2.8.0",
|
||||||
|
"electron-debug": "^1.0.0",
|
||||||
|
"electron-rebuild": "^1.6.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"devtron": "^1.1.0",
|
||||||
|
"electron-packager": "^8.0.0",
|
||||||
|
"electron": "^1.6.6",
|
||||||
|
"xo": "^0.18.0"
|
||||||
|
},
|
||||||
|
"xo": {
|
||||||
|
"envs": [
|
||||||
|
"node",
|
||||||
|
"browser"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,4 +80,8 @@ $(document).tooltip({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function isElectron() {
|
||||||
|
return window && window.process && window.process.type;
|
||||||
|
}
|
@ -1,3 +0,0 @@
|
|||||||
<h1><%= message %></h1>
|
|
||||||
<h2><%= error.status %></h2>
|
|
||||||
<pre><%= error.stack %></pre>
|
|
@ -217,6 +217,9 @@
|
|||||||
const baseApiUrl = 'api/';
|
const baseApiUrl = 'api/';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!-- Required for correct loading of scripts in Electron -->
|
||||||
|
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
|
||||||
|
|
||||||
<script src="libraries/jquery.min.js"></script>
|
<script src="libraries/jquery.min.js"></script>
|
||||||
|
|
||||||
<!-- bootstrap needs to be included before jQuery UI, otherwise close icon in the dialog will be missing -->
|
<!-- bootstrap needs to be included before jQuery UI, otherwise close icon in the dialog will be missing -->
|
||||||
|
@ -43,7 +43,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Required for correct loading of scripts in Electron -->
|
||||||
|
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
|
||||||
|
|
||||||
<link href="libraries/bootstrap/css/bootstrap.css" rel="stylesheet">
|
<link href="libraries/bootstrap/css/bootstrap.css" rel="stylesheet">
|
||||||
<script src="libraries/bootstrap/js/bootstrap.js"></script>
|
<script src="libraries/bootstrap/js/bootstrap.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
@ -47,6 +47,9 @@
|
|||||||
const baseApiUrl = 'api/';
|
const baseApiUrl = 'api/';
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<!-- Required for correct loading of scripts in Electron -->
|
||||||
|
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
|
||||||
|
|
||||||
<script src="stat/lib/jquery.min.js"></script>
|
<script src="stat/lib/jquery.min.js"></script>
|
||||||
|
|
||||||
<link href="stat/lib/bootstrap/css/bootstrap.css" rel="stylesheet">
|
<link href="stat/lib/bootstrap/css/bootstrap.css" rel="stylesheet">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user