Uses https://npmjs.com/package/electron-localshortcut to workaround a bug in Electron (https://github.com/atom/electron/issues/1334). We can remove `electron-localshortcut` once that bug is fixed.
42 lines
790 B
JavaScript
42 lines
790 B
JavaScript
var startTime = Date.now()
|
|
|
|
var electron = require('electron')
|
|
var ipc = require('./ipc')
|
|
var menu = require('./menu')
|
|
var windows = require('./windows')
|
|
var shortcuts = require('./shortcuts')
|
|
|
|
var app = electron.app
|
|
|
|
app.startTime = startTime
|
|
|
|
app.on('open-file', onOpen)
|
|
app.on('open-url', onOpen)
|
|
|
|
app.on('ready', function () {
|
|
electron.Menu.setApplicationMenu(menu.appMenu)
|
|
windows.createMainWindow(menu)
|
|
shortcuts.init(menu)
|
|
})
|
|
|
|
app.on('activate', function () {
|
|
if (windows.main) {
|
|
windows.main.show()
|
|
} else {
|
|
windows.createMainWindow(menu)
|
|
}
|
|
})
|
|
|
|
app.on('window-all-closed', function () {
|
|
if (process.platform !== 'darwin') {
|
|
app.quit()
|
|
}
|
|
})
|
|
|
|
ipc.init()
|
|
|
|
function onOpen (e, torrentId) {
|
|
e.preventDefault()
|
|
windows.main.send('addTorrent', torrentId)
|
|
}
|