mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-11 08:19:01 +08:00
fix(AppUpdater): simplify error logging and update version check logic (#8656)
* fix(AppUpdater): simplify error logging and update version check logic - Updated error logging to use a more concise format. - Changed logging messages for update events to be more consistent. - Modified the update check logic to return null when no update is available. - Enhanced the app initialization hook to include update availability in the state dispatch. * fix(useAppInit): simplify update state dispatch logic by removing update availability check
This commit is contained in:
parent
73b010af00
commit
bee933dd72
@ -31,17 +31,12 @@ export default class AppUpdater {
|
|||||||
}
|
}
|
||||||
|
|
||||||
autoUpdater.on('error', (error) => {
|
autoUpdater.on('error', (error) => {
|
||||||
// 简单记录错误信息和时间戳
|
logger.error('update error', error as Error)
|
||||||
logger.error('更新异常', {
|
|
||||||
message: error.message,
|
|
||||||
stack: error.stack,
|
|
||||||
time: new Date().toISOString()
|
|
||||||
})
|
|
||||||
mainWindow.webContents.send(IpcChannel.UpdateError, error)
|
mainWindow.webContents.send(IpcChannel.UpdateError, error)
|
||||||
})
|
})
|
||||||
|
|
||||||
autoUpdater.on('update-available', (releaseInfo: UpdateInfo) => {
|
autoUpdater.on('update-available', (releaseInfo: UpdateInfo) => {
|
||||||
logger.info('检测到新版本', releaseInfo)
|
logger.info('update available', releaseInfo)
|
||||||
mainWindow.webContents.send(IpcChannel.UpdateAvailable, releaseInfo)
|
mainWindow.webContents.send(IpcChannel.UpdateAvailable, releaseInfo)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -65,7 +60,7 @@ export default class AppUpdater {
|
|||||||
autoUpdater.on('update-downloaded', (releaseInfo: UpdateInfo) => {
|
autoUpdater.on('update-downloaded', (releaseInfo: UpdateInfo) => {
|
||||||
mainWindow.webContents.send(IpcChannel.UpdateDownloaded, releaseInfo)
|
mainWindow.webContents.send(IpcChannel.UpdateDownloaded, releaseInfo)
|
||||||
this.releaseInfo = releaseInfo
|
this.releaseInfo = releaseInfo
|
||||||
logger.info('下载完成', releaseInfo)
|
logger.info('update downloaded', releaseInfo)
|
||||||
})
|
})
|
||||||
|
|
||||||
if (isWin) {
|
if (isWin) {
|
||||||
@ -242,7 +237,7 @@ export default class AppUpdater {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
currentVersion: this.autoUpdater.currentVersion,
|
currentVersion: this.autoUpdater.currentVersion,
|
||||||
updateInfo: this.updateCheckResult?.updateInfo
|
updateInfo: this.updateCheckResult?.isUpdateAvailable ? this.updateCheckResult?.updateInfo : null
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error('Failed to check for update:', error as Error)
|
logger.error('Failed to check for update:', error as Error)
|
||||||
|
|||||||
@ -96,9 +96,6 @@ const AboutSettings: FC = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// don't support downgrade, so we only check if the version is different
|
|
||||||
const hasNewVersion = update?.info?.version && version ? update.info.version !== version : false
|
|
||||||
|
|
||||||
const currentChannelByVersion =
|
const currentChannelByVersion =
|
||||||
[
|
[
|
||||||
{ pattern: `-${UpgradeChannel.BETA}.`, channel: UpgradeChannel.BETA },
|
{ pattern: `-${UpgradeChannel.BETA}.`, channel: UpgradeChannel.BETA },
|
||||||
@ -267,7 +264,7 @@ const AboutSettings: FC = () => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</SettingGroup>
|
</SettingGroup>
|
||||||
{hasNewVersion && update.info && (
|
{update.info && update.available && (
|
||||||
<SettingGroup theme={theme}>
|
<SettingGroup theme={theme}>
|
||||||
<SettingRow>
|
<SettingRow>
|
||||||
<SettingRowTitle>
|
<SettingRowTitle>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user