fix: check for update ui
This commit is contained in:
parent
7d2df1a8c5
commit
51ca9cb289
@ -8,7 +8,7 @@ export default class AppUpdater {
|
||||
constructor(mainWindow: BrowserWindow) {
|
||||
logger.transports.file.level = 'debug'
|
||||
autoUpdater.logger = logger
|
||||
autoUpdater.forceDevUpdateConfig = true
|
||||
autoUpdater.forceDevUpdateConfig = !app.isPackaged
|
||||
autoUpdater.autoDownload = true
|
||||
|
||||
// 检测下载错误
|
||||
@ -36,12 +36,13 @@ export default class AppUpdater {
|
||||
|
||||
// 更新下载进度
|
||||
autoUpdater.on('download-progress', (progress) => {
|
||||
logger.info('下载进度', progress)
|
||||
mainWindow.webContents.send('download-progress', progress)
|
||||
})
|
||||
|
||||
// 当需要更新的内容下载完成后
|
||||
autoUpdater.on('update-downloaded', (releaseInfo: UpdateInfo) => {
|
||||
mainWindow.webContents.send('update-downloaded')
|
||||
|
||||
logger.info('下载完成,询问用户是否更新', releaseInfo)
|
||||
|
||||
dialog
|
||||
@ -58,6 +59,8 @@ export default class AppUpdater {
|
||||
if (response === 1) {
|
||||
app.isQuitting = true
|
||||
setImmediate(() => autoUpdater.quitAndInstall())
|
||||
} else {
|
||||
mainWindow.webContents.send('update-downloaded-cancelled')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@ -83,6 +83,7 @@ const AboutSettings: FC = () => {
|
||||
}),
|
||||
ipcRenderer.on('update-available', () => {
|
||||
setCheckUpdateLoading(false)
|
||||
setDownloading(true)
|
||||
}),
|
||||
ipcRenderer.on('download-update', () => {
|
||||
setCheckUpdateLoading(false)
|
||||
@ -90,6 +91,10 @@ const AboutSettings: FC = () => {
|
||||
}),
|
||||
ipcRenderer.on('download-progress', (_, progress: ProgressInfo) => {
|
||||
setPercent(progress.percent)
|
||||
setDownloading(progress.percent < 100)
|
||||
}),
|
||||
ipcRenderer.on('update-downloaded', () => {
|
||||
setDownloading(false)
|
||||
}),
|
||||
ipcRenderer.on('update-error', (_, error) => {
|
||||
setCheckUpdateLoading(false)
|
||||
@ -143,7 +148,10 @@ const AboutSettings: FC = () => {
|
||||
</Tag>
|
||||
</VersionWrapper>
|
||||
</Row>
|
||||
<CheckUpdateButton onClick={onCheckUpdate} loading={checkUpdateLoading}>
|
||||
<CheckUpdateButton
|
||||
onClick={onCheckUpdate}
|
||||
loading={checkUpdateLoading}
|
||||
disabled={downloading || checkUpdateLoading}>
|
||||
{downloading ? t('settings.about.downloading') : t('settings.about.checkUpdate')}
|
||||
</CheckUpdateButton>
|
||||
</AboutHeader>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user