-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
123 lines (94 loc) · 2.82 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
const { app, ipcMain, BrowserWindow, Menu, MenuItem } = require('electron');
const exec = require('child_process').exec;
const fs = require('fs');
const isSingleInstanceLocked = app.requestSingleInstanceLock()
const { RESOURCES } = require('./modules/constants');
const { SettingsWindow, AppWindow } = require('./modules/windows');
const { reset, restart } = require('./modules/application');
const wallpaper = require('./modules/wallpaper');
const store = require('./modules/store').get();
let WindowList = require('./modules/windows/WindowList');
let tray = require('./modules/tray');
if(!isSingleInstanceLocked) {
app.quit();
} else {
if(!fs.existsSync(RESOURCES.API)) {
fs.copyFileSync('./api.js', RESOURCES.API);
}
if(!store.get('experimental')) {
const menu = new Menu();
menu.append(new MenuItem({
label: 'Reset',
submenu: [ {
role: 'help',
accelerator: process.platform === 'darwin' ? 'Ctrl+Cmd+R' : 'Ctrl+Shift+R',
click: reset
} ]
}));
Menu.setApplicationMenu(menu);
}
ipcMain.on('token', (channel, token) => {
store.set('token', token || '');
if(WindowList.TokenWindow ? !WindowList.TokenWindow.closed : false) {
WindowList.TokenWindow.close();
}
});
ipcMain.on('open-api-file', () => {
let cl;
switch(process.platform) {
case 'darwin':
cl = 'open';
break;
case 'win32' || 'win64':
cl = 'start';
break;
default:
cl = 'xdg-open';
}
exec(`${ cl } ${ RESOURCES.API }`);
});
ipcMain.on('item', (channel, item) => {
store.set('item', item || '');
});
ipcMain.on('update', () => {
wallpaper.update();
});
ipcMain.on('settings', () => {
SettingsWindow();
});
ipcMain.on('circle', () => {
wallpaper.circle();
});
ipcMain.on('reset', () => {
reset();
});
ipcMain.on('restart', () => {
restart();
});
ipcMain.on('quit', () => {
app.quit();
});
app.on('ready', () => {
tray();
AppWindow();
app.on('activate', () => {
if(BrowserWindow.getAllWindows().length === 0) {
AppWindow();
}
});
});
app.on('window-all-closed', e => e.preventDefault());
wallpaper.circle();
fs.watchFile(RESOURCES.API, {
interval: 1000
}, () => {
restart();
});
app.on('second-instance', () => {
if(!!WindowList.AppWindow) {
if(WindowList.AppWindow.isMinimized()) WindowList.AppWindow.restore();
WindowList.AppWindow.focus()
}
});
}
require('./modules/autolaunch')();