feat: add fallback pages and refine page interactions

This commit is contained in:
2026-05-22 00:09:00 +08:00
parent 78b1c952e7
commit f35baf4a67
9 changed files with 175 additions and 16 deletions
+11 -1
View File
@@ -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 {