Skip to content

Commit 4cbbf2a

Browse files
committed
新增版本更新超时功能
1 parent a035a25 commit 4cbbf2a

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/renderer/App.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export default {
3737
globalObj: {
3838
apiSource: 'messoer',
3939
},
40+
updateTimeout: null,
4041
}
4142
},
4243
computed: {
@@ -98,19 +99,29 @@ export default {
9899
})
99100
rendererOn('update-error', () => {
100101
this.setVersionModalVisible({ isError: true })
102+
this.clearUpdateTimeout()
101103
this.$nextTick(() => {
102104
this.showUpdateModal()
103105
})
104106
})
105107
rendererOn('update-downloaded', () => {
108+
this.clearUpdateTimeout()
106109
this.showUpdateModal()
107110
})
108111
rendererOn('update-not-available', () => {
109112
if (this.setting.ignoreVersion) this.setSetting(Object.assign({}, this.setting, { ignoreVersion: null }))
113+
this.clearUpdateTimeout()
110114
this.setNewVersion({
111115
version: this.version.version,
112116
})
113117
})
118+
this.updateTimeout = setTimeout(() => {
119+
this.updateTimeout = null
120+
this.setVersionModalVisible({ isError: true })
121+
this.$nextTick(() => {
122+
this.showUpdateModal()
123+
})
124+
}, 180000)
114125
115126
this.initData()
116127
this.globalObj.apiSource = this.setting.apiSource
@@ -174,6 +185,10 @@ export default {
174185
body.removeEventListener('mouseleave', this.enableIgnoreMouseEvents)
175186
}
176187
},
188+
clearUpdateTimeout() {
189+
clearTimeout(this.updateTimeout)
190+
this.updateTimeout = null
191+
},
177192
}
178193
</script>
179194

src/renderer/store/actions.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ export default {
66
getVersionInfo() {
77
return new Promise((resolve, reject) => {
88
httpGet(`https://raw.githubusercontent.com/${author.name}/${name}/master/publish/version.json`, (err, resp, body) => {
9-
if (err) return reject(err)
9+
if (err) {
10+
return resolve({
11+
version: '0.0.0',
12+
desc: '<h3>版本获取失败</h3><ul><li>更新信息获取失败,可能是无法访问Github导致的,请手动检查更新!</li><li>检查方法:去设置-关于洛雪音乐打开<strong>开源地址</strong>或<strong>网盘地址</strong>查看<strong>版本号</strong>与当前版本对比是否最新</li></ul>',
13+
history: [],
14+
})
15+
}
1016
resolve(body)
1117
})
1218
})

0 commit comments

Comments
 (0)