brutalism design
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { Component, FunctionPlugin } from 'vue'
|
||||
import { useAuth } from '@shared/composables/use-auth'
|
||||
import { createRouter, createWebHistory } from 'vue-router'
|
||||
import { routes } from 'vue-router/auto-routes'
|
||||
|
||||
@@ -13,6 +14,23 @@ export const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes,
|
||||
})
|
||||
router.onError((e) => {
|
||||
console.log('wtf', e)
|
||||
})
|
||||
|
||||
router.isReady().then(() => {
|
||||
router.beforeEach((to) => {
|
||||
const { authorized } = useAuth()
|
||||
|
||||
if (authorized.value && to.meta.auth === 'guest') {
|
||||
return { name: '/', replace: true }
|
||||
}
|
||||
|
||||
if (!authorized.value && to.meta.auth === undefined) {
|
||||
return { name: '/auth/login', replace: true }
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
export default {
|
||||
install(app) {
|
||||
|
||||
Reference in New Issue
Block a user