🔨 Refactor: optimize auto update

This commit is contained in:
萌萌哒赫萝
2023-04-06 12:50:07 +08:00
parent 2fab2cd79d
commit e0e26bd9ad
11 changed files with 165 additions and 190 deletions
+6 -3
View File
@@ -43,6 +43,7 @@ import getManageApi from '../manage/Main'
import UpDownTaskQueue from '../manage/datastore/upDownTaskQueue'
import { T } from '~/main/i18n'
import { UpdateInfo, autoUpdater } from 'electron-updater'
import updateChecker from '../utils/updateChecker'
const isDevelopment = process.env.NODE_ENV !== 'production'
const handleStartUpFiles = (argv: string[], cwd: string) => {
@@ -77,11 +78,14 @@ autoUpdater.on('update-available', (info: UpdateInfo) => {
buttons: ['Yes', 'No'],
message: T('TIPS_FIND_NEW_VERSION', {
v: info.version
})
}),
checkboxLabel: T('NO_MORE_NOTICE'),
checkboxChecked: false
}).then((result) => {
if (result.response === 0) {
autoUpdater.downloadUpdate()
}
db.set('settings.showUpdateTip', !result.checkboxChecked)
})
})
@@ -151,8 +155,7 @@ class LifeCycle {
}
createTray()
db.set('needReload', false)
// updateChecker()
autoUpdater.checkForUpdatesAndNotify()
updateChecker()
// 不需要阻塞
process.nextTick(() => {
shortKeyHandler.init()