feat: add admin login

This commit is contained in:
yanghao05
2025-04-16 19:55:32 +08:00
parent 8d601d456e
commit e95fc65f5f
11 changed files with 241 additions and 3 deletions

View File

@@ -0,0 +1,33 @@
import { useAuthStore } from '@/stores/authStore';
import { createRouter, createWebHistory } from 'vue-router';
// ...existing code...
// Add login route
const routes = [
{
path: '/login',
name: 'Login',
component: () => import('@/pages/LoginPage.vue'),
meta: { requiresAuth: false }
},
// ...existing routes...
];
// Add navigation guard
const router = createRouter({
history: createWebHistory(),
routes,
});
router.beforeEach((to, from, next) => {
const authStore = useAuthStore();
if (to.meta.requiresAuth !== false && !authStore.isAuthenticated) {
next('/login');
} else {
next();
}
});
export default router;