电子更新程序下载进度事件未调用

时间:2019-08-16 15:41:06

标签: electron electron-builder

我想在下载更新时在我的电子应用程序内显示进度条。因此,我已经根据我的需要调整了电子制造商更新程序文档中的示例代码。

以下是我的main.ts的摘录:

function sendStatusToWindow(updateState: UpdateState) {
  log.info(updateState);
  win.webContents.send('message', updateState);
}

autoUpdater.on('checking-for-update', () => {
  sendStatusToWindow({ status: 'checking' });
});

autoUpdater.on('update-available', (info) => {
  sendStatusToWindow({ status: 'update-available' });
});

autoUpdater.on('update-not-available', (info) => {
  sendStatusToWindow({ status: 'current' });
});

autoUpdater.on('error', (err) => {
  sendStatusToWindow({ status: 'error', error: err });
});

autoUpdater.on('download-progress', (progressObj) => {
  log.info(progressObj);
  sendStatusToWindow({
    status: 'downloading',
    download: {
      bytesPerSecond: progressObj.bytesPerSecond,
      percent: progressObj.percent,
      transferred: progressObj.transferred,
      total: progressObj.total
    }
  });
});

autoUpdater.on('update-downloaded', (info) => {
  sendStatusToWindow({ status: 'completed' });
});

还有我的electronic-builder.json:

  "win": {
    "icon": "dist",
    "target": ["NSIS"],
    "publish": ["github"]
  }

download-progress之外的所有事件都被调用 我在做错什么吗?

1 个答案:

答案 0 :(得分:0)

您要打以下电话吗?

Page-003.png (89, 41, 89)
Page-082.png (89, 41, 89)
Page-047.png (90, 40, 89)
Page-075.png (92, 38, 91)
Page-111.png (92, 38, 91)
Page-071.png (92, 38, 92)
Page-074.png (92, 38, 92)
Page-077.png (92, 38, 92)
Page-112.png (93, 37, 93)
Page-079.png (94, 36, 93)
Page-078.png (94, 36, 94)
Page-031.png (95, 35, 95)
Page-083.png (95, 35, 95)
Page-023.png (96, 34, 96)
Page-050.png (96, 34, 96)
Page-081.png (96, 34, 96)
Page-098.png (96, 34, 96)
Page-099.png (96, 34, 96)
Page-033.png (97, 33, 96)
Page-094.png (97, 33, 97)
Page-107.png (97, 33, 97)
Page-038.png (98, 32, 98)
Page-039.png (98, 32, 98)
Page-095.png (98, 32, 98)
Page-096.png (98, 32, 98)
Page-106.png (98, 32, 98)
Page-108.png (98, 32, 98)
Page-018.png (99, 31, 99)
Page-046.png (99, 31, 99)
Page-072.png (99, 31, 99)
Page-097.png (99, 31, 99)
Page-066.png (100, 30, 99)
Page-080.png (100, 30, 99)
Page-110.png (100, 30, 99)
Page-011.png (100, 30, 100)
Page-121.png (100, 30, 100)
Page-109.png (101, 29, 100)
Page-006.png (101, 29, 101)
Page-051.png (101, 29, 101)
Page-007.png (102, 28, 102)
Page-010.png (102, 28, 102)
Page-015.png (102, 28, 102)
Page-025.png (102, 28, 102)
Page-049.png (102, 28, 102)
Page-052.png (102, 28, 102)
Page-056.png (102, 28, 102)
Page-065.png (102, 28, 102)
Page-076.png (102, 28, 102)
Page-086.png (102, 28, 102)
Page-102.png (102, 28, 102)
Page-122.png (102, 28, 102)
Page-067.png (103, 27, 102)
Page-092.png (103, 27, 102)
Page-116.png (103, 27, 102)
Page-014.png (103, 27, 103)
Page-084.png (103, 27, 103)
Page-103.png (103, 27, 103)
Page-115.png (103, 27, 103)
Page-026.png (104, 26, 103)
Page-059.png (104, 26, 103)
Page-012.png (104, 26, 104)
Page-024.png (104, 26, 104)
Page-048.png (104, 26, 104)
Page-123.png (104, 26, 104)
Page-009.png (105, 25, 105)
Page-034.png (105, 25, 105)
Page-087.png (105, 25, 105)
Page-114.png (105, 25, 105)
Page-118.png (105, 25, 105)
Page-119.png (105, 25, 105)
Page-030.png (106, 24, 105)
Page-043.png (106, 24, 105)
Page-062.png (106, 24, 105)
Page-063.png (106, 24, 105)
Page-035.png (106, 24, 106)
Page-126.png (106, 24, 106)
Page-113.png (107, 23, 106)
Page-044.png (107, 23, 107)
Page-068.png (107, 23, 107)
Page-019.png (108, 22, 107)
Page-070.png (108, 22, 107)
Page-054.png (108, 22, 108)
Page-064.png (108, 22, 108)
Page-090.png (108, 22, 108)
Page-002.png (109, 21, 108)
Page-058.png (109, 21, 108)
Page-091.png (109, 21, 108)
Page-020.png (109, 21, 109)
Page-101.png (109, 21, 109)
Page-104.png (110, 20, 109)
Page-032.png (110, 20, 110)
Page-004.png (111, 19, 111)
Page-040.png (112, 18, 111)
Page-021.png (112, 18, 112)
Page-041.png (112, 18, 112)
Page-061.png (113, 17, 113)
Page-016.png (114, 16, 114)
Page-055.png (114, 16, 114)
Page-008.png (115, 15, 114)
Page-117.png (115, 15, 115)
Page-042.png (116, 14, 116)
Page-036.png (118, 12, 117)
Page-085.png (130, 0, 129)
Page-022.png (131, -1, 131)
Page-073.png (131, -1, 131)
Page-027.png (133, -3, 132)
Page-124.png (133, -3, 132)
Page-005.png (133, -3, 133)
Page-057.png (134, -4, 133)
Page-013.png (135, -5, 135)
Page-037.png (135, -5, 135)
Page-105.png (137, -7, 137)
Page-120.png (137, -7, 137)
Page-045.png (138, -8, 138)
Page-060.png (139, -9, 139)
Page-093.png (139, -9, 139)
Page-017.png (140, -10, 140)
Page-125.png (141, -11, 140)
Page-089.png (142, -12, 141)
Page-029.png (142, -12, 142)
Page-028.png (143, -13, 142)
Page-069.png (145, -15, 145)
Page-053.png (147, -17, 146)
Page-100.png (149, -19, 149)
Page-088.png (150, -20, 149)

在开发人员模式下,checkForUpdatesAndNotify不会触发任何操作。仅在打包时有效。如果在开发人员模式(electron-is-dev)中调用checkForUpdates,则应该获得下载事件。