gpt4 book ai didi

electron - Electron 'download-progress'没什么

转载 作者:行者123 更新时间:2023-12-03 12:41:28 25 4
gpt4 key购买 nike

我的构建配置

"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('update-available',
  • !!跳过autoUpdater.on('download-progress'!!
  • autoUpdater.on('更新下载的'

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

    仅“下载进行中”无效

    最佳答案

    这是一个缓存问题
    删除文件夹效果很好

    关于electron - Electron 'download-progress'没什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60599279/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com