电子 - 上端的进度事件
Electron-Updater QuitandInstall()方法是否会启动安装进度事件?
我的客户在安装更新时要求一个进度栏,但我在文档中没有看到任何内容。
注意:我不是指更新下载进度(我已经有效)。
这是我的代码:
const { autoUpdater } = require("electron-updater");
const updater = (mainWindow) => {
autoUpdater.checkForUpdates();
autoUpdater.on("update-available", (data) => {
mainWindow.webContents.send("update-available", data);
});
ipcMain.handle("download-update", (event) => {
autoUpdater.downloadUpdate();
});
autoUpdater.on("download-progress", (data) => {
logger.info(data);
mainWindow.webContents.send("download-progress", data.percent);
});
autoUpdater.on("update-downloaded", (data) => {
mainWindow.webContents.send("update-downloaded", data);
});
ipcMain.handle("install-and-restart", () => {
// I'm looking for an installation progress event after I called this method.
autoUpdater.quitAndInstall(false, true);
});
};
Does electron-updater quitAndInstall() method emmit an installation progress event?
My client is asking for a progress bar while the update is installing but I don't see anything in the docs.
Note: I'm not referring to the update download progress (I already have that working).
Here is my code:
const { autoUpdater } = require("electron-updater");
const updater = (mainWindow) => {
autoUpdater.checkForUpdates();
autoUpdater.on("update-available", (data) => {
mainWindow.webContents.send("update-available", data);
});
ipcMain.handle("download-update", (event) => {
autoUpdater.downloadUpdate();
});
autoUpdater.on("download-progress", (data) => {
logger.info(data);
mainWindow.webContents.send("download-progress", data.percent);
});
autoUpdater.on("update-downloaded", (data) => {
mainWindow.webContents.send("update-downloaded", data);
});
ipcMain.handle("install-and-restart", () => {
// I'm looking for an installation progress event after I called this method.
autoUpdater.quitAndInstall(false, true);
});
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要显示安装程序进度事件,您可以在软件包文件中使用“ NSIS”键。在软件包中添加以下代码。json文件:
“ nsis”:{
“允许ChangeInstallationDirectory”:true,
“ CreateSktopShortCut”:true,
“ Oneclick”:false
}
在这里,“ Oneclick:false”有魔术。它告诉是要创建一键安装程序还是辅助。默认情况下,值为真,您可以将值设置为false以显示指导的安装过程。
For showing installer progress event you can use "nsis" key in your package.json file. Add the following code in your package.json file:
"nsis": {
"allowToChangeInstallationDirectory": true,
"createDesktopShortcut": true,
"oneClick": false
}
Here "oneClick: false" does the magic. It tells whether to create one-click installer or assisted. By default the value is true, you can set the value to false to show a guided installation process.