diff --git a/frontend/src/stores/modules/system-update.ts b/frontend/src/stores/modules/system-update.ts index 3ce0f1d76..4484cd37a 100644 --- a/frontend/src/stores/modules/system-update.ts +++ b/frontend/src/stores/modules/system-update.ts @@ -19,6 +19,14 @@ const restartReadyTimeoutMs = 60_000 const restartProbeTimeoutMs = 2_000 const restartReadyPollIntervalMs = 500 +interface SystemUpdateEvent { + id: string + level: string + message: string + at: string + terminal?: boolean +} + export const useSystemUpdateStore = defineStore('system-update', () => { const version = shallowRef> | null>(null) const updateInfo = shallowRef> | null>(null) @@ -30,7 +38,7 @@ export const useSystemUpdateStore = defineStore('system-update', () => { const updateSuccess = shallowRef(false) const needRestart = shallowRef(false) const loadedOnce = shallowRef(false) - const updateLogs = ref([]) + const updateLogs = ref([]) const updateStreaming = shallowRef(false) const updateStreamError = shallowRef('') const restartTargetVersion = shallowRef('') @@ -72,7 +80,7 @@ export const useSystemUpdateStore = defineStore('system-update', () => { restartTargetVersion.value = '' } - function appendUpdateLog(log: any) { + function appendUpdateLog(log: SystemUpdateEvent) { const logs = updateLogs.value.filter(item => item.id !== log.id) updateLogs.value = [...logs, log].slice(-maxUpdateLogs) } @@ -97,7 +105,7 @@ export const useSystemUpdateStore = defineStore('system-update', () => { if (!message?.raw) return try { - const event = JSON.parse(message.raw) + const event = JSON.parse(message.raw) as SystemUpdateEvent appendUpdateLog(event) if (event.terminal) disconnectUpdateEvents()