小调整。

pull/303/head
王良 2024-04-23 16:23:14 +08:00
parent 1bd12d3b6e
commit ec1b90882a
2 changed files with 6 additions and 7 deletions

View File

@ -78,7 +78,6 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
// 检查更新 // 检查更新
const releasesApiUrl = 'https://api.github.com/repos/docmirror/dev-sidecar/releases' const releasesApiUrl = 'https://api.github.com/repos/docmirror/dev-sidecar/releases'
async function checkForUpdatesFromGitHub () { async function checkForUpdatesFromGitHub () {
log.info('DevSidecar.api.config.app.skipPreRelease:', DevSidecar.api.config.get().app.skipPreRelease)
request(releasesApiUrl, { headers: { 'User-Agent': 'DS/' + pkg.version } }, (error, response, body) => { request(releasesApiUrl, { headers: { 'User-Agent': 'DS/' + pkg.version } }, (error, response, body) => {
try { try {
if (error) { if (error) {
@ -109,7 +108,7 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
return return
} }
log.info('github api返回的release数据', JSON.stringify(data, null, '\t')) // log.info('github api返回的release数据', JSON.stringify(data, null, '\t'))
// 检查更新 // 检查更新
for (let i = 0; i < data.length; i++) { for (let i = 0; i < data.length; i++) {
@ -118,7 +117,7 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
if (!versionData.assets || versionData.assets.length === 0) { if (!versionData.assets || versionData.assets.length === 0) {
continue // 跳过空版本,即上传过安装包 continue // 跳过空版本,即上传过安装包
} }
if (DevSidecar.api.config.app.skipPreRelease && versionData.name.indexOf('Pre-release') >= 0) { if (DevSidecar.api.config.get().app.skipPreRelease && versionData.name.indexOf('Pre-release') >= 0) {
continue // 跳过预发布版本 continue // 跳过预发布版本
} }
@ -134,9 +133,7 @@ function updateHandle (app, api, win, beforeQuit, quit, log) {
key: 'available', key: 'available',
value: { value: {
version: versionData.tag_name, version: versionData.tag_name,
releaseNotes: [ releaseNotes: '发布公告:' + (versionData.html_url || ('https://github.com/docmirror/dev-sidecar/releases/tag/' + versionData.tag_name))
'请查看发布公告:' + versionData.html_url
]
} }
}) })
} else { } else {

View File

@ -68,6 +68,7 @@ function install (app, api) {
title: '暂不提供自动升级', title: '暂不提供自动升级',
cancelText: '取消', cancelText: '取消',
okText: '确定', okText: '确定',
width: 420,
content: h => { content: h => {
function openGithubUrl () { function openGithubUrl () {
api.ipc.openExternal('https://github.com/docmirror/dev-sidecar/releases') api.ipc.openExternal('https://github.com/docmirror/dev-sidecar/releases')
@ -129,10 +130,11 @@ function install (app, api) {
title: '发现新版本:' + value.version, title: '发现新版本:' + value.version,
cancelText: '暂不升级', cancelText: '暂不升级',
okText: '升级', okText: '升级',
width: 710,
content: h => { content: h => {
if (value.releaseNotes) { if (value.releaseNotes) {
if (typeof value.releaseNotes === 'string') { if (typeof value.releaseNotes === 'string') {
return <div><div>更新内容</div><div>{value.releaseNotes}</div></div> return <div>{value.releaseNotes}</div>
} else { } else {
const notes = [] const notes = []
for (const note of value.releaseNotes) { for (const note of value.releaseNotes) {