Skip to content

Commit

Permalink
feat: preferences add auto check updates setting
Browse files Browse the repository at this point in the history
* add auto check update, time out: 1 min.

* fix: add auto check update, check interval: 30 min.

* no message

* no message

* fix: modify update check interval to 7 days, add display of [last check update time] to preference.

* no message

* fix: modified the group of auto-check-update, fix the display of last-check-update-time

* no message

* fix: hide last-check-update-time when never check.
  • Loading branch information
Yi-Frank authored and agalwood committed Apr 1, 2019
1 parent 1489d58 commit 7d8bb44
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ npm-debug.log.*
thumbs.db
!.gitkeep
release/*
.idea/
42 changes: 31 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/main/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,12 @@ export default class Application extends EventEmitter {
if (is.mas()) {
return
}
this.updateManager = new UpdateManager()
this.updateManager = new UpdateManager({
autoCheck: this.configManager.getUserConfig('auto-check-update')
? (new Date().getTime() - this.configManager.getUserConfig('last-check-update-time') > 7 * 24 * 60 * 60 * 1000)
: false,
setCheckTime: this.configManager
})
this.handleUpdaterEvents()
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/core/ConfigManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ export default class ConfigManager {
'all-proxy-backup': '',
'log-path': getLogPath(),
'session-path': getSessionPath(),
'locale': app.getLocale()
'locale': app.getLocale(),
'auto-check-update': false,
'last-check-update-time': 0
}
})
}
Expand Down
22 changes: 18 additions & 4 deletions src/main/core/UpdateManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export default class UpdateManager extends EventEmitter {
this.updater = autoUpdater
this.updater.autoDownload = false
this.updater.logger = logger
this.autoCheckData = {
checkEnable: this.options.autoCheck,
userCheck: false
}
this.init()
}

Expand All @@ -36,9 +40,17 @@ export default class UpdateManager extends EventEmitter {
this.updater.on('download-progress', this.updateDownloadProgress.bind(this))
this.updater.on('update-downloaded', this.updateDownloaded.bind(this))
this.updater.on('error', this.updateError.bind(this))

if (this.autoCheckData.checkEnable) {
this.autoCheckData.userCheck = false
this.options.setCheckTime.setUserConfig('last-check-update-time', new Date().getTime())
this.updater.checkForUpdates()
}
}

check () {
this.options.setCheckTime.setUserConfig('last-check-update-time', new Date().getTime())
this.autoCheckData.userCheck = true
this.updater.checkForUpdates()
}

Expand All @@ -63,10 +75,12 @@ export default class UpdateManager extends EventEmitter {

updateNotAvailable (event, info) {
this.emit('update-not-available', info)
dialog.showMessageBox({
title: this.i18n.t('app.check-for-updates-title'),
message: this.i18n.t('app.update-not-available-message')
})
if (this.autoCheckData.userCheck) {
dialog.showMessageBox({
title: this.i18n.t('app.check-for-updates-title'),
message: this.i18n.t('app.update-not-available-message')
})
}
}

/**
Expand Down
25 changes: 20 additions & 5 deletions src/renderer/components/Preference/Basic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,20 @@
:model="form"
:rules="rules">
<el-form-item :label="`${$t('preferences.startup')}: `" :label-width="formLabelWidth">
<el-checkbox v-model="form.resumeAllWhenAppLaunched">
{{ $t('preferences.auto-resume-all') }}
</el-checkbox>
<el-col class="form-item-sub" :span="24">
<el-checkbox v-model="form.resumeAllWhenAppLaunched">
{{ $t('preferences.auto-resume-all') }}
</el-checkbox>
</el-col>
<el-col class="form-item-sub" :span="24">
<el-checkbox v-model="form.autoCheckUpdate">
{{ $t('preferences.auto-check-update') }}
</el-checkbox>
<div class="el-form-item__info" style="margin-top: 8px;" v-if="form.lastCheckUpdateTime !== 0">
{{ $t('preferences.last-check-update-time') + ': ' + (form.lastCheckUpdateTime !== 0 ? new
Date(form.lastCheckUpdateTime).toLocaleString() : new Date().toLocaleString()) }}
</div>
</el-col>
</el-form-item>
<el-form-item :label="`${$t('preferences.default-dir')}: `" :label-width="formLabelWidth">
<el-input placeholder="" v-model="downloadDir" :readonly="isMas()">
Expand Down Expand Up @@ -88,7 +99,9 @@
maxConcurrentDownloads,
maxConnectionPerServer,
taskNotification,
newTaskShowDownloading
autoCheckUpdate,
newTaskShowDownloading,
lastCheckUpdateTime
} = config
const result = {
dir,
Expand All @@ -98,7 +111,9 @@
maxConcurrentDownloads,
maxConnectionPerServer,
taskNotification,
newTaskShowDownloading
autoCheckUpdate,
newTaskShowDownloading,
lastCheckUpdateTime
}
return result
}
Expand Down
4 changes: 3 additions & 1 deletion src/shared/configKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ const userKeys = [
'all-proxy-backup',
'log-path',
'session-path',
'enable-egg-features'
'enable-egg-features',
'auto-check-update',
'last-check-update-time'
]

const systemKeys = [
Expand Down
4 changes: 3 additions & 1 deletion src/shared/locales/de/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ export default {
'browser-extensions': 'Erweiterungen',
'baidu-exporter': 'Baidu Exporter',
'browser-extensions-tip': 'Von der Community bereitgestellt, ',
'baidu-exporter-help': 'mehr über die Verwendung zu erfahren'
'baidu-exporter-help': 'mehr über die Verwendung zu erfahren',
'auto-check-update': 'Automatische Updates überprüfen',
'last-check-update-time': 'letzte kontrolle update - zeit'
}
4 changes: 3 additions & 1 deletion src/shared/locales/en-US/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ export default {
'browser-extensions': 'Extensions',
'baidu-exporter': 'BaiduExporter',
'browser-extensions-tip': 'Provided by the community, ',
'baidu-exporter-help': 'Click here for usage'
'baidu-exporter-help': 'Click here for usage',
'auto-check-update': 'Auto check update',
'last-check-update-time': 'Last Check Update Time'
}
4 changes: 3 additions & 1 deletion src/shared/locales/fr/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ export default {
'browser-extensions': 'Extensions',
'baidu-exporter': 'BaiduExporter',
'browser-extensions-tip': 'Fourni par la communauté, ',
'baidu-exporter-help': 'Cliquez ici pour voir l\'utilisation'
'baidu-exporter-help': 'Cliquez ici pour voir l\'utilisation',
'auto-check-update': 'Mise à jour automatique',
'last-check-update-time': 'dernier contrôle la mise à jour du temps'
}
4 changes: 3 additions & 1 deletion src/shared/locales/pt-BR/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ export default {
'browser-extensions': 'Extensões',
'baidu-exporter': 'BaiduExporter',
'browser-extensions-tip': 'Fornecido pela comunidade, ',
'baidu-exporter-help': 'Clique aqui ver as instruções de uso'
'baidu-exporter-help': 'Clique aqui ver as instruções de uso',
'auto-check-update': 'A verificação automática de atualizações',
'last-check-update-time': 'última verificação do tempo de atualização'
}
5 changes: 4 additions & 1 deletion src/shared/locales/tr/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,8 @@ export default {
'browser-extensions': 'Eklentiler',
'baidu-exporter': 'BaiduExporter',
'browser-extensions-tip': 'Topluluk tarafından sağlanan, ',
'baidu-exporter-help': 'Kullanım detayları için buraya tıklayın'
'baidu-exporter-help': 'Kullanım detayları için buraya tıklayın',
'auto-check-update': 'Auto Check Update',
'last-check-update-time': 'Last Check Update Time'

}
4 changes: 3 additions & 1 deletion src/shared/locales/zh-CN/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ export default {
'browser-extensions': '浏览器扩展',
'baidu-exporter': '百度网盘助手',
'browser-extensions-tip': '社区提供的浏览器扩展「不保证可用性」,',
'baidu-exporter-help': '点此查看使用说明'
'baidu-exporter-help': '点此查看使用说明',
'auto-check-update': '自动检查更新',
'last-check-update-time': '上次检查更新时间'
}
4 changes: 3 additions & 1 deletion src/shared/locales/zh-TW/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ export default {
'browser-extensions': '瀏覽器擴充功能',
'baidu-exporter': '百度网盘助手',
'browser-extensions-tip': '社群提供的瀏覽器擴充功能「不保證可用性」,',
'baidu-exporter-help': '点此查看使用说明'
'baidu-exporter-help': '点此查看使用说明',
'auto-check-update': '自動檢查更新',
'last-check-update-time': '上次檢查更新時間'
}

0 comments on commit 7d8bb44

Please sign in to comment.