多维表格
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

19 lines
655 B

import { defineNuxtRouteMiddleware, navigateTo, useNuxtApp } from '#app'
export default defineNuxtRouteMiddleware((to, from) => {
const { $state } = useNuxtApp()
/**
* By default, we assume that auth is required
* If not required, mark the page as `requiresAuth: false` using `definePageMeta`
*/
if ((to.meta.requiresAuth || typeof to.meta.requiresAuth === 'undefined') && !$state.signedIn.value) {
return navigateTo('/signin')
} else if (to.meta.requiresAuth === false && $state.signedIn.value) {
if (from.meta.requiresAuth === false) {
return navigateTo('/')
} else {
return navigateTo(from.path)
}
}
})