-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
67 lines (56 loc) · 1.67 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
'use strict'
const electron = require('electron')
const app = electron.app
const globalShortcut = electron.globalShortcut
const os = require('os')
const path = require('path')
const pack = require(path.join(__dirname, 'package.json'))
const BrowserWindow = electron.BrowserWindow
const electronData = require('electron-data')
app.setName(pack.productName)
var mainWindow = null
electronData.config({
autosave: true,
prettysave: true
})
if (!electronData.has('config')) {
electronData.set('config', require('config.json'))
}
app.on('ready', function () {
mainWindow = new BrowserWindow({
backgroundColor: 'lightgray',
icon: path.join(__dirname, '/app/images/favicon.ico'),
title: pack.productName,
titleBarStyle: 'hidden',
frame: false,
show: false,
webPreferences: {
nodeIntegration: true,
defaultEncoding: 'UTF-8'
}
})
mainWindow.loadURL(`file://${__dirname}/app/index.html`)
// Enable keyboard shortcuts for Developer Tools on various platforms.
let platform = os.platform()
if (platform === 'darwin') {
globalShortcut.register('Command+Option+I', () => {
mainWindow.webContents.openDevTools()
})
} else if (platform === 'linux' || platform === 'win32') {
globalShortcut.register('Control+Shift+I', () => {
mainWindow.webContents.openDevTools()
})
}
mainWindow.once('ready-to-show', () => {
mainWindow.setMenu(null)
mainWindow.show()
})
mainWindow.onbeforeunload = (e) => {
// Prevent Command-R from unloading the window contents.
e.returnValue = false
}
mainWindow.on('closed', function () {
mainWindow = null
})
})
app.on('window-all-closed', () => { app.quit() })