From b27009659123ba749c2d4494c4439f5c82348f6a Mon Sep 17 00:00:00 2001 From: lyswhut Date: Sat, 24 Aug 2019 14:24:07 +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=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=96=B0=E5=A2=9E=E9=9D=9E?= =?UTF-8?q?=E5=AE=89=E8=A3=85=E7=89=88=E5=BC=B9=E7=AA=97=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- publish/changeLog.md | 2 + src/main/utils/autoUpdate.js | 23 ++++++---- src/renderer/App.vue | 39 +++++++++++++--- src/renderer/components/core/Icons.vue | 7 +++ src/renderer/components/core/Player.vue | 6 +-- .../components/material/VersionModal.vue | 46 +++++++++++++++---- src/renderer/store/mutations.js | 5 +- src/renderer/utils/index.js | 3 +- src/renderer/views/Setting.vue | 21 +++++++-- 10 files changed, 120 insertions(+), 34 deletions(-) diff --git a/package.json b/package.json index eded902b..8eb99504 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lx-music-desktop", - "version": "0.2.4", + "version": "0.2.3", "description": "一个免费的音乐下载助手", "main": "./dist/electron/main.js", "productName": "lx-music-desktop", diff --git a/publish/changeLog.md b/publish/changeLog.md index b75c3a75..2e921f9b 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -2,6 +2,8 @@ - 新增**MAC**及**Linux**版本(需要的可自行下载) - 新增任务栏播放进度条控制选项(现在可在设置界面关闭在任务栏显示的播放进度) +- 新增更新出错时的弹窗提示 +- 从该版本起,非安装版也会有更新弹窗提醒了,但仍然需要手动下载新版本更新,版本信息可到设置页面查看 ### 修复 diff --git a/src/main/utils/autoUpdate.js b/src/main/utils/autoUpdate.js index f49a12ce..7514abc9 100644 --- a/src/main/utils/autoUpdate.js +++ b/src/main/utils/autoUpdate.js @@ -61,23 +61,30 @@ module.exports = win => { autoUpdater.on('checking-for-update', () => { sendStatusToWindow('Checking for update...') }) - autoUpdater.on('update-available', (ev, info) => { + autoUpdater.on('update-available', info => { sendStatusToWindow('Update available.') - // win.webContents.send('update-available') + win.webContents.send('update-available', info) }) - autoUpdater.on('update-not-available', (ev, info) => { + autoUpdater.on('update-not-available', info => { sendStatusToWindow('Update not available.') + setTimeout(() => { // 延迟发送事件,过早发送可能渲染进程还启动完成 + win.webContents.send('update-not-available') + }, 5000) }) - autoUpdater.on('error', (ev, err) => { + autoUpdater.on('error', () => { sendStatusToWindow('Error in auto-updater.') - // win.webContents.send('update-error') + setTimeout(() => { // 延迟发送事件,过早发送可能渲染进程还启动完成 + win.webContents.send('update-error') + }, 6000) }) - autoUpdater.on('download-progress', (ev, progressObj) => { + autoUpdater.on('download-progress', progressObj => { sendStatusToWindow('Download progress...') }) - autoUpdater.on('update-downloaded', (ev, info) => { + autoUpdater.on('update-downloaded', info => { sendStatusToWindow('Update downloaded.') - win.webContents.send('update-downloaded') + setTimeout(() => { // 延迟发送事件,过早发送可能渲染进程还启动完成 + win.webContents.send('update-downloaded') + }, 2000) }) mainOn('quit-update', () => { setTimeout(() => { diff --git a/src/renderer/App.vue b/src/renderer/App.vue index f649c91c..08b2d1ba 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -81,7 +81,7 @@ export default { }, methods: { ...mapActions(['getVersionInfo']), - ...mapMutations(['setNewVersion', 'setVersionVisible']), + ...mapMutations(['setNewVersion', 'setVersionModalVisible']), ...mapMutations('list', ['initDefaultList']), ...mapMutations('download', ['updateDownloadList']), ...mapMutations(['setSetting']), @@ -90,12 +90,25 @@ export default { body.addEventListener('mouseenter', this.dieableIgnoreMouseEvents) body.addEventListener('mouseleave', this.enableIgnoreMouseEvents) } + rendererOn('update-available', (e, info) => { + // this.showUpdateModal(true) + this.setNewVersion({ + version: info.version, + }) + }) + rendererOn('update-error', () => { + this.setVersionModalVisible({ isError: true }) + this.$nextTick(() => { + this.showUpdateModal() + }) + }) rendererOn('update-downloaded', () => { - this.getVersionInfo().then(body => { - this.setNewVersion(body) - this.$nextTick(() => { - this.setVersionVisible({ isShow: true }) - }) + this.showUpdateModal() + }) + rendererOn('update-not-available', () => { + if (this.setting.ignoreVersion) this.setSetting(Object.assign({}, this.setting, { ignoreVersion: null })) + this.setNewVersion({ + version: this.version.version, }) }) @@ -140,6 +153,20 @@ export default { this.updateDownloadList(downloadList) } }, + 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 + + this.$nextTick(() => { + this.setVersionModalVisible({ isShow: true }) + }) + }) + }, }, beforeDestroy() { if (this.isProd) { diff --git a/src/renderer/components/core/Icons.vue b/src/renderer/components/core/Icons.vue index 3568ec1c..740f9d37 100644 --- a/src/renderer/components/core/Icons.vue +++ b/src/renderer/components/core/Icons.vue @@ -48,5 +48,12 @@ svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/19 path(fill='currentColor' d='M112.525,95.091L26.75,45.901C11.982,37.427,0,44.369,0,61.404v98.062c0,17.025,11.982,23.969,26.75,15.492l85.781-49.177C127.294,117.305,127.294,103.565,112.525,95.091z') // 205.857 205.857 //- path(fill='currentColor' d='M174.522,0h-26.848c-9.885,0-17.897,8.013-17.897,17.899v62.533L37.513,2.522c-3.483-2.406-7.807-2.005-11.072-2.005c-13.061,0-13.004,11.7-13.004,14.666v175.983c0,2.507-0.057,14.666,13.004,14.666c3.265,0,7.589,0.401,11.072-2.005l92.265-77.91v62.016c0,9.885,8.012,17.898,17.897,17.898h26.848c9.885,0,17.898-8.013,17.898-17.898V17.899C192.421,8.013,184.408,0,174.522,0z') + g#icon-sound + // 0 0 291.063 291.064 + path(d='M26.512,204.255h18.292l106.48,67.761c12.354,7.855,22.369,2.361,22.369-12.282v-69.397c16.933-8.854,28.501-26.559,28.501-46.983c0-20.425-11.568-38.129-28.501-46.986V31.645c0-14.639-10.18-20.401-22.731-12.873L44.804,82.443H26.512C11.866,82.443,0,94.311,0,108.955v68.789C0,192.387,11.866,204.255,26.512,204.255z') + path(d='M219.791,152.899c-0.818,11.185-4.039,21.758-9.569,31.426c-3.635,6.354-1.43,14.452,4.919,18.087c2.082,1.187,4.34,1.751,6.576,1.751c4.599,0,9.062-2.393,11.517-6.675c7.508-13.138,11.889-27.491,12.986-42.663c1.714-23.397-4.836-46.781-18.455-65.845c-4.256-5.96-12.536-7.332-18.491-3.081c-5.959,4.259-7.337,12.531-3.08,18.491C216.218,118.425,221.055,135.653,219.791,152.899z') + path(d='M290.7,158c3.34-45.736-16.508-89.592-53.097-117.318c-5.841-4.433-14.146-3.27-18.568,2.556c-4.428,5.838-3.283,14.151,2.558,18.568c29.401,22.281,45.355,57.521,42.668,94.252c-2.02,27.636-14.375,53.159-34.787,71.867c-5.396,4.95-5.758,13.339-0.808,18.729c2.609,2.854,6.188,4.298,9.771,4.298c3.194,0,6.41-1.154,8.953-3.484C272.805,224.175,288.184,192.408,290.7,158z') + + diff --git a/src/renderer/components/core/Player.vue b/src/renderer/components/core/Player.vue index c7dd2ef9..afe86d6a 100644 --- a/src/renderer/components/core/Player.vue +++ b/src/renderer/components/core/Player.vue @@ -212,9 +212,9 @@ export default { if (!this.targetSong.interval && this.listId != 'download') this.updateMusicInfo({ index: this.playIndex, data: { interval: formatPlayTime2(this.maxPlayTime) } }) this.status = '音乐加载中...' }) - // this.audio.addEventListener('loadstart', () => { - // this.status = '开始加载音乐信息...' - // }) + this.audio.addEventListener('loadstart', () => { + this.status = '音乐加载中...' + }) this.audio.addEventListener('canplay', () => { console.log('加载完成开始播放') // if (this.musicInfo.lrc) this.lyric.lrc.play(this.audio.currentTime * 1000) diff --git a/src/renderer/components/material/VersionModal.vue b/src/renderer/components/material/VersionModal.vue index cc516a58..ce04b1c4 100644 --- a/src/renderer/components/material/VersionModal.vue +++ b/src/renderer/components/material/VersionModal.vue @@ -1,7 +1,7 @@