检查更新失败时,返回数据添加action
parent
20735c7524
commit
dee5225ef9
|
@ -83,13 +83,13 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
|
||||||
if (error) {
|
if (error) {
|
||||||
log.error('检查更新失败:', error)
|
log.error('检查更新失败:', error)
|
||||||
const errorMsg = '检查更新失败:' + error
|
const errorMsg = '检查更新失败:' + error
|
||||||
win.webContents.send('update', { key: 'error', error: errorMsg })
|
win.webContents.send('update', { key: 'error', action: 'checkForUpdate', error: errorMsg })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (response && response.statusCode === 200) {
|
if (response && response.statusCode === 200) {
|
||||||
if (body == null || body.length < 2) {
|
if (body == null || body.length < 2) {
|
||||||
log.warn('检查更新失败,github API返回数据为空:', body)
|
log.warn('检查更新失败,github API返回数据为空:', body)
|
||||||
win.webContents.send('update', { key: 'error', error: '检查更新失败,github 返回数据为空' })
|
win.webContents.send('update', { key: 'error', action: 'checkForUpdate', error: '检查更新失败,github 返回数据为空' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,13 +98,14 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
|
||||||
try {
|
try {
|
||||||
data = JSON.parse(body)
|
data = JSON.parse(body)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.error(`检查更新失败,github API返回数据格式不正确, url: ${releasesApiUrl}, body: ${body}`)
|
log.error('检查更新失败,github API返回数据格式不正确:', body)
|
||||||
win.webContents.send('update', { key: 'error', error: '检查更新失败,github API返回数据格式不正确' })
|
win.webContents.send('update', { key: 'error', action: 'checkForUpdate', error: '检查更新失败,github API返回数据格式不正确' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof data !== 'object' || data.length === undefined) {
|
if (typeof data !== 'object' || data.length === undefined) {
|
||||||
win.webContents.send('update', { key: 'error', error: '检查更新失败,github API返回数据格式不正确' })
|
log.error('检查更新失败,github API返回数据不是数组:', body)
|
||||||
|
win.webContents.send('update', { key: 'error', action: 'checkForUpdate', error: '检查更新失败,github API返回数据不是数组' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue