-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
132 lines (118 loc) · 2.8 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
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
124
125
126
127
128
129
130
131
132
'use strict'
const app = require('electron').app
const path = app.getAppPath()
const BrowserWindow = require('electron').BrowserWindow
const Menu = require('electron').Menu
const ipcMain = require('electron').ipcMain
const abema = require('./renderer/util/abema')
const cheerio = require('./renderer/util/cheerio')
const file = require('./renderer/util/file')
const nasne = require('./renderer/util/nasne')
let mainWindow = null
app.on('window-all-closed', () => {
app.quit()
})
app.on('ready', () => {
mainWindow = new BrowserWindow({ width: 1100, height: 1000, minWidth: 410 })
mainWindow.loadURL(`file://${__dirname}/renderer/app.html`)
mainWindow.on('closed', () => {
mainWindow = null
})
})
app.once('ready', () => {
const template = [
{
label: 'Application',
submenu: [{
type: 'separator'
},
{
label: 'About TV-kko',
click: showAbout
}]
},
{
label: 'Edit',
submenu: [{
type: 'separator'
},
{
label: 'Cut',
accelerator: 'CmdOrCtrl+X',
role: 'cut'
},
{
label: 'Copy',
accelerator: 'CmdOrCtrl+C',
role: 'copy'
},
{
label: 'Paste',
accelerator: 'CmdOrCtrl+V',
role: 'paste'
},
{
label: 'Select All',
accelerator: 'CmdOrCtrl+A',
role: 'selectall'
}]
},
{
label: 'View',
submenu: [{
label: 'Reload',
accelerator: 'CmdOrCtrl+R',
click(item, focusedWindow) {
if (focusedWindow) focusedWindow.reload()
}
}]
},
{
label: 'Window',
role: 'window',
submenu: [{
label: 'Minimize',
accelerator: 'CmdOrCtrl+M',
role: 'minimize'
},
{
label: 'Close',
accelerator: 'CmdOrCtrl+W',
role: 'close'
}]
}]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
})
ipcMain.on('async-downloadCastsFile', (event) => {
file.downloadCastsFile(event, path)
})
ipcMain.on('async-checkForUpdates', (event) => {
file.checkForUpdates(event)
})
ipcMain.on('async-fetchImage', (event, args) => {
cheerio.fetchImage(event, args.name, args.imgDir)
})
ipcMain.on('async-fetchProgramList', (event, args) => {
if (args.platformId === 'Abema') {
abema.fetchProgramList(event, args.name, args.index)
} else {
cheerio.fetchProgramList(event, args.area, args.name, args.platformId, args.index)
}
})
ipcMain.on('async-fetchReservedList', (event, args) => {
nasne.fetchReservedList(event, args.ip)
})
function showAbout() {
const aboutWindow = new BrowserWindow({
width: 275,
minWidth: 275,
maxWidth: 275,
height: 160,
minHeight: 160,
maxHeight: 160,
parent: mainWindow
})
let currentVersion = require('./package.json').version
aboutWindow.loadURL(`file://${__dirname}/renderer/about.html#${currentVersion}`)
}