my build config
"build": {
"mac": {
"target": [
"dmg",
"zip"
],
"publish": {
"provider": "generic",
"url": "http://ip/update/darwin/0.0.1",
"channel": "stable"
}
},
"win": {
"target": [
"squirrel",
"nsis"
]
},
"nsis": {
"oneClick": false,
"allowToChangeInstallationDirectory": false
}
},
команда
"build_mac": "electron-builder --mac"
и main. js
const { app, BrowserWindow, dialog } = require('electron');
const { autoUpdater } = require('electron-updater');
const log = require('electron-log');
autoUpdater.logger = log;
autoUpdater.logger.transports.file.level = 'info';
log.info('App starting...');
app.whenReady().then(function() {
let win = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
},
});
win.loadFile('buildprodp/index.html');
win.webContents.openDevTools();
setInterval(() => {
win.webContents.send('submitted-form', `currentVersion - ${app.getVersion()}`);
}, 5000);
init(win);
});
app.on('ready', function() {
setTimeout(() => {
autoUpdater.checkForUpdates();
}, 6000);
});
// autoUpdate codes
const init = win => {
autoUpdater.on('checking-for-update', (ev, err) => {
win.webContents.send('submitted-form', '? Checking for updates');
win.webContents.send('submitted-form', ev);
win.webContents.send('submitted-form', err);
});
autoUpdater.on('update-available', (ev, err) => {
win.webContents.send('submitted-form', '? Update available. Downloading ⌛️');
});
autoUpdater.on('update-not-available', (ev, err) => {
win.webContents.send('submitted-form', '? Update not available');
});
autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => {
const dialogOpts = {
type: 'info',
buttons: ['Restart', 'Later'],
title: 'Application Update',
message: process.platform === 'win32' ? releaseNotes : releaseName,
detail: 'plz restart',
};
dialog.showMessageBox(dialogOpts).then(returnValue => {
if (returnValue.response === 0) autoUpdater.quitAndInstall();
});
});
autoUpdater.on('error', message => {
win.webContents.send('submitted-form', message);
});
autoUpdater.on('download-progress', progressObj => {
win.webContents.send('submitted-form', 'down start');
});
};
она работала 6 с после
- autoUpdater.checkForUpdates ();
- Элемент списка
- autoUpdater.on («проверка обновлений»
- autoUpdater.on («обновление доступно») ,
- !! Пропуск autoUpdater.on («прогресс загрузки» !!
- autoUpdater.on («обновление загружено»
https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/AppUpdater.ts#L555
Не работает только «прогресс загрузки»