Windows: create desktop/start menu shortcuts on install/update

This commit is contained in:
Feross Aboukhadijeh
2016-03-25 01:39:44 -07:00
parent 6f9121ac12
commit aa9310eb15
3 changed files with 30 additions and 22 deletions

View File

@@ -16,10 +16,9 @@ var shouldQuit = false
var argv = sliceArgv(process.argv) var argv = sliceArgv(process.argv)
if (process.platform === 'win32') { if (process.platform === 'win32') {
shouldQuit = squirrelWin32.handleArgv(argv[0]) shouldQuit = squirrelWin32.handleEvent(argv[0])
argv.shift() // Remove any --squirrel-xxxx arguments
// Remove any --squirrel-xxxx arguments // app.setAppUserModelId('com.squirrel.WebTorrent.WebTorrent')
argv.shift()
} }
if (!shouldQuit) { if (!shouldQuit) {

View File

@@ -1,34 +1,33 @@
module.exports = { module.exports = {
handleArgv handleEvent
} }
var cp = require('child_process')
var electron = require('electron') var electron = require('electron')
var path = require('path')
var app = electron.app var app = electron.app
var config = require('../config')
var handlers = require('./handlers') var handlers = require('./handlers')
function handleArgv (cmd) { function handleEvent (cmd) {
if (cmd === '--squirrel-install') { if (cmd === '--squirrel-install' || cmd === '--squirrel-updated') {
// App was just installed. // App was installed/updated. (Called on new version of app.)
handlers.init()
// TODO: // Install protocol/file handlers, desktop/start menu shortcuts.
// - Install desktop and start menu shortcuts handlers.init()
// - Add explorer context menus createShortcuts()
// Ensure user sees install splash screen so they realize that Setup.exe actually // Ensure user sees install splash screen so they realize that Setup.exe actually
// installed an application and isn't the application itself. // installed an application and isn't the application itself.
setTimeout(function () { if (cmd === '--squirrel-install') {
setTimeout(function () {
app.quit()
}, 5000)
} else {
app.quit() app.quit()
}, 5000) }
return true
}
if (cmd === '--squirrel-updated') {
// App was just updated. (Called on new version of app.)
handlers.init()
app.quit()
return true return true
} }
@@ -54,3 +53,13 @@ function handleArgv (cmd) {
return false return false
} }
function createShortcuts () {
var updateExe = path.join(process.execPath, '..', 'Update.exe')
var args = [
'--createShortcut="' + config.APP_NAME + '.exe"',
'--shortcut-locations="Desktop,StartMenu,Startup"',
'--process-start-args="--autostart"'
]
cp.execSync(updateExe + args.join(' '))
}

View File

@@ -1,5 +1,5 @@
{ {
"name": "webtorrent-app", "name": "WebTorrent",
"description": "WebTorrent, the streaming torrent client. For OS X, Windows, and Linux.", "description": "WebTorrent, the streaming torrent client. For OS X, Windows, and Linux.",
"version": "0.0.1", "version": "0.0.1",
"author": { "author": {