Init
This commit is contained in:
@@ -18,6 +18,11 @@ const router = createRouter({
|
||||
name: 'login',
|
||||
component: () => import('@/pages/login.vue'),
|
||||
},
|
||||
{
|
||||
path: '/join',
|
||||
name: 'join',
|
||||
component: () => import('@/pages/join.vue'),
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
component: Index,
|
||||
@@ -31,9 +36,13 @@ const router = createRouter({
|
||||
],
|
||||
})
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
const authStore = useAuthStore()
|
||||
const publicPages = ['login', 'register']
|
||||
if (!authStore.isInitialized) {
|
||||
await authStore.initialize()
|
||||
}
|
||||
|
||||
const publicPages = ['login', 'join']
|
||||
const authRequired = !publicPages.includes(to.name as string)
|
||||
const adminRequired = to.matched.some(record => record.meta.requiresAdmin)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user