fix(logs): preserve log data and eliminate blank flash on page navigation

Preserve SWR cache in onConnected to avoid replacing accumulated logs
with kernel buffer on reconnect. Add KeepAlive for the logs page so
its DOM stays mounted across route changes, removing the visible blank
window when navigating back.
This commit is contained in:
Tunglies
2026-04-03 13:13:57 +08:00
parent 51578c03b0
commit 36624aff49
3 changed files with 27 additions and 4 deletions
+6 -1
View File
@@ -101,7 +101,12 @@ export const useLogData = () => {
async onConnected() {
const logs = await getClashLogs()
if (isMounted()) {
next(null, clampLogs(filterLogsByLevel(logs, allowedTypes)))
next(null, (current) => {
if (!current || current.length === 0) {
return clampLogs(filterLogsByLevel(logs, allowedTypes))
}
return current
})
}
},
cleanup: clearFlushTimer,