Add prettier. Format.

This commit is contained in:
2026-07-22 02:12:05 +00:00
parent d28b09dc21
commit 18baa96848
45 changed files with 4520 additions and 2613 deletions

View File

@@ -3,8 +3,19 @@
"version": "0.1.0",
"type": "module",
"license": "MIT",
"files": ["dist"],
"scripts": { "build": "vite build --config vite.config.ts && vue-tsc -p tsconfig.json --emitDeclarationOnly" },
"exports": { ".": { "types": "./dist/index.d.ts", "import": "./dist/index.js" } },
"peerDependencies": { "@native-vue-router/core": "^0.1.0" }
"files": [
"dist"
],
"scripts": {
"build": "vite build --config vite.config.ts && vue-tsc -p tsconfig.json --emitDeclarationOnly"
},
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"peerDependencies": {
"@native-vue-router/core": "^0.1.0"
}
}

View File

@@ -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?.();
};
},
}
};
}

View File

@@ -1,10 +1,15 @@
import { defineConfig } from 'vite'
import { resolve } from 'node:path'
import { defineConfig } from "vite";
import { resolve } from "node:path";
export default defineConfig({
build: {
outDir: 'dist', emptyOutDir: true,
lib: { entry: resolve(__dirname, 'src/index.ts'), formats: ['es'], fileName: 'index' },
rollupOptions: { external: ['@native-vue-router/core'] },
outDir: "dist",
emptyOutDir: true,
lib: {
entry: resolve(__dirname, "src/index.ts"),
formats: ["es"],
fileName: "index",
},
rollupOptions: { external: ["@native-vue-router/core"] },
},
})
});