feat(ui): type system update log events

Replace any[] updateLogs with SystemUpdateEvent (id, level, message, at,
terminal) so the log pipeline is type-checked.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
zyycn
2026-08-02 00:31:44 +08:00
co-authored by Claude Fable 5
parent 9768921ff7
commit 2dc670875a
+11 -3
View File
@@ -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<Awaited<ReturnType<typeof getSystemVersion>> | null>(null)
const updateInfo = shallowRef<Awaited<ReturnType<typeof getSystemUpdateDetail>> | 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<any[]>([])
const updateLogs = ref<SystemUpdateEvent[]>([])
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()