我正在创建一个Electron应用程序,并使用electron-winstaller来构建使用squirrel.windows的安装程序。 其中一个示例代码片段包含以下部分:
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
// Install desktop and start menu shortcuts
spawnUpdate(['--createShortcut', exeName]);
setTimeout(app.quit, 1000);
return true;
case '--squirrel-uninstall':
// Undo anything you did in the --squirrel-install and
// --squirrel-updated handlers
// Remove desktop and start menu shortcuts
spawnUpdate(['--removeShortcut', exeName]);
setTimeout(app.quit, 1000);
return true;
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
app.quit();
return true;
}
}
在上面的部分中,显示"- 写入注册表以获取文件关联和资源管理器上下文菜单等内容。 我想在这里添加注册表项,但是在查看松鼠文档时,我不知道该怎么做。我在网上找不到任何例子。 有人有什么想法吗?
Squirrel 不会公开更改注册表的命令,因此您必须编写自己的命令。这个 CoffeeScript 中spawnReg
一个例子:https://gist.github.com/Hrxn/7f415e5e32abb83eff27