diff --git a/README.md b/README.md
index e734c46..9e0e030 100644
--- a/README.md
+++ b/README.md
@@ -83,7 +83,7 @@ Mocking up web app with Vitesse(speed)
### Plugins
- [Vue Router](https://github.com/vuejs/router)
- - [`vite-plugin-pages`](https://github.com/hannoeru/vite-plugin-pages) - file system based routing
+ - [`unplugin-vue-router`](https://github.com/posva/unplugin-vue-router) - file system based routing
- [`vite-plugin-vue-layouts`](https://github.com/JohnCampionJr/vite-plugin-vue-layouts) - layouts for pages
- [Pinia](https://pinia.vuejs.org) - Intuitive, type safe, light and flexible Store for Vue using the composition api
- [`unplugin-vue-components`](https://github.com/antfu/unplugin-vue-components) - components auto import
diff --git a/README.zh-CN.md b/README.zh-CN.md
index ded6bad..334ed02 100644
--- a/README.zh-CN.md
+++ b/README.zh-CN.md
@@ -78,7 +78,7 @@
### 插件
- [Vue Router](https://github.com/vuejs/router)
- - [`vite-plugin-pages`](https://github.com/hannoeru/vite-plugin-pages) - 以文件系统为基础的路由
+ - [`unplugin-vue-router`](https://github.com/posva/unplugin-vue-router) - 以文件系统为基础的路由
- [`vite-plugin-vue-layouts`](https://github.com/JohnCampionJr/vite-plugin-vue-layouts) - 页面布局系统
- [Pinia](https://pinia.vuejs.org) - 直接的, 类型安全的, 使用 Composition API 的轻便灵活的 Vue 状态管理
- [`unplugin-vue-components`](https://github.com/antfu/unplugin-vue-components) - 自动加载组件
diff --git a/package.json b/package.json
index 4910b49..bdbc1ef 100644
--- a/package.json
+++ b/package.json
@@ -59,10 +59,10 @@
"unplugin-vue-components": "^0.25.2",
"unplugin-vue-macros": "^2.6.2",
"unplugin-vue-markdown": "^0.24.3",
+ "unplugin-vue-router": "^0.7.0",
"vite": "^5.0.0-beta.15",
"vite-bundle-visualizer": "^0.10.0",
"vite-plugin-inspect": "^0.7.41",
- "vite-plugin-pages": "^0.31.0",
"vite-plugin-pwa": "^0.16.6",
"vite-plugin-vue-devtools": "^1.0.0-rc.5",
"vite-plugin-vue-layouts": "^0.8.0",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 718a6a1..d67251b 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -127,6 +127,9 @@ devDependencies:
unplugin-vue-markdown:
specifier: ^0.24.3
version: 0.24.3(rollup@4.2.0)(vite@5.0.0-beta.15)
+ unplugin-vue-router:
+ specifier: ^0.7.0
+ version: 0.7.0(rollup@4.2.0)(vue-router@4.2.5)(vue@3.3.7)
vite:
specifier: ^5.0.0-beta.15
version: 5.0.0-beta.15(@types/node@20.2.3)
@@ -136,9 +139,6 @@ devDependencies:
vite-plugin-inspect:
specifier: ^0.7.41
version: 0.7.41(rollup@4.2.0)(vite@5.0.0-beta.15)
- vite-plugin-pages:
- specifier: ^0.31.0
- version: 0.31.0(vite@5.0.0-beta.15)
vite-plugin-pwa:
specifier: ^0.16.6
version: 0.16.6(vite@5.0.0-beta.15)(workbox-build@7.0.0)(workbox-window@7.0.0)
@@ -2630,12 +2630,6 @@ packages:
resolution: {integrity: sha512-mEo1sAde+UCE6b2hxn332f1g1E8WfYRu6p5SvTKr2ZKC1f7gFJXk4h5PyGP9Dt6gCaG8y8XhwnXWC6Iy2cmBng==}
dev: true
- /@types/debug@4.1.8:
- resolution: {integrity: sha512-/vPO1EPOs306Cvhwv7KfVfYvOJqA/S/AXjaHQiJboCZzcNDb+TIJFN9/2C9DZ//ijSKWioNyUxD792QmDJ+HKQ==}
- dependencies:
- '@types/ms': 0.7.31
- dev: true
-
/@types/estree@0.0.39:
resolution: {integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==}
dev: true
@@ -2687,10 +2681,6 @@ packages:
resolution: {integrity: sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA==}
dev: true
- /@types/ms@0.7.31:
- resolution: {integrity: sha512-iiUgKzV9AuaEkZqkOLDIvlQiL6ltuZd9tGcW3gwpnX8JbuiuhFlEGmmFXEXkN50Cvq7Os88IY2v0dkDqXYWVgA==}
- dev: true
-
/@types/node@18.17.17:
resolution: {integrity: sha512-cOxcXsQ2sxiwkykdJqvyFS+MLQPLvIdwh5l6gNg8qF6s+C7XSkEWOZjK+XhUZd+mYvHV/180g2cnCcIl4l06Pw==}
dev: true
@@ -5013,29 +5003,6 @@ packages:
type-detect: 4.0.8
dev: true
- /deep-equal@2.2.1:
- resolution: {integrity: sha512-lKdkdV6EOGoVn65XaOsPdH4rMxTZOnmFyuIkMjM1i5HHCbfjC97dawgTAy0deYNfuqUqW+Q5VrVaQYtUpSd6yQ==}
- dependencies:
- array-buffer-byte-length: 1.0.0
- call-bind: 1.0.2
- es-get-iterator: 1.1.3
- get-intrinsic: 1.2.1
- is-arguments: 1.1.1
- is-array-buffer: 3.0.2
- is-date-object: 1.0.5
- is-regex: 1.1.4
- is-shared-array-buffer: 1.0.2
- isarray: 2.0.5
- object-is: 1.1.5
- object-keys: 1.1.1
- object.assign: 4.1.4
- regexp.prototype.flags: 1.5.1
- side-channel: 1.0.4
- which-boxed-primitive: 1.0.2
- which-collection: 1.0.1
- which-typed-array: 1.1.11
- dev: true
-
/deep-is@0.1.4:
resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==}
dev: true
@@ -5351,20 +5318,6 @@ packages:
which-typed-array: 1.1.11
dev: true
- /es-get-iterator@1.1.3:
- resolution: {integrity: sha512-sPZmqHBe6JIiTfN5q2pEi//TwxmAFHwj/XEuYjTuse78i8KxaqMTTzxPoFKuzRpDpTJ+0NAbpfenkmH2rePtuw==}
- dependencies:
- call-bind: 1.0.2
- get-intrinsic: 1.2.1
- has-symbols: 1.0.3
- is-arguments: 1.1.1
- is-map: 2.0.2
- is-set: 2.0.2
- is-string: 1.0.7
- isarray: 2.0.5
- stop-iteration-iterator: 1.0.0
- dev: true
-
/es-set-tostringtag@2.0.1:
resolution: {integrity: sha512-g3OMbtlwY3QewlqAiMLI47KywjWZoEytKr8pf6iTC8uJq5bIAH52Z9pnQ8pVL6whrCto53JZDuUIsifGeLorTg==}
engines: {node: '>= 0.4'}
@@ -5871,13 +5824,6 @@ packages:
eslint-visitor-keys: 3.4.3
dev: true
- /esprima-extract-comments@1.1.0:
- resolution: {integrity: sha512-sBQUnvJwpeE9QnPrxh7dpI/dp67erYG4WXEAreAMoelPRpMR7NWb4YtwRPn9b+H1uLQKl/qS8WYmyaljTpjIsw==}
- engines: {node: '>=4'}
- dependencies:
- esprima: 4.0.1
- dev: true
-
/esprima@4.0.1:
resolution: {integrity: sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==}
engines: {node: '>=4'}
@@ -6045,14 +5991,6 @@ packages:
resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==}
dev: true
- /extract-comments@1.1.0:
- resolution: {integrity: sha512-dzbZV2AdSSVW/4E7Ti5hZdHWbA+Z80RJsJhr5uiL10oyjl/gy7/o+HI1HwK4/WSZhlq4SNKU3oUzXlM13Qx02Q==}
- engines: {node: '>=6'}
- dependencies:
- esprima-extract-comments: 1.1.0
- parse-code-context: 1.0.0
- dev: true
-
/extract-zip@2.0.1(supports-color@8.1.1):
resolution: {integrity: sha512-GDhU9ntwuKyGXdZBUgTIe+vXnWj0fppUEtMDL0+idd5Sta8TGpHssn/eusA9mrPr9qNDym6SxAYZjNvCn/9RBg==}
engines: {node: '>= 10.17.0'}
@@ -6930,14 +6868,6 @@ packages:
is-decimal: 1.0.4
dev: true
- /is-arguments@1.1.1:
- resolution: {integrity: sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==}
- engines: {node: '>= 0.4'}
- dependencies:
- call-bind: 1.0.2
- has-tostringtag: 1.0.0
- dev: true
-
/is-array-buffer@3.0.2:
resolution: {integrity: sha512-y+FyyR/w8vfIRq4eQcM1EYgSTnmHXPqaF+IgzgraytCFq5Xh8lllDVmAZolPJiZttZLeFSINPYMaEJ7/vWUa1w==}
dependencies:
@@ -7077,10 +7007,6 @@ packages:
resolution: {integrity: sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==}
dev: true
- /is-map@2.0.2:
- resolution: {integrity: sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg==}
- dev: true
-
/is-module@1.0.0:
resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==}
dev: true
@@ -7133,10 +7059,6 @@ packages:
engines: {node: '>=0.10.0'}
dev: true
- /is-set@2.0.2:
- resolution: {integrity: sha512-+2cnTEZeY5z/iXGbLhPrOAaK/Mau5k5eXq9j14CpRTftq0pAJu2MwVRSZhyZWBzx3o6X795Lz6Bpb6R0GKf37g==}
- dev: true
-
/is-shared-array-buffer@1.0.2:
resolution: {integrity: sha512-sqN2UDu1/0y6uvXyStCOzyhAjCSlHceFoMKJW8W9EU9cvic/QdsZ0kEU93HEy3IUEFZIiH/3w+AH/UQbPHNdhA==}
dependencies:
@@ -7183,23 +7105,12 @@ packages:
engines: {node: '>=10'}
dev: true
- /is-weakmap@2.0.1:
- resolution: {integrity: sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA==}
- dev: true
-
/is-weakref@1.0.2:
resolution: {integrity: sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==}
dependencies:
call-bind: 1.0.2
dev: true
- /is-weakset@2.0.2:
- resolution: {integrity: sha512-t2yVvttHkQktwnNNmBQ98AhENLdPUTDTE21uPqAQ0ARwQfGeQKRVS0NNurH7bTf7RrvcVn1OOge45CnBeHCSmg==}
- dependencies:
- call-bind: 1.0.2
- get-intrinsic: 1.2.1
- dev: true
-
/is-wsl@2.2.0:
resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==}
engines: {node: '>=8'}
@@ -8249,14 +8160,6 @@ packages:
resolution: {integrity: sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==}
dev: true
- /object-is@1.1.5:
- resolution: {integrity: sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==}
- engines: {node: '>= 0.4'}
- dependencies:
- call-bind: 1.0.2
- define-properties: 1.2.0
- dev: true
-
/object-keys@1.1.1:
resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==}
engines: {node: '>= 0.4'}
@@ -8460,11 +8363,6 @@ packages:
callsites: 3.1.0
dev: true
- /parse-code-context@1.0.0:
- resolution: {integrity: sha512-OZQaqKaQnR21iqhlnPfVisFjBWjhnMl5J9MgbP8xC+EwoVqbXrq78lp+9Zb3ahmLzrIX5Us/qbvBnaS3hkH6OA==}
- engines: {node: '>=6'}
- dev: true
-
/parse-entities@2.0.0:
resolution: {integrity: sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==}
dependencies:
@@ -9592,13 +9490,6 @@ packages:
resolution: {integrity: sha512-Rz6yejtVyWnVjC1RFvNmYL10kgjC49EOghxWn0RFqlCHGFpQx+Xe7yW3I4ceK1SGrWIGMjD5Kbue8W/udkbMJg==}
dev: true
- /stop-iteration-iterator@1.0.0:
- resolution: {integrity: sha512-iCGQj+0l0HOdZ2AEeBADlsRC+vsnDsZsbdSiH1yNSjcfKM7fdpCMfqAL/dwF5BLiw/XhRft/Wax6zQbhq2BcjQ==}
- engines: {node: '>= 0.4'}
- dependencies:
- internal-slot: 1.0.5
- dev: true
-
/string-argv@0.3.2:
resolution: {integrity: sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==}
engines: {node: '>=0.6.19'}
@@ -10436,6 +10327,33 @@ packages:
- rollup
dev: true
+ /unplugin-vue-router@0.7.0(rollup@4.2.0)(vue-router@4.2.5)(vue@3.3.7):
+ resolution: {integrity: sha512-ddRreGq0t5vlSB7OMy4e4cfU1w2AwBQCwmvW3oP/0IHQiokzbx4hd3TpwBu3eIAFVuhX2cwNQwp1U32UybTVCw==}
+ peerDependencies:
+ vue-router: ^4.1.0
+ peerDependenciesMeta:
+ vue-router:
+ optional: true
+ dependencies:
+ '@babel/types': 7.22.19
+ '@rollup/pluginutils': 5.0.5(rollup@4.2.0)
+ '@vue-macros/common': 1.8.0(rollup@4.2.0)(vue@3.3.7)
+ ast-walker-scope: 0.5.0(rollup@4.2.0)
+ chokidar: 3.5.3
+ fast-glob: 3.3.1
+ json5: 2.2.3
+ local-pkg: 0.4.3
+ mlly: 1.4.2
+ pathe: 1.1.1
+ scule: 1.0.0
+ unplugin: 1.5.0
+ vue-router: 4.2.5(vue@3.3.7)
+ yaml: 2.3.3
+ transitivePeerDependencies:
+ - rollup
+ - vue
+ dev: true
+
/unplugin@1.5.0:
resolution: {integrity: sha512-9ZdRwbh/4gcm1JTOkp9lAkIDrtOyOxgHmY7cjuwI8L/2RTikMcVG25GsZwNAgRuap3iDw2jeq7eoqtAsz5rW3A==}
dependencies:
@@ -10611,29 +10529,6 @@ packages:
- supports-color
dev: true
- /vite-plugin-pages@0.31.0(vite@5.0.0-beta.15):
- resolution: {integrity: sha512-fw3onBfVTXQI7rOzAbSZhmfwvk50+3qNnGZpERjmD93c8nEjrGLyd53eFXYMxcJV4KA1vzi4qIHt2+6tS4dEMw==}
- peerDependencies:
- '@vue/compiler-sfc': ^2.7.0 || ^3.0.0
- vite: ^2.0.0 || ^3.0.0-0 || ^4.0.0
- peerDependenciesMeta:
- '@vue/compiler-sfc':
- optional: true
- dependencies:
- '@types/debug': 4.1.8
- debug: 4.3.4(supports-color@8.1.1)
- deep-equal: 2.2.1
- extract-comments: 1.1.0
- fast-glob: 3.3.1
- json5: 2.2.3
- local-pkg: 0.4.3
- picocolors: 1.0.0
- vite: 5.0.0-beta.15(@types/node@20.2.3)
- yaml: 2.3.3
- transitivePeerDependencies:
- - supports-color
- dev: true
-
/vite-plugin-pwa@0.16.6(vite@5.0.0-beta.15)(workbox-build@7.0.0)(workbox-window@7.0.0):
resolution: {integrity: sha512-bQPDOWvhPMwydMoWqohXvIzvrq4X8iuCF+q95qEiaM4yC0ybViGKWMnWcpWp0vcnoLk7QvxHDlK65KUZvqB3Sg==}
engines: {node: '>=16.0.0'}
@@ -11036,15 +10931,6 @@ packages:
is-symbol: 1.0.4
dev: true
- /which-collection@1.0.1:
- resolution: {integrity: sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A==}
- dependencies:
- is-map: 2.0.2
- is-set: 2.0.2
- is-weakmap: 2.0.1
- is-weakset: 2.0.2
- dev: true
-
/which-typed-array@1.1.11:
resolution: {integrity: sha512-qe9UWWpkeG5yzZ0tNYxDmd7vo58HDBc39mZ0xWWpolAGADdFOzkfamWLDxkOWcvHQKVmdTyQdLD4NOfjLWTKew==}
engines: {node: '>= 0.4'}
diff --git a/src/auto-imports.d.ts b/src/auto-imports.d.ts
index fbff4ef..45eafa6 100644
--- a/src/auto-imports.d.ts
+++ b/src/auto-imports.d.ts
@@ -29,6 +29,8 @@ declare global {
const debouncedWatch: typeof import('@vueuse/core')['debouncedWatch']
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
const defineComponent: typeof import('vue')['defineComponent']
+ const defineLoader: typeof import('vue-router/auto')['defineLoader']
+ const definePage: typeof import('unplugin-vue-router/runtime')['_definePage']
const eagerComputed: typeof import('@vueuse/core')['eagerComputed']
const effectScope: typeof import('vue')['effectScope']
const extendRef: typeof import('@vueuse/core')['extendRef']
@@ -49,8 +51,8 @@ declare global {
const nextTick: typeof import('vue')['nextTick']
const onActivated: typeof import('vue')['onActivated']
const onBeforeMount: typeof import('vue')['onBeforeMount']
- const onBeforeRouteLeave: typeof import('vue-router')['onBeforeRouteLeave']
- const onBeforeRouteUpdate: typeof import('vue-router')['onBeforeRouteUpdate']
+ const onBeforeRouteLeave: typeof import('vue-router/auto')['onBeforeRouteLeave']
+ const onBeforeRouteUpdate: typeof import('vue-router/auto')['onBeforeRouteUpdate']
const onBeforeUnmount: typeof import('vue')['onBeforeUnmount']
const onBeforeUpdate: typeof import('vue')['onBeforeUpdate']
const onClickOutside: typeof import('@vueuse/core')['onClickOutside']
@@ -185,7 +187,7 @@ declare global {
const useIntervalFn: typeof import('@vueuse/core')['useIntervalFn']
const useKeyModifier: typeof import('@vueuse/core')['useKeyModifier']
const useLastChanged: typeof import('@vueuse/core')['useLastChanged']
- const useLink: typeof import('vue-router')['useLink']
+ const useLink: typeof import('vue-router/auto')['useLink']
const useLocalStorage: typeof import('@vueuse/core')['useLocalStorage']
const useMagicKeys: typeof import('@vueuse/core')['useMagicKeys']
const useManualRefHistory: typeof import('@vueuse/core')['useManualRefHistory']
@@ -221,8 +223,8 @@ declare global {
const useRafFn: typeof import('@vueuse/core')['useRafFn']
const useRefHistory: typeof import('@vueuse/core')['useRefHistory']
const useResizeObserver: typeof import('@vueuse/core')['useResizeObserver']
- const useRoute: typeof import('vue-router')['useRoute']
- const useRouter: typeof import('vue-router')['useRouter']
+ const useRoute: typeof import('vue-router/auto')['useRoute']
+ const useRouter: typeof import('vue-router/auto')['useRouter']
const useScreenOrientation: typeof import('@vueuse/core')['useScreenOrientation']
const useScreenSafeArea: typeof import('@vueuse/core')['useScreenSafeArea']
const useScriptTag: typeof import('@vueuse/core')['useScriptTag']
@@ -323,6 +325,8 @@ declare module 'vue' {
readonly debouncedWatch: UnwrapRef
readonly defineAsyncComponent: UnwrapRef
readonly defineComponent: UnwrapRef
+ readonly defineLoader: UnwrapRef
+ readonly definePage: UnwrapRef
readonly eagerComputed: UnwrapRef
readonly effectScope: UnwrapRef
readonly extendRef: UnwrapRef
@@ -343,8 +347,8 @@ declare module 'vue' {
readonly nextTick: UnwrapRef
readonly onActivated: UnwrapRef
readonly onBeforeMount: UnwrapRef
- readonly onBeforeRouteLeave: UnwrapRef
- readonly onBeforeRouteUpdate: UnwrapRef
+ readonly onBeforeRouteLeave: UnwrapRef
+ readonly onBeforeRouteUpdate: UnwrapRef
readonly onBeforeUnmount: UnwrapRef
readonly onBeforeUpdate: UnwrapRef
readonly onClickOutside: UnwrapRef
@@ -479,7 +483,7 @@ declare module 'vue' {
readonly useIntervalFn: UnwrapRef
readonly useKeyModifier: UnwrapRef
readonly useLastChanged: UnwrapRef
- readonly useLink: UnwrapRef
+ readonly useLink: UnwrapRef
readonly useLocalStorage: UnwrapRef
readonly useMagicKeys: UnwrapRef
readonly useManualRefHistory: UnwrapRef
@@ -515,8 +519,8 @@ declare module 'vue' {
readonly useRafFn: UnwrapRef
readonly useRefHistory: UnwrapRef
readonly useResizeObserver: UnwrapRef
- readonly useRoute: UnwrapRef
- readonly useRouter: UnwrapRef
+ readonly useRoute: UnwrapRef
+ readonly useRouter: UnwrapRef
readonly useScreenOrientation: UnwrapRef
readonly useScreenSafeArea: UnwrapRef
readonly useScriptTag: UnwrapRef
@@ -611,6 +615,8 @@ declare module '@vue/runtime-core' {
readonly debouncedWatch: UnwrapRef
readonly defineAsyncComponent: UnwrapRef
readonly defineComponent: UnwrapRef
+ readonly defineLoader: UnwrapRef
+ readonly definePage: UnwrapRef
readonly eagerComputed: UnwrapRef
readonly effectScope: UnwrapRef
readonly extendRef: UnwrapRef
@@ -631,8 +637,8 @@ declare module '@vue/runtime-core' {
readonly nextTick: UnwrapRef
readonly onActivated: UnwrapRef
readonly onBeforeMount: UnwrapRef
- readonly onBeforeRouteLeave: UnwrapRef
- readonly onBeforeRouteUpdate: UnwrapRef
+ readonly onBeforeRouteLeave: UnwrapRef
+ readonly onBeforeRouteUpdate: UnwrapRef
readonly onBeforeUnmount: UnwrapRef
readonly onBeforeUpdate: UnwrapRef
readonly onClickOutside: UnwrapRef
@@ -767,7 +773,7 @@ declare module '@vue/runtime-core' {
readonly useIntervalFn: UnwrapRef
readonly useKeyModifier: UnwrapRef
readonly useLastChanged: UnwrapRef
- readonly useLink: UnwrapRef
+ readonly useLink: UnwrapRef
readonly useLocalStorage: UnwrapRef
readonly useMagicKeys: UnwrapRef
readonly useManualRefHistory: UnwrapRef
@@ -803,8 +809,8 @@ declare module '@vue/runtime-core' {
readonly useRafFn: UnwrapRef
readonly useRefHistory: UnwrapRef
readonly useResizeObserver: UnwrapRef
- readonly useRoute: UnwrapRef
- readonly useRouter: UnwrapRef
+ readonly useRoute: UnwrapRef
+ readonly useRouter: UnwrapRef
readonly useScreenOrientation: UnwrapRef
readonly useScreenSafeArea: UnwrapRef
readonly useScriptTag: UnwrapRef
diff --git a/src/layouts/README.md b/src/layouts/README.md
index 6ca905c..762d85e 100644
--- a/src/layouts/README.md
+++ b/src/layouts/README.md
@@ -4,7 +4,7 @@ Vue components in this dir are used as layouts.
By default, `default.vue` will be used unless an alternative is specified in the route meta.
-With [`vite-plugin-pages`](https://github.com/hannoeru/vite-plugin-pages) and [`vite-plugin-vue-layouts`](https://github.com/JohnCampionJr/vite-plugin-vue-layouts), you can specify the layout in the page's SFCs like this:
+With [`unplugin-vue-router`](https://github.com/posva/unplugin-vue-router) and [`vite-plugin-vue-layouts`](https://github.com/JohnCampionJr/vite-plugin-vue-layouts), you can specify the layout in the page's SFCs like this:
```html
diff --git a/src/main.ts b/src/main.ts
index 6c55815..464d157 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -2,20 +2,23 @@ import { ViteSSG } from 'vite-ssg'
import { setupLayouts } from 'virtual:generated-layouts'
// import Previewer from 'virtual:vue-component-preview'
+import { routes } from 'vue-router/auto/routes'
import App from './App.vue'
import type { UserModule } from './types'
-import generatedRoutes from '~pages'
import '@unocss/reset/tailwind.css'
import './styles/main.css'
import 'uno.css'
-const routes = setupLayouts(generatedRoutes)
+// const routes = setupLayouts(generatedRoutes)
// https://github.com/antfu/vite-ssg
export const createApp = ViteSSG(
App,
- { routes, base: import.meta.env.BASE_URL },
+ {
+ routes: setupLayouts(routes),
+ base: import.meta.env.BASE_URL,
+ },
(ctx) => {
// install all modules under `modules/`
Object.values(import.meta.glob<{ install: UserModule }>('./modules/*.ts', { eager: true }))
diff --git a/src/pages/README.md b/src/pages/README.md
index 929b7c9..26b343d 100644
--- a/src/pages/README.md
+++ b/src/pages/README.md
@@ -1,7 +1,7 @@
## File-based Routing
Routes will be auto-generated for Vue files in this dir with the same file structure.
-Check out [`vite-plugin-pages`](https://github.com/hannoeru/vite-plugin-pages) for more details.
+Check out [`unplugin-vue-router`](https://github.com/posva/unplugin-vue-router) for more details.
### Path Aliasing
diff --git a/tsconfig.json b/tsconfig.json
index e037b7e..ffb75af 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -14,7 +14,6 @@
"vitest",
"vite/client",
"vue/ref-macros",
- "vite-plugin-pages/client",
"vite-plugin-vue-layouts/client",
"vite-plugin-pwa/client",
"unplugin-vue-macros/macros-global"
diff --git a/typed-router.d.ts b/typed-router.d.ts
new file mode 100644
index 0000000..37dda6b
--- /dev/null
+++ b/typed-router.d.ts
@@ -0,0 +1,145 @@
+/* eslint-disable */
+/* prettier-ignore */
+// @ts-nocheck
+// Generated by unplugin-vue-router. ‼️ DO NOT MODIFY THIS FILE ‼️
+// It's recommended to commit this file.
+// Make sure to add this file to your tsconfig.json file as an "includes" or "files" entry.
+
+///
+
+import type {
+ // type safe route locations
+ RouteLocationTypedList,
+ RouteLocationResolvedTypedList,
+ RouteLocationNormalizedTypedList,
+ RouteLocationNormalizedLoadedTypedList,
+ RouteLocationAsString,
+ RouteLocationAsRelativeTypedList,
+ RouteLocationAsPathTypedList,
+
+ // helper types
+ // route definitions
+ RouteRecordInfo,
+ ParamValue,
+ ParamValueOneOrMore,
+ ParamValueZeroOrMore,
+ ParamValueZeroOrOne,
+
+ // vue-router extensions
+ _RouterTyped,
+ RouterLinkTyped,
+ RouterLinkPropsTyped,
+ NavigationGuard,
+ UseLinkFnTyped,
+
+ // data fetching
+ _DataLoader,
+ _DefineLoaderOptions,
+} from 'unplugin-vue-router/types'
+
+declare module 'vue-router/auto/routes' {
+ export interface RouteNamedMap {
+ '/': RouteRecordInfo<'/', '/', Record, Record>,
+ '/[...all]': RouteRecordInfo<'/[...all]', '/:all(.*)', { all: ParamValue }, { all: ParamValue }>,
+ '/about': RouteRecordInfo<'/about', '/about', Record, Record>,
+ '/hi/[name]': RouteRecordInfo<'/hi/[name]', '/hi/:name', { name: ParamValue }, { name: ParamValue }>,
+ '/README': RouteRecordInfo<'/README', '/README', Record, Record>,
+ }
+}
+
+declare module 'vue-router/auto' {
+ import type { RouteNamedMap } from 'vue-router/auto/routes'
+
+ export type RouterTyped = _RouterTyped
+
+ /**
+ * Type safe version of `RouteLocationNormalized` (the type of `to` and `from` in navigation guards).
+ * Allows passing the name of the route to be passed as a generic.
+ */
+ export type RouteLocationNormalized = RouteLocationNormalizedTypedList[Name]
+
+ /**
+ * Type safe version of `RouteLocationNormalizedLoaded` (the return type of `useRoute()`).
+ * Allows passing the name of the route to be passed as a generic.
+ */
+ export type RouteLocationNormalizedLoaded = RouteLocationNormalizedLoadedTypedList[Name]
+
+ /**
+ * Type safe version of `RouteLocationResolved` (the returned route of `router.resolve()`).
+ * Allows passing the name of the route to be passed as a generic.
+ */
+ export type RouteLocationResolved = RouteLocationResolvedTypedList[Name]
+
+ /**
+ * Type safe version of `RouteLocation` . Allows passing the name of the route to be passed as a generic.
+ */
+ export type RouteLocation = RouteLocationTypedList[Name]
+
+ /**
+ * Type safe version of `RouteLocationRaw` . Allows passing the name of the route to be passed as a generic.
+ */
+ export type RouteLocationRaw =
+ | RouteLocationAsString
+ | RouteLocationAsRelativeTypedList[Name]
+ | RouteLocationAsPathTypedList[Name]
+
+ /**
+ * Generate a type safe params for a route location. Requires the name of the route to be passed as a generic.
+ */
+ export type RouteParams = RouteNamedMap[Name]['params']
+ /**
+ * Generate a type safe raw params for a route location. Requires the name of the route to be passed as a generic.
+ */
+ export type RouteParamsRaw = RouteNamedMap[Name]['paramsRaw']
+
+ export function useRouter(): RouterTyped
+ export function useRoute(name?: Name): RouteLocationNormalizedLoadedTypedList[Name]
+
+ export const useLink: UseLinkFnTyped
+
+ export function onBeforeRouteLeave(guard: NavigationGuard): void
+ export function onBeforeRouteUpdate(guard: NavigationGuard): void
+
+ export const RouterLink: RouterLinkTyped
+ export const RouterLinkProps: RouterLinkPropsTyped
+
+ // Experimental Data Fetching
+
+ export function defineLoader<
+ P extends Promise,
+ Name extends keyof RouteNamedMap = keyof RouteNamedMap,
+ isLazy extends boolean = false,
+ >(
+ name: Name,
+ loader: (route: RouteLocationNormalizedLoaded) => P,
+ options?: _DefineLoaderOptions,
+ ): _DataLoader, isLazy>
+ export function defineLoader<
+ P extends Promise,
+ isLazy extends boolean = false,
+ >(
+ loader: (route: RouteLocationNormalizedLoaded) => P,
+ options?: _DefineLoaderOptions,
+ ): _DataLoader, isLazy>
+
+ export {
+ _definePage as definePage,
+ _HasDataLoaderMeta as HasDataLoaderMeta,
+ _setupDataFetchingGuard as setupDataFetchingGuard,
+ _stopDataFetchingScope as stopDataFetchingScope,
+ } from 'unplugin-vue-router/runtime'
+}
+
+declare module 'vue-router' {
+ import type { RouteNamedMap } from 'vue-router/auto/routes'
+
+ export interface TypesConfig {
+ beforeRouteUpdate: NavigationGuard
+ beforeRouteLeave: NavigationGuard
+
+ $route: RouteLocationNormalizedLoadedTypedList[keyof RouteNamedMap]
+ $router: _RouterTyped
+
+ RouterLink: RouterLinkTyped
+ }
+}
diff --git a/vite.config.ts b/vite.config.ts
index 6880ff5..79b70cf 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,7 +1,6 @@
import path from 'node:path'
import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
-import Pages from 'vite-plugin-pages'
import generateSitemap from 'vite-ssg-sitemap'
import Layouts from 'vite-plugin-vue-layouts'
import Components from 'unplugin-vue-components/vite'
@@ -15,6 +14,8 @@ import LinkAttributes from 'markdown-it-link-attributes'
import Unocss from 'unocss/vite'
import Shiki from 'markdown-it-shikiji'
import WebfontDownload from 'vite-plugin-webfont-dl'
+import VueRouter from 'unplugin-vue-router/vite'
+import { VueRouterAutoImports } from 'unplugin-vue-router'
export default defineConfig({
resolve: {
@@ -32,9 +33,9 @@ export default defineConfig({
},
}),
- // https://github.com/hannoeru/vite-plugin-pages
- Pages({
- extensions: ['vue', 'md'],
+ // https://github.com/posva/unplugin-vue-router
+ VueRouter({
+ extensions: ['.vue', '.md'],
}),
// https://github.com/JohnCampionJr/vite-plugin-vue-layouts
@@ -44,10 +45,14 @@ export default defineConfig({
AutoImport({
imports: [
'vue',
- 'vue-router',
'vue-i18n',
'@vueuse/head',
'@vueuse/core',
+ VueRouterAutoImports,
+ {
+ // add any other imports you were relying on
+ 'vue-router/auto': ['useLink'],
+ },
],
dts: 'src/auto-imports.d.ts',
dirs: [