feat: add fallback pages and refine page interactions
This commit is contained in:
+11
-1
@@ -62,6 +62,16 @@ const router = createRouter({
|
||||
component: () => import('@/views/admin/AdminView.vue'),
|
||||
meta: { requiresAuth: true, requiresAdmin: true },
|
||||
},
|
||||
{
|
||||
path: '/403',
|
||||
name: 'forbidden',
|
||||
component: () => import('@/views/system/ForbiddenView.vue'),
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'not-found',
|
||||
component: () => import('@/views/system/NotFoundView.vue'),
|
||||
},
|
||||
],
|
||||
scrollBehavior() {
|
||||
return { top: 0 }
|
||||
@@ -74,7 +84,7 @@ router.beforeEach((to, _from, next) => {
|
||||
if (to.meta.requiresAuth && !authStore.isLoggedIn) {
|
||||
next({ name: 'login', query: { redirect: to.fullPath } })
|
||||
} else if (to.meta.requiresAdmin && !authStore.isAdmin) {
|
||||
next({ name: 'map' })
|
||||
next({ name: 'forbidden' })
|
||||
} else if ((to.name === 'login' || to.name === 'register') && authStore.isLoggedIn) {
|
||||
next({ name: 'map' })
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user