Skip to content

Commit b270096

Browse files
committed
优化更新弹窗功能,新增非安装版弹窗提醒
1 parent be689f0 commit b270096

10 files changed

Lines changed: 120 additions & 34 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lx-music-desktop",
3-
"version": "0.2.4",
3+
"version": "0.2.3",
44
"description": "一个免费的音乐下载助手",
55
"main": "./dist/electron/main.js",
66
"productName": "lx-music-desktop",

publish/changeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
- 新增**MAC****Linux**版本(需要的可自行下载)
44
- 新增任务栏播放进度条控制选项(现在可在设置界面关闭在任务栏显示的播放进度)
5+
- 新增更新出错时的弹窗提示
6+
- 从该版本起,非安装版也会有更新弹窗提醒了,但仍然需要手动下载新版本更新,版本信息可到设置页面查看
57

68
### 修复
79

src/main/utils/autoUpdate.js

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,30 @@ module.exports = win => {
6161
autoUpdater.on('checking-for-update', () => {
6262
sendStatusToWindow('Checking for update...')
6363
})
64-
autoUpdater.on('update-available', (ev, info) => {
64+
autoUpdater.on('update-available', info => {
6565
sendStatusToWindow('Update available.')
66-
// win.webContents.send('update-available')
66+
win.webContents.send('update-available', info)
6767
})
68-
autoUpdater.on('update-not-available', (ev, info) => {
68+
autoUpdater.on('update-not-available', info => {
6969
sendStatusToWindow('Update not available.')
70+
setTimeout(() => { // 延迟发送事件,过早发送可能渲染进程还启动完成
71+
win.webContents.send('update-not-available')
72+
}, 5000)
7073
})
71-
autoUpdater.on('error', (ev, err) => {
74+
autoUpdater.on('error', () => {
7275
sendStatusToWindow('Error in auto-updater.')
73-
// win.webContents.send('update-error')
76+
setTimeout(() => { // 延迟发送事件,过早发送可能渲染进程还启动完成
77+
win.webContents.send('update-error')
78+
}, 6000)
7479
})
75-
autoUpdater.on('download-progress', (ev, progressObj) => {
80+
autoUpdater.on('download-progress', progressObj => {
7681
sendStatusToWindow('Download progress...')
7782
})
78-
autoUpdater.on('update-downloaded', (ev, info) => {
83+
autoUpdater.on('update-downloaded', info => {
7984
sendStatusToWindow('Update downloaded.')
80-
win.webContents.send('update-downloaded')
85+
setTimeout(() => { // 延迟发送事件,过早发送可能渲染进程还启动完成
86+
win.webContents.send('update-downloaded')
87+
}, 2000)
8188
})
8289
mainOn('quit-update', () => {
8390
setTimeout(() => {

src/renderer/App.vue

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default {
8181
},
8282
methods: {
8383
...mapActions(['getVersionInfo']),
84-
...mapMutations(['setNewVersion', 'setVersionVisible']),
84+
...mapMutations(['setNewVersion', 'setVersionModalVisible']),
8585
...mapMutations('list', ['initDefaultList']),
8686
...mapMutations('download', ['updateDownloadList']),
8787
...mapMutations(['setSetting']),
@@ -90,12 +90,25 @@ export default {
9090
body.addEventListener('mouseenter', this.dieableIgnoreMouseEvents)
9191
body.addEventListener('mouseleave', this.enableIgnoreMouseEvents)
9292
}
93+
rendererOn('update-available', (e, info) => {
94+
// this.showUpdateModal(true)
95+
this.setNewVersion({
96+
version: info.version,
97+
})
98+
})
99+
rendererOn('update-error', () => {
100+
this.setVersionModalVisible({ isError: true })
101+
this.$nextTick(() => {
102+
this.showUpdateModal()
103+
})
104+
})
93105
rendererOn('update-downloaded', () => {
94-
this.getVersionInfo().then(body => {
95-
this.setNewVersion(body)
96-
this.$nextTick(() => {
97-
this.setVersionVisible({ isShow: true })
98-
})
106+
this.showUpdateModal()
107+
})
108+
rendererOn('update-not-available', () => {
109+
if (this.setting.ignoreVersion) this.setSetting(Object.assign({}, this.setting, { ignoreVersion: null }))
110+
this.setNewVersion({
111+
version: this.version.version,
99112
})
100113
})
101114
@@ -140,6 +153,20 @@ export default {
140153
this.updateDownloadList(downloadList)
141154
}
142155
},
156+
showUpdateModal() {
157+
(this.version.newVersion && this.version.newVersion.history ? Promise.resolve(this.version.newVersion) : this.getVersionInfo().then(body => {
158+
this.setNewVersion(body)
159+
if (body.version !== this.setting.ignoreVersion) this.setSetting(Object.assign({}, this.setting, { ignoreVersion: null }))
160+
return body
161+
})).then(body => {
162+
if (body.version === this.version.version) return
163+
if (this.version.isError && body.version === this.setting.ignoreVersion) return
164+
165+
this.$nextTick(() => {
166+
this.setVersionModalVisible({ isShow: true })
167+
})
168+
})
169+
},
143170
},
144171
beforeDestroy() {
145172
if (this.isProd) {

src/renderer/components/core/Icons.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,12 @@ svg(version='1.1' xmlns='http://www.w3.org/2000/svg' xlink='http://www.w3.org/19
4848
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')
4949
// 205.857 205.857
5050
//- 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')
51+
g#icon-sound
52+
// 0 0 291.063 291.064
53+
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')
54+
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')
55+
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')
56+
57+
5158
</template>
5259

src/renderer/components/core/Player.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ export default {
212212
if (!this.targetSong.interval && this.listId != 'download') this.updateMusicInfo({ index: this.playIndex, data: { interval: formatPlayTime2(this.maxPlayTime) } })
213213
this.status = '音乐加载中...'
214214
})
215-
// this.audio.addEventListener('loadstart', () => {
216-
// this.status = '开始加载音乐信息...'
217-
// })
215+
this.audio.addEventListener('loadstart', () => {
216+
this.status = '音乐加载中...'
217+
})
218218
this.audio.addEventListener('canplay', () => {
219219
console.log('加载完成开始播放')
220220
// if (this.musicInfo.lrc) this.lyric.lrc.play(this.audio.currentTime * 1000)

src/renderer/components/material/VersionModal.vue

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template lang="pug">
22
material-modal(:show="version.showModal" @close="handleClose")
33
main(:class="$style.main" v-if="version.newVersion")
4-
h2 🚀程序更新🚀
4+
h2 {{ version.isError ? '🌟发现新版本🌟' : '🚀程序更新🚀'}}
55

66
div.scroll(:class="$style.info")
77
div(:class="$style.current")
@@ -15,7 +15,20 @@ material-modal(:show="version.showModal" @close="handleClose")
1515
h4 v{{ver.version}}
1616
p(v-html="ver.desc")
1717

18-
div(:class="$style.footer")
18+
div(:class="$style.footer" v-if="version.isError")
19+
div(:class="$style.desc")
20+
p 发现有新版本啦,但是自动更新功能出问题了
21+
p
22+
| 如果你所用的软件是
23+
strong 安装版
24+
| ,可以到QQ群:830125506 反馈哦
25+
p
26+
| 你现在可以选择继续使用当前版本或
27+
strong 去发布页下载新版本
28+
div(:class="$style.btns")
29+
material-btn(:class="$style.btn" @click.onec="handleIgnoreClick") 忽略该版本
30+
material-btn(:class="$style.btn" @click.onec="handleOpenPageClick") 去下载新版本
31+
div(:class="$style.footer" v-else)
1932
div(:class="$style.desc")
2033
p 新版本已下载完毕,
2134
p
@@ -24,18 +37,18 @@ material-modal(:show="version.showModal" @close="handleClose")
2437
| 或稍后
2538
strong 关闭程序时
2639
| 自动更新~
27-
material-btn(:class="$style.btn" @click.onec="handleClick") 立即重启更新
40+
material-btn(:class="$style.btn" @click.onec="handleRestartClick") 立即重启更新
2841

2942
</template>
3043

3144
<script>
3245
import { mapGetters, mapMutations } from 'vuex'
3346
import { rendererSend } from '../../../common/icp'
34-
import { checkVersion } from '../../utils'
47+
import { checkVersion, openUrl } from '../../utils'
3548
3649
export default {
3750
computed: {
38-
...mapGetters(['version']),
51+
...mapGetters(['version', 'setting']),
3952
history() {
4053
if (!this.version.newVersion) return []
4154
let arr = []
@@ -48,11 +61,21 @@ export default {
4861
},
4962
},
5063
methods: {
51-
...mapMutations(['setVersionVisible']),
64+
...mapMutations(['setVersionModalVisible', 'setSetting']),
5265
handleClose() {
53-
this.setVersionVisible(false)
66+
this.setVersionModalVisible({
67+
isShow: false,
68+
})
5469
},
55-
handleClick(event) {
70+
handleIgnoreClick(event) {
71+
this.handleClose()
72+
// event.target.disabled = true
73+
this.setSetting(Object.assign({}, this.setting, { ignoreVersion: this.version.newVersion.version }))
74+
},
75+
handleOpenPageClick() {
76+
openUrl('https://github.com/lyswhut/lx-music-desktop')
77+
},
78+
handleRestartClick(event) {
5679
this.handleClose()
5780
event.target.disabled = true
5881
rendererSend('quit-update')
@@ -68,7 +91,7 @@ export default {
6891
.main {
6992
position: relative;
7093
padding: 15px;
71-
max-width: 500px;
94+
max-width: 450px;
7295
min-width: 300px;
7396
display: flex;
7497
flex-flow: column nowrap;
@@ -156,6 +179,11 @@ export default {
156179
display: block;
157180
width: 100%;
158181
}
182+
.btns {
183+
display: grid;
184+
grid-template-columns: 1fr 1fr;
185+
grid-gap: 0 10px;
186+
}
159187
160188
each(@themes, {
161189
:global(#container.@{value}) {

src/renderer/store/mutations.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export default {
1919
// val.desc = val.desc.replace(/\n/g, '<br>')
2020
state.version.newVersion = val
2121
},
22-
setVersionVisible(state, { isShow }) {
23-
state.version.showModal = isShow
22+
setVersionModalVisible(state, { isShow, isError }) {
23+
if (isShow !== undefined) state.version.showModal = isShow
24+
if (isError !== undefined) state.version.isError = isError
2425
},
2526
}

src/renderer/utils/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ export const isChildren = (parent, children) => {
161161
* @param {*} setting
162162
*/
163163
export const updateSetting = setting => {
164-
const defaultVersion = '1.0.3'
164+
const defaultVersion = '1.0.4'
165165
const defaultSetting = {
166166
version: defaultVersion,
167167
player: {
@@ -185,6 +185,7 @@ export const updateSetting = setting => {
185185
sourceId: 'kw',
186186
apiSource: 'messoer',
187187
randomAnimate: true,
188+
ignoreVersion: null,
188189
}
189190
const overwriteSetting = {
190191
version: defaultVersion,

src/renderer/views/Setting.vue

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,21 @@ div.scroll(:class="$style.setting")
6767
div
6868
material-btn(:class="[$style.btn, $style.gapLeft]" min @click="handleImportAllData") 导入
6969
material-btn(:class="[$style.btn, $style.gapLeft]" min @click="handleExportAllData") 导出
70+
dt 软件更新
71+
dd
72+
p.small
73+
| 最新版本:{{version.newVersion ? version.newVersion.version : '未知'}}
74+
p.small 当前版本:{{version.version}}
75+
p.small(v-if="version.newVersion")
76+
span(v-if="isLatestVer") 软件已是最新,尽情地体验吧~🥂
77+
material-btn(v-else-if="setting.ignoreVersion" :class="[$style.btn, $style.gapLeft]" min @click="showUpdateModal") 打开更新窗口
78+
span(v-else) 发现新版本并在努力下载中,请稍等...⏳
79+
p.small(v-else) 检查更新中...
7080
dt 关于洛雪音乐
7181
dd
7282
p.small
7383
| 本软件完全免费,代码已开源,开源地址:
7484
span.hover(@click="handleOpenUrl('https://github.com/lyswhut/lx-music-desktop')") https://github.com/lyswhut/lx-music-desktop
75-
p
76-
small 当前版本:
77-
| {{version.version}}
7885
p.small
7986
| 本软件仅用于学习交流使用,禁止将本软件用于
8087
strong 非法用途
@@ -111,6 +118,9 @@ export default {
111118
computed: {
112119
...mapGetters(['setting', 'themes', 'version']),
113120
...mapGetters('list', ['defaultList']),
121+
isLatestVer() {
122+
return this.version.newVersion && this.version.version === this.version.newVersion.version
123+
},
114124
},
115125
data() {
116126
return {
@@ -202,7 +212,7 @@ export default {
202212
this.init()
203213
},
204214
methods: {
205-
...mapMutations(['setSetting']),
215+
...mapMutations(['setSetting', 'setVersionModalVisible']),
206216
...mapMutations('list', ['setDefaultList']),
207217
init() {
208218
this.current_setting = JSON.parse(JSON.stringify(this.setting))
@@ -356,6 +366,9 @@ export default {
356366
window.globalObj.apiSource = id
357367
})
358368
},
369+
showUpdateModal() {
370+
this.setVersionModalVisible({ isShow: true })
371+
},
359372
},
360373
}
361374
</script>

0 commit comments

Comments
 (0)