This repository has been archived by the owner on Dec 7, 2019. It is now read-only.
/
index.js
69 lines (58 loc) · 1.41 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
const {
app, BrowserWindow, globalShortcut, Menu, Tray,
} = require('electron');
let mainWindow = null;
global.status = { speaking: false };
app.on('ready', () => {
mainWindow = new BrowserWindow({
width: 800,
height: 500,
show: false,
});
let on = 'idle';
mainWindow.on('close', (event) => {
if (mainWindow.forceClose) return;
event.preventDefault();
mainWindow.hide();
});
const tray = new Tray(`${__dirname}/app/img/temp.png`);
const contextMenu = Menu.buildFromTemplate([
{
label: 'Show Pardal',
click() {
mainWindow.show();
},
},
{
label: 'Quit',
role: 'quit',
},
]);
tray.setContextMenu(contextMenu);
// timeline
globalShortcut.register('CmdOrCtrl+Shift+Down', () => {
on = 'timeline';
mainWindow.send('read-tweets-down');
});
globalShortcut.register('CmdOrCtrl+Shift+Up', () => {
on = 'timeline';
mainWindow.send('read-tweets-up');
});
// settings
globalShortcut.register('CmdOrCtrl+Alt+S', () => {
on = 'settings';
mainWindow.show();
});
globalShortcut.register('CmdOrCtrl+Alt+T', () => {
if (on === 'settings') {
mainWindow.send('settings-create-template');
}
});
mainWindow.loadURL(`file://${__dirname}/app/index.html`);
});
app.on('before-quit', () => {
mainWindow.forceClose = true;
});
app.on('activate-with-no-open-windows', () => {
mainWindow.show();
});