我有一个Electron应用程序,我正在为Mac制作Windows安装程序。通过与Electron的松鼠事件创建桌面快捷方式
现在我有一个/ installers目录和一个setupEvents.js文件来处理所有的Squirrel事件。大部分是从Windows installer documentation:
import { app } from 'electron';
module.exports = {
handleSquirrelEvent: function() {
if (process.argv.length === 1) {
return false;
}
const ChildProcess = require('child_process');
const path = require('path');
const appFolder = path.resolve(process.execPath, '..');
const rootAtomFolder = path.resolve(appFolder, '..');
const updateDotExe = path.resolve(path.join(rootAtomFolder, 'Update.exe'));
const exeName = path.basename(process.execPath);
const spawn = function(command, args) {
let spawnedProcess, error;
try {
spawnedProcess = ChildProcess.spawn(command, args, {detached: true});
} catch (error) {}
return spawnedProcess;
};
const spawnUpdate = function(args) {
return spawn(updateDotExe, args);
};
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;
}
}
}
到目前为止,这正常工作,不同之处在于添加到桌面的标题为“电子”的快捷方式图标,我不知道如何更改。我的package.json中有一个名称,产品名称:
{
"name": "my app",
"description": "my app description",
"productName": "my app",
"appCopyright": "me",
"appCategoryType": "Productivity",
...
而且我安装的配置是这样的:
{
appDirectory: path.join(outPath, 'myapp-win32-ia32/'),
authors: 'me',
noMsi: true,
outputDirectory: path.join(outPath, 'windows-installer'),
exe: 'myapp.exe',
setupExe: 'myappInstaller.exe',
setupIcon: path.join(rootPath, 'assets', 'win', 'icon.ico'),
skipUpdateIcon: true
}
我不知道在哪里可以告诉安装程序的快捷方式图标应该有我的应用程序的名称,而不是“电子”。
在此先感谢!
这个工作!谢谢!! –
它现在变成'win32metadata' –