From dfa15c695206705b24e8d06fbb05a23e5cde45c1 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sun, 3 Nov 2019 17:18:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9B=B4=E6=96=B0=E5=BC=B9?= =?UTF-8?q?=E7=AA=97=E6=9C=BA=E5=88=B6=E5=8F=8A=E5=85=B6=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish/changeLog.md | 9 +- src/main/utils/autoUpdate.js | 4 +- src/renderer/App.vue | 52 +++--- .../components/material/VersionModal.vue | 159 +++++++++++++----- src/renderer/store/actions.js | 6 +- src/renderer/store/mutations.js | 5 +- src/renderer/store/state.js | 3 + src/renderer/utils/index.js | 1 - src/renderer/views/Setting.vue | 14 +- 9 files changed, 174 insertions(+), 79 deletions(-) diff --git a/publish/changeLog.md b/publish/changeLog.md index 14019c0b..00131e4d 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,8 +1,3 @@ -#### 优化 +### 优化 -- 大幅减少程序**播放时**对CPU与GPU的使用,经测试CPU使用减少60%以上,GPU使用减少90%以上,这应该能解决MAC系统上的温度上涨的问题 - -#### 修复 - -- 修复酷我源**搜索提示**、**排行榜**无法获取的问题 -- 修复咪咕源无法播放的问题 +- 优化更新弹窗机制及其内容描述 diff --git a/src/main/utils/autoUpdate.js b/src/main/utils/autoUpdate.js index 4aa145a9..d496103d 100644 --- a/src/main/utils/autoUpdate.js +++ b/src/main/utils/autoUpdate.js @@ -92,14 +92,14 @@ module.exports = isFirstCheckedUpdate => { }) autoUpdater.on('error', err => { sendStatusToWindow('Error in auto-updater.') - handleSendEvent({ type: 'update-error', info: err }) + handleSendEvent({ type: 'update-error', info: err.message }) }) autoUpdater.on('download-progress', progressObj => { let log_message = 'Download speed: ' + progressObj.bytesPerSecond log_message = log_message + ' - Downloaded ' + progressObj.percent + '%' log_message = log_message + ' (' + progressObj.transferred + '/' + progressObj.total + ')' sendStatusToWindow(log_message) - handleSendEvent({ type: 'download-progress', info: progressObj }) + handleSendEvent({ type: 'update-progress', info: progressObj }) }) autoUpdater.on('update-downloaded', info => { sendStatusToWindow('Update downloaded.') diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 4e3a72fa..1229b1f2 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -108,33 +108,39 @@ export default { } ipcRenderer.on('update-available', (e, info) => { // this.showUpdateModal(true) - console.log(info) - this.setNewVersion({ + // console.log(info) + this.getVersionInfo().catch(() => ({ version: info.version, + desc: info.releaseNotes, + })).then(body => { + // console.log(body) + this.setNewVersion(body) + this.$nextTick(() => { + this.setVersionModalVisible({ isShow: true }) + }) }) }) - ipcRenderer.on('update-error', err => { - console.log(err) - if (!this.updateTimeout) return - this.setVersionModalVisible({ isError: true }) + ipcRenderer.on('update-error', (event, err) => { + // console.log(err) this.clearUpdateTimeout() + this.setVersionModalVisible({ isError: true }) this.$nextTick(() => { this.showUpdateModal() }) }) - ipcRenderer.on('update-progress', progress => { - console.log(progress) + ipcRenderer.on('update-progress', (event, progress) => { + // console.log(progress) this.setDownloadProgress(progress) }) ipcRenderer.on('update-downloaded', info => { - console.log(info) + // console.log(info) this.clearUpdateTimeout() - this.setVersionModalVisible({ isError: false }) - this.showUpdateModal() + this.setVersionModalVisible({ isDownloaded: true }) + this.$nextTick(() => { + this.showUpdateModal() + }) }) ipcRenderer.on('update-not-available', () => { - if (!this.updateTimeout) return - if (this.setting.ignoreVersion) this.setSetting(Object.assign({}, this.setting, { ignoreVersion: null })) this.clearUpdateTimeout() this.setNewVersion({ version: this.version.version, @@ -143,11 +149,11 @@ export default { // 更新超时定时器 this.updateTimeout = setTimeout(() => { this.updateTimeout = null - this.setVersionModalVisible({ isError: true }) + this.setVersionModalVisible({ isTimeOut: true }) this.$nextTick(() => { this.showUpdateModal() }) - }, 180000) + }, 60 * 30 * 1000) this.initData() this.globalObj.apiSource = this.setting.apiSource @@ -192,12 +198,18 @@ export default { showUpdateModal() { (this.version.newVersion && this.version.newVersion.history ? Promise.resolve(this.version.newVersion) : this.getVersionInfo().then(body => { this.setNewVersion(body) - if (body.version !== this.setting.ignoreVersion) this.setSetting(Object.assign({}, this.setting, { ignoreVersion: null })) return body - })).then(body => { - if (body.version === this.version.version) return - if (this.version.isError && body.version === this.setting.ignoreVersion) return - + })).catch(() => { + this.setVersionModalVisible({ isUnknow: true }) + let result = { + version: '0.0.0', + desc: null, + } + this.setNewVersion(result) + return result + }).then(result => { + if (result.version === this.version.version) return + console.log(this.version) this.$nextTick(() => { this.setVersionModalVisible({ isShow: true }) }) diff --git a/src/renderer/components/material/VersionModal.vue b/src/renderer/components/material/VersionModal.vue index dce871dc..4235e062 100644 --- a/src/renderer/components/material/VersionModal.vue +++ b/src/renderer/components/material/VersionModal.vue @@ -1,7 +1,31 @@