This repository has been archived by the owner on Jan 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.js
88 lines (73 loc) · 1.85 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
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
const path = require('path')
const fs = require('fs')
const electron = require('electron')
const ipc = electron.ipcMain
const app = electron.app
const BrowserWindow = electron.BrowserWindow
const client = require('electron-connect').client
require('electron-debug')();
require('electron-dl')();
let mainWindow
const devel = process.env.NODE_ENV === "development"
function updateBadge(title){
if (!app.dock) {
return;
}
app.dock.setBadge(title);
}
function createWindow(){
mainWindow = new BrowserWindow({
show: false,
width: 1260,
width: devel ? 1260 : 560,
minWidth: 460,
maxWidth: devel ? 1260 : 560,
height: 550,
maxHeight: 550,
minHeight: 550,
titleBarStyle: 'hidden-inset',
webPreferences : {
devTools: devel,
nodeIntegration: false,
webSecurity: false,
allowDisplayingInsecureContent: true,
preload: path.join(__dirname, 'browser.js'),
blinkFeatures: "CSSBackdropFilter"
}
});
mainWindow.loadURL('https://overcast.fm/login')
if (devel){
mainWindow.webContents.openDevTools()
}
mainWindow.on('closed', () => {
mainWindow = null
})
const page = mainWindow.webContents
page.on('dom-ready', () => {
page.insertCSS(fs.readFileSync(path.join(__dirname, 'dist/browser.css'), 'utf8'))
})
// this is causing errors when starting with `electron main.js`
// client.create(mainWindow, function(){
// console.log('electron-connect client created')
// })
mainWindow.once('ready-to-show', () => {
mainWindow.show()
})
}
app.on('ready', createWindow)
app.on('window-all-closed', () => {
if (process.platform !== 'darwin'){
app.quit()
}
})
app.on('activate', () => {
if (mainWindow === null){
createWindow()
}
})
ipc.on('update-badge', (event, data) => {
let count = data.count
if (count){
updateBadge(count.toString())
}
})