eletron 'загрузка-прогресс' ничего не делает - PullRequest
0 голосов
/ 09 марта 2020

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 с после

  1. autoUpdater.checkForUpdates ();
  2. Элемент списка
  3. autoUpdater.on («проверка обновлений»
  4. autoUpdater.on («обновление доступно») ,
  5. !! Пропуск autoUpdater.on («прогресс загрузки» !!
  6. autoUpdater.on («обновление загружено»

https://github.com/electron-userland/electron-builder/blob/master/packages/electron-updater/src/AppUpdater.ts#L555

Не работает только «прогресс загрузки»

1 Ответ

0 голосов
/ 10 марта 2020

Это была проблема с кешем Удаление папки работает нормально

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...