Skip to content

A full-featured download manager.

feat: preferences add auto check updates setting

Bo Yuan7d8bb443b8cc
diff --git a/.gitignore b/.gitignore
index a8464969..b08ca7f9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ npm-debug.log.*
thumbs.db
!.gitkeep
release/*
+.idea/
diff --git a/package-lock.json b/package-lock.json
index 317ec531..5ca40b40 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -7073,7 +7073,8 @@
"version": "4.6.0",
"resolved": "http://registry.npm.taobao.org/co/download/co-4.6.0.tgz",
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
- "dev": true
+ "dev": true,
+ "optional": true
},
"coa": {
"version": "2.0.2",
@@ -11018,11 +11019,13 @@
},
"balanced-match": {
"version": "1.0.0",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
+ "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -11039,7 +11042,8 @@
},
"concat-map": {
"version": "0.0.1",
- "bundled": true
+ "bundled": true,
+ "optional": true
},
"console-control-strings": {
"version": "1.1.0",
@@ -11168,6 +11172,7 @@
"minimatch": {
"version": "3.0.4",
"bundled": true,
+ "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -20037,12 +20042,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -20062,7 +20069,8 @@
"concat-map": {
"version": "0.0.1",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"console-control-strings": {
"version": "1.1.0",
@@ -20210,6 +20218,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -21716,12 +21725,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@@ -21736,17 +21747,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"core-util-is": {
"version": "1.0.2",
@@ -21863,7 +21877,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"ini": {
"version": "1.3.5",
@@ -21875,6 +21890,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@@ -21889,6 +21905,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@@ -22000,7 +22017,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
- "dev": true
+ "dev": true,
+ "optional": true
},
"object-assign": {
"version": "4.1.1",
@@ -22012,6 +22030,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"wrappy": "1"
}
@@ -22133,6 +22152,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
+ "optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
diff --git a/src/main/Application.js b/src/main/Application.js
index 4c55241d..1a950b8a 100644
--- a/src/main/Application.js
+++ b/src/main/Application.js
@@ -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()
}
diff --git a/src/main/core/ConfigManager.js b/src/main/core/ConfigManager.js
index 3496ec87..0e829df2 100644
--- a/src/main/core/ConfigManager.js
+++ b/src/main/core/ConfigManager.js
@@ -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
}
})
}
diff --git a/src/main/core/UpdateManager.js b/src/main/core/UpdateManager.js
index f23fcc75..ad265514 100644
--- a/src/main/core/UpdateManager.js
+++ b/src/main/core/UpdateManager.js
@@ -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()
}
@@ -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()
}
@@ -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')
+ })
+ }
}
/**
diff --git a/src/renderer/components/Preference/Basic.vue b/src/renderer/components/Preference/Basic.vue
index 0b084d54..d33305a6 100644
--- a/src/renderer/components/Preference/Basic.vue
+++ b/src/renderer/components/Preference/Basic.vue
@@ -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()">
@@ -88,7 +99,9 @@
maxConcurrentDownloads,
maxConnectionPerServer,
taskNotification,
- newTaskShowDownloading
+ autoCheckUpdate,
+ newTaskShowDownloading,
+ lastCheckUpdateTime
} = config
const result = {
dir,
@@ -98,7 +111,9 @@
maxConcurrentDownloads,
maxConnectionPerServer,
taskNotification,
- newTaskShowDownloading
+ autoCheckUpdate,
+ newTaskShowDownloading,
+ lastCheckUpdateTime
}
return result
}
diff --git a/src/shared/configKeys.js b/src/shared/configKeys.js
index 8f83c875..a0bc7eab 100644
--- a/src/shared/configKeys.js
+++ b/src/shared/configKeys.js
@@ -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 = [
diff --git a/src/shared/locales/de/preferences.js b/src/shared/locales/de/preferences.js
index 19bd88d1..56a92540 100644
--- a/src/shared/locales/de/preferences.js
+++ b/src/shared/locales/de/preferences.js
@@ -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'
}
diff --git a/src/shared/locales/en-US/preferences.js b/src/shared/locales/en-US/preferences.js
index 2c74244d..9c1e9774 100644
--- a/src/shared/locales/en-US/preferences.js
+++ b/src/shared/locales/en-US/preferences.js
@@ -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'
}
diff --git a/src/shared/locales/fr/preferences.js b/src/shared/locales/fr/preferences.js
index 3e66c7c2..efed1b91 100644
--- a/src/shared/locales/fr/preferences.js
+++ b/src/shared/locales/fr/preferences.js
@@ -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'
}
diff --git a/src/shared/locales/pt-BR/preferences.js b/src/shared/locales/pt-BR/preferences.js
index d24cad4e..c34e9b0e 100644
--- a/src/shared/locales/pt-BR/preferences.js
+++ b/src/shared/locales/pt-BR/preferences.js
@@ -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'
}
diff --git a/src/shared/locales/tr/preferences.js b/src/shared/locales/tr/preferences.js
index 9b898c1e..4bd8340b 100644
--- a/src/shared/locales/tr/preferences.js
+++ b/src/shared/locales/tr/preferences.js
@@ -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'
+
}
diff --git a/src/shared/locales/zh-CN/preferences.js b/src/shared/locales/zh-CN/preferences.js
index 2454d2ba..3df0eb87 100644
--- a/src/shared/locales/zh-CN/preferences.js
+++ b/src/shared/locales/zh-CN/preferences.js
@@ -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': '上次检查更新时间'
}
diff --git a/src/shared/locales/zh-TW/preferences.js b/src/shared/locales/zh-TW/preferences.js
index c108254d..79b7d438 100644
--- a/src/shared/locales/zh-TW/preferences.js
+++ b/src/shared/locales/zh-TW/preferences.js
@@ -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': '上次檢查更新時間'
}