-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
89 lines (74 loc) · 2.29 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
'use strict';
import electron from 'electron';
import api from './main_process/Api'
import { autoUpdater } from 'electron-updater'
import log from 'electron-log'
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
log.info('Starting SNSKRT DICT');
const app = electron.app;
const browserWindow = electron.BrowserWindow;
const menu = electron.Menu;
api.listen(electron.ipcMain);
let win;
function createWindow() {
win = new browserWindow({width: 600, height: 800});
win.loadURL(`file://${__dirname}/assets_build/index.html`);
win.on('closed', function () {
win = null;
});
menu.setApplicationMenu(menu.buildFromTemplate(createMenu()));
}
function changeStatus(text) {
log.info(text);
win.webContents.send('message', text);
}
function createMenu() {
const editMenu = {
label: 'Edit',
submenu: [
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
{ label: 'Select All', accelerator: 'CmdOrCtrl+A', selector: 'selectAll:' }
]
};
const appMenu = {
label: 'Application',
submenu: [ ]
};
if (process.platform === 'darwin') {
appMenu.submenu.push({ label: 'About Application', selector: 'orderFrontStandardAboutPanel:' });
appMenu.submenu.push({ type: 'separator' });
}
appMenu.submenu.push({ label: 'Quit', accelerator: 'Command+Q', click: function() { app.quit(); } });
return [ appMenu, editMenu ];
}
app.on('ready', createWindow);
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
});
app.on('activate', function () {
if (win === null) {
createWindow()
}
});
autoUpdater.on('checking-for-update', () => {
changeStatus('Checking for update...');
});
autoUpdater.on('update-available', () => {
changeStatus('Update available.');
});
autoUpdater.on('download-progress', () => {
changeStatus('Download update...');
});
autoUpdater.on('update-downloaded', () => {
changeStatus('Update downloaded; will install in 5 seconds');
setTimeout(function() {
autoUpdater.quitAndInstall();
}, 5000)
});
app.on('ready', function() {
autoUpdater.checkForUpdates();
});