- Electron Projects
- Denys Vuika
- 251字
- 2021-06-24 12:14:37
Configuring the application name in the menu
You may have already noticed the Electron label in the main application menu. This has happened because we launched a generic Electron shell to run and test our application with the npm start command. As you may recall, we defined the start command like so:
{
"name": "markdown-editor",
"version": "1.1.0",
"main": "index.js",
"scripts": {
"start": "electron ."
},
"devDependencies": {
"electron": "^7.0.0",
"electron-builder": "^21.2.0"
},
"dependencies": {
"simplemde": "^1.11.2"
}
}
But when you package the application for distribution, it is going to have its own version of Electron embedded in it. In that case, the name of your application renders as expected.
Let's test the package with the macOS build:
- Append the build:macos command to the scripts section of the package.json file:
{
"scripts": {
"start": "electron .",
"build:macos": "electron-builder --macos --dir"
}
}
- Now, execute the npm run build:macos command in the Terminal to create a quick package for local development and testing.
- Next, go to the dist/mac folder and run the markdown-editor application by double-clicking on its icon:

Note that the application menu now shows the correct value. Here, the application is called markdown-editor.
- The code in the menu.js file now takes the following values from the package.json settings:
{
"name": "markdown-editor",
"version": "1.0.0"
}
The same behavior applies to the application version. When you run your project in testing mode, the About box will show the Electron framework version. For the packaged application, however, you should see the correct value.
推薦閱讀
- 精通JavaScript+jQuery:100%動態網頁設計密碼
- Unity Virtual Reality Projects
- SEO實戰密碼
- 深入淺出RxJS
- JavaScript入門經典
- PHP從入門到精通(第4版)(軟件開發視頻大講堂)
- Mastering C++ Multithreading
- 軟件測試綜合技術
- SwiftUI極簡開發
- Web程序設計:ASP.NET(第2版)
- 軟硬件綜合系統軟件需求建模及可靠性綜合試驗、分析、評價技術
- Python滲透測試編程技術:方法與實踐(第2版)
- Ubuntu Server Cookbook
- Learning Dynamics NAV Patterns
- Oracle Database 12c DBA官方手冊(第8版)