新增版本更新超时功能
parent
a035a2525a
commit
4cbbf2ac81
|
@ -37,6 +37,7 @@ export default {
|
||||||
globalObj: {
|
globalObj: {
|
||||||
apiSource: 'messoer',
|
apiSource: 'messoer',
|
||||||
},
|
},
|
||||||
|
updateTimeout: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -98,19 +99,29 @@ export default {
|
||||||
})
|
})
|
||||||
rendererOn('update-error', () => {
|
rendererOn('update-error', () => {
|
||||||
this.setVersionModalVisible({ isError: true })
|
this.setVersionModalVisible({ isError: true })
|
||||||
|
this.clearUpdateTimeout()
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.showUpdateModal()
|
this.showUpdateModal()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
rendererOn('update-downloaded', () => {
|
rendererOn('update-downloaded', () => {
|
||||||
|
this.clearUpdateTimeout()
|
||||||
this.showUpdateModal()
|
this.showUpdateModal()
|
||||||
})
|
})
|
||||||
rendererOn('update-not-available', () => {
|
rendererOn('update-not-available', () => {
|
||||||
if (this.setting.ignoreVersion) this.setSetting(Object.assign({}, this.setting, { ignoreVersion: null }))
|
if (this.setting.ignoreVersion) this.setSetting(Object.assign({}, this.setting, { ignoreVersion: null }))
|
||||||
|
this.clearUpdateTimeout()
|
||||||
this.setNewVersion({
|
this.setNewVersion({
|
||||||
version: this.version.version,
|
version: this.version.version,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
this.updateTimeout = setTimeout(() => {
|
||||||
|
this.updateTimeout = null
|
||||||
|
this.setVersionModalVisible({ isError: true })
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.showUpdateModal()
|
||||||
|
})
|
||||||
|
}, 180000)
|
||||||
|
|
||||||
this.initData()
|
this.initData()
|
||||||
this.globalObj.apiSource = this.setting.apiSource
|
this.globalObj.apiSource = this.setting.apiSource
|
||||||
|
@ -174,6 +185,10 @@ export default {
|
||||||
body.removeEventListener('mouseleave', this.enableIgnoreMouseEvents)
|
body.removeEventListener('mouseleave', this.enableIgnoreMouseEvents)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
clearUpdateTimeout() {
|
||||||
|
clearTimeout(this.updateTimeout)
|
||||||
|
this.updateTimeout = null
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,13 @@ export default {
|
||||||
getVersionInfo() {
|
getVersionInfo() {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
httpGet(`https://raw.githubusercontent.com/${author.name}/${name}/master/publish/version.json`, (err, resp, body) => {
|
httpGet(`https://raw.githubusercontent.com/${author.name}/${name}/master/publish/version.json`, (err, resp, body) => {
|
||||||
if (err) return reject(err)
|
if (err) {
|
||||||
|
return resolve({
|
||||||
|
version: '0.0.0',
|
||||||
|
desc: '<h3>版本获取失败</h3><ul><li>更新信息获取失败,可能是无法访问Github导致的,请手动检查更新!</li><li>检查方法:去设置-关于洛雪音乐打开<strong>开源地址</strong>或<strong>网盘地址</strong>查看<strong>版本号</strong>与当前版本对比是否最新</li></ul>',
|
||||||
|
history: [],
|
||||||
|
})
|
||||||
|
}
|
||||||
resolve(body)
|
resolve(body)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue