为什么 "about" 菜单中显示的应用名称与应用名称不同? (电子,MacOS)?

Why is the app name displayed in "about" Menu different than App name? (Electron, MacOS)?

我正在使用 electron-forge,我的应用构建、捆绑和 运行 都很好,所以我处于自定义和完善状态(设置应用图标、名称等)。

我能够设置 .app 包名称,并且名称显示在顶级菜单中,但由于某种原因,package.json name 字段仍在应用于两个领域(见下图)。我打开应用程序包查看 Info.plist,但没有看到 'omni-desktop-test' 的任何实例。

我缺少什么设置来定位这些值?

我的 forge 配置的相关部分:

packagerConfig: {
    name: 'Keystone Omni',
    productName: 'Keystone Omni',
    executableName: 'Keystone Omni Desktop',
    icon: 'assets/app.icns',
    appBundleId: 'com.xxxxxxx.omni',
    appCategoryType: 'public.app-category.developer-tools',
    extendInfo: 'static/info.plist',
}

在您的电子 Main.js 文件中,使用 app.setName 更改您的应用名称:

app.setName('Keystone Omni');

在测试并尝试向 electron-forge 报告错误时,我发现了以下内容:

  1. 这里提到的productNamehttps://electron.github.io/electron-packager/master/interfaces/electronpackager.options.html#name是要在package.json文件中,而不是在electron-packager配置中。我以前没有在 package.json 中看到 'productName' 作为值。

The application name. If omitted, it will use the 'productName' or 'name' value from the nearest package.json.

  1. 即使您在 electron-packager 配置中设置 'name',它仍然会读取 package.json 'productName' 值(或 'name' 值,如果未定义),用于问题区域中的文本。

所以答案是,如果你想在捆绑器级别设置这个:

Use 'name' in the packager config to set the top-level display name, and 'productName' (or 'name' as a fallback) in the package.json to set the sub-menu about, hide, quit, etc items.