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

@@ -6,6 +6,8 @@ import type { NativePlatformAdapter, NativeRouterRuntime } from '@native-vue-rou
export interface CapacitorAdapterOptions {
exitAtRoot?: boolean
haptics?: boolean
/** Release inactive component trees when the native app backgrounds. Defaults to true. */
trimCacheOnPause?: boolean
deepLinkPath?: (url: URL) => string
}
@@ -31,7 +33,10 @@ export function createCapacitorAdapter(options: CapacitorAdapterOptions = {}): N
const path = options.deepLinkPath?.(parsed) ?? `${parsed.pathname}${parsed.search}${parsed.hash}`
void runtime.push(path || '/')
}),
App.addListener('pause', () => void runtime.cancelInteractive()),
App.addListener('pause', () => {
void runtime.cancelInteractive()
if (options.trimCacheOnPause !== false) runtime.trimCache({ reason: 'memory-pressure' })
}),
])
const launch = await App.getLaunchUrl()
if (launch?.url) {