mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(nuxt): use native vue-router composables (#28114)
This commit is contained in:
parent
3412f87276
commit
c2e843485c
@ -218,6 +218,14 @@ export default defineNuxtModule({
|
|||||||
references.push({ types: useExperimentalTypedPages ? 'vue-router/auto-routes' : 'vue-router' })
|
references.push({ types: useExperimentalTypedPages ? 'vue-router/auto-routes' : 'vue-router' })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Add vue-router route guard imports
|
||||||
|
nuxt.hook('imports:sources', (sources) => {
|
||||||
|
const routerImports = sources.find(s => s.from === '#app/composables/router' && s.imports.includes('onBeforeRouteLeave'))
|
||||||
|
if (routerImports) {
|
||||||
|
routerImports.from = 'vue-router'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
// Regenerate templates when adding or removing pages
|
// Regenerate templates when adding or removing pages
|
||||||
const updateTemplatePaths = nuxt.options._layers.flatMap((l) => {
|
const updateTemplatePaths = nuxt.options._layers.flatMap((l) => {
|
||||||
const dir = (l.config.rootDir === nuxt.options.rootDir ? nuxt.options : l.config).dir
|
const dir = (l.config.rootDir === nuxt.options.rootDir ? nuxt.options : l.config).dir
|
||||||
|
Loading…
Reference in New Issue
Block a user