forked from CityOfZion/neon-wallet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
112 lines (103 loc) · 2.97 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
const { app, shell, Menu, BrowserWindow } = require('electron')
const path = require('path')
const url = require('url')
const port = process.env.PORT || 3000
let mainWindow = null
// adapted from https://github.com/chentsulin/electron-react-boilerplate
const installExtensions = () => {
const installer = require('electron-devtools-installer')
const extensions = [
'REACT_DEVELOPER_TOOLS',
'REDUX_DEVTOOLS'
]
return Promise
.all(extensions.map(name => installer.default(installer[name])))
.catch(console.log)
}
app.on('window-all-closed', () => {
app.quit()
})
app.on('ready', () => {
const onAppReady = () => {
mainWindow = new BrowserWindow({
height: 750,
width: 1000,
minHeight: 750,
minWidth: 1000,
icon: path.join(__dirname, 'icons/png/64x64.png'),
webPreferences: {
webSecurity: false
}
})
if (process.env.NODE_ENV === 'development') {
mainWindow.webContents.openDevTools()
}
if (process.platform !== 'darwin') {
// Windows/Linxu Menu
mainWindow.setMenu(null)
} else {
// Menu is required for MacOS
const template = [
{
label: app.getName(),
submenu: [
{ role: 'about' },
{ type: 'separator' },
{ role: 'quit' }
]
},
{
label: 'Edit',
submenu: [
{ role: 'undo' },
{ role: 'redo' },
{ type: 'separator' },
{ role: 'cut' },
{ role: 'copy' },
{ role: 'paste' }
]
},
{
label: 'View',
submenu: [
{role: 'toggledevtools'}
]
},
{
role: 'help',
submenu: [
{ label: 'City of Zion', click () { shell.openExternal('https://cityofzion.io/') } },
{ label: 'GitHub', click () { shell.openExternal('https://github.com/CityOfZion') } },
{ label: 'NEO Reddit', click () { shell.openExternal('https://www.reddit.com/r/NEO/') } },
{ label: 'Slack', click () { shell.openExternal('https://neosmarteconomy.slack.com') } }
]
}
]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
}
const inputMenu = Menu.buildFromTemplate([
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', click () { mainWindow.webContents.paste() } }
])
mainWindow.webContents.on('context-menu', (event, params) => {
inputMenu.popup(mainWindow)
})
if (process.env.START_HOT) {
mainWindow.loadURL(`http://localhost:${port}/dist`)
} else {
mainWindow.loadURL(url.format({
protocol: 'file',
slashes: true,
pathname: path.join(__dirname, '/app/dist/index.html')
}))
}
mainWindow.on('closed', function () {
mainWindow = null
})
}
if (process.env.NODE_ENV === 'development') {
installExtensions().then(() => onAppReady())
} else {
onAppReady()
}
})