first commit

This commit is contained in:
2026-07-21 14:54:36 +10:00
commit e79c793b9c
134 changed files with 14427 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
{
"name": "@native-vue-router/electron",
"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" }
}

View File

@@ -0,0 +1,34 @@
import type { NativePlatformAdapter, NativeRouterRuntime } from '@native-vue-router/core'
export interface ElectronCommandLine {
appendSwitch(name: string, value?: string): void
}
export function disableElectronHistoryGestures(commandLine: ElectronCommandLine) {
commandLine.appendSwitch('disable-features', 'OverscrollHistoryNavigation')
}
declare global {
interface Window {
nativeVueHost?: {
onBack(callback: () => void): () => void
onForward?(callback: () => void): () => void
}
}
}
export function createElectronRendererAdapter(): NativePlatformAdapter {
return {
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())
return () => {
removeBack?.()
removeForward?.()
}
},
}
}

View File

@@ -0,0 +1,15 @@
{
"extends": "../../tsconfig.app.json",
"compilerOptions": {
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true,
"noEmit": false,
"rootDir": "src",
"outDir": "dist",
"tsBuildInfoFile": "../../node_modules/.tmp/electron.tsbuildinfo",
"baseUrl": ".",
"paths": { "@native-vue-router/core": ["../core/dist/index.d.ts"] }
},
"include": ["src/**/*.ts"]
}

View File

@@ -0,0 +1,10 @@
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'] },
},
})