// 放在最上面 if (handleSquirrelEvent()) { // squirrel event handled and app will exit in 1000ms, so don't do anything else } else { // createWindow... }
functionhandleSquirrelEvent() { if (process.argv.length === 1) { returnfalse; }
const squirrelEvent = process.argv[1]; switch (squirrelEvent) { case"--squirrel-install": case"--squirrel-updated": // Optionally do things such as: // - Add your .exe to the PATH // - Write to the registry for things like file associations and // explorer context menus
setTimeout(app.exit, 1000); returntrue;
case"--squirrel-uninstall": // Undo anything you did in the --squirrel-install and // --squirrel-updated handlers
setTimeout(app.exit, 1000); returntrue;
case"--squirrel-obsolete": // This is called on the outgoing version of your app before // we update to the new version - it's the opposite of // --squirrel-updated