Improve caching
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user