1
0
mirror of https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git synced 2025-08-14 00:25:46 +02:00

Починка админки полностью1д9l9

This commit is contained in:
MoonTestUse1
2025-01-01 23:15:59 +06:00
parent f302acd71b
commit 814e8a252f
3 changed files with 50 additions and 14 deletions

View File

@@ -1,4 +1,5 @@
import { createRouter, createWebHistory } from 'vue-router';
import { useAuthStore } from '@/stores/auth';
const router = createRouter({
history: createWebHistory(),
@@ -6,6 +7,7 @@ const router = createRouter({
{
path: '/admin',
component: () => import('@/layouts/AdminLayout.vue'),
meta: { requiresAdmin: true },
children: [
{
path: '',
@@ -41,4 +43,14 @@ const router = createRouter({
]
});
router.beforeEach((to, from, next) => {
const authStore = useAuthStore();
if (to.meta.requiresAdmin && !authStore.isAdmin) {
next({ name: 'AdminLogin' });
} else {
next();
}
});
export default router;