电子 - 上端的进度事件

发布于 2025-02-04 11:51:13 字数 959 浏览 3 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凶凌 2025-02-11 11:51:13

要显示安装程序进度事件,您可以在软件包文件中使用“ 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文