Improve caching

This commit is contained in:
2026-07-21 18:45:59 +10:00
parent 92c61abcfe
commit 7d134ff8c9
24 changed files with 519 additions and 105 deletions

View File

@@ -13,6 +13,7 @@ declare global {
nativeVueHost?: {
onBack(callback: () => void): () => void
onForward?(callback: () => void): () => void
onMemoryPressure?(callback: () => void): () => void
}
}
}
@@ -25,9 +26,13 @@ export function createElectronRendererAdapter(): NativePlatformAdapter {
if (runtime.canGoBack.value) void runtime.pop()
})
const removeForward = window.nativeVueHost?.onForward?.(() => runtime.router.forward())
const removeMemoryPressure = window.nativeVueHost?.onMemoryPressure?.(() => {
runtime.trimCache({ reason: 'memory-pressure' })
})
return () => {
removeBack?.()
removeForward?.()
removeMemoryPressure?.()
}
},
}