-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
57 lines (46 loc) · 1.42 KB
/
main.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
const { app, BrowserWindow, ipcMain, Menu } = require('electron')
const { autoUpdater } = require('electron-updater')
const fs = require('fs')
const path = require('path')
const createMainWindow = () => {
const mainWindow = new BrowserWindow({
webPreferences: {
nodeIntegration: true
}
})
mainWindow.loadFile('index.html')
// mainWindow.webContents.openDevTools()
Menu.setApplicationMenu(null)
ipcMain.on('redirect', (e, url) => {
createMeetingWindow(url)
})
ipcMain.on('save-meetings', (e, meetings) => {
const data = JSON.stringify(meetings)
fs.writeFile(path.join(app.getPath('userData'), 'data.json'), data, (e) => { if (e) { console.error(e) } })
})
ipcMain.on('ready', (e) => {
let data = '[]'
try {
data = fs.readFileSync(path.join(app.getPath('userData'), 'data.json'))
} catch (e) {
console.log(e)
}
e.reply('meetings-list', JSON.parse(data))
})
autoUpdater.checkForUpdatesAndNotify()
}
const createMeetingWindow = (url) => {
const meetingWindow = new BrowserWindow()
meetingWindow.loadURL(url)
}
app.whenReady().then(createMainWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createMainWindow()
}
})