chore: enhance route meta in test + cleanup vue test page

This commit is contained in:
userquin 2023-08-31 15:44:42 +02:00
parent 9e88b29bac
commit 7056c9cbc1
2 changed files with 9 additions and 3 deletions

View File

@ -10,6 +10,12 @@ declare module 'nitropack' {
}
}
declare module 'vue-router' {
interface RouteMeta {
globalMiddleware?: string[]
}
}
export default defineNuxtConfig({
app: {
pageTransition: true,

View File

@ -1,7 +1,7 @@
<script setup lang="ts">
definePageMeta({
middleware: [defineNuxtRouteMiddleware((to) => {
const globalMiddleware: string[] | undefined = to.meta.globalMiddleware
middleware: [(to) => {
const globalMiddleware = to.meta.globalMiddleware
if (!globalMiddleware?.length) {
return createError('Missing to.meta.globalMiddleware')
}
@ -13,7 +13,7 @@ definePageMeta({
if (!globalMiddleware.every((m, idx) => (idx === 0 && m === '01.a.global') || (idx === 1 && m === '01.b.global') || (idx === 2 && m === 'a.global') || (idx === 3 && m === 'b.global'))) {
return createError('Missmatch to.meta.globalMiddleware sorting order')
}
})]
}]
})
</script>
<template>