Add prettier. Format.
This commit is contained in:
@@ -1,39 +1,48 @@
|
||||
import type { NativePlatformAdapter, NativeRouterRuntime } from '@native-vue-router/core'
|
||||
import type {
|
||||
NativePlatformAdapter,
|
||||
NativeRouterRuntime,
|
||||
} from "@native-vue-router/core";
|
||||
|
||||
export interface ElectronCommandLine {
|
||||
appendSwitch(name: string, value?: string): void
|
||||
appendSwitch(name: string, value?: string): void;
|
||||
}
|
||||
|
||||
export function disableElectronHistoryGestures(commandLine: ElectronCommandLine) {
|
||||
commandLine.appendSwitch('disable-features', 'OverscrollHistoryNavigation')
|
||||
export function disableElectronHistoryGestures(
|
||||
commandLine: ElectronCommandLine,
|
||||
) {
|
||||
commandLine.appendSwitch("disable-features", "OverscrollHistoryNavigation");
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
nativeVueHost?: {
|
||||
onBack(callback: () => void): () => void
|
||||
onForward?(callback: () => void): () => void
|
||||
onMemoryPressure?(callback: () => void): () => void
|
||||
}
|
||||
onBack(callback: () => void): () => void;
|
||||
onForward?(callback: () => void): () => void;
|
||||
onMemoryPressure?(callback: () => void): () => void;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function createElectronRendererAdapter(): NativePlatformAdapter {
|
||||
return {
|
||||
name: 'electron',
|
||||
name: "electron",
|
||||
install(runtime: NativeRouterRuntime) {
|
||||
const removeBack = window.nativeVueHost?.onBack(() => {
|
||||
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' })
|
||||
})
|
||||
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?.()
|
||||
}
|
||||
removeBack?.();
|
||||
removeForward?.();
|
||||
removeMemoryPressure?.();
|
||||
};
|
||||
},
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user