任务栏的进度条 (Windows, macOS, Unity)
On Windows, you can use a taskbar button to display a progress bar.
On macOS, the progress bar will be displayed as a part of the dock icon.
All three cases are covered by the same API - the method available on an instance of BrowserWindow
. To indicate your progress, call this method with a number between 0
and . For example, if you have a long-running task that is currently at 63% towards completion, you would call it as setProgressBar(0.63)
.
Setting the parameter to negative values (e.g. -1
) will remove the progress bar, whereas setting it to values greater than (e.g. 2
) will switch the progress bar to indeterminate mode (Windows-only — it will clamp to 100% otherwise). In this mode, a progress bar remains active but does not show an actual percentage. Use this mode for situations when you do not know how long an operation will take to complete.
从起 Quick Start Guide 示例的应用程序开始,将以下行添加到 main.js
文件:
After launching the Electron application, you should see the bar in the dock (macOS) or taskbar (Windows, Unity), indicating the progress percentage you just defined.
For macOS, the progress bar will also be indicated for your application when using :