mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Починка админки полностью1д
This commit is contained in:
@@ -1,51 +1,44 @@
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import LoginView from '../views/LoginView.vue';
|
||||
|
||||
const router = createRouter({
|
||||
history: createWebHistory(),
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
name: 'login',
|
||||
component: LoginView
|
||||
},
|
||||
{
|
||||
path: '/support',
|
||||
name: 'support',
|
||||
component: () => import('../views/SupportView.vue'),
|
||||
meta: { requiresAuth: true }
|
||||
},
|
||||
{
|
||||
path: '/admin',
|
||||
name: 'admin-login',
|
||||
component: () => import('../views/admin/AdminLoginView.vue')
|
||||
component: () => import('@/layouts/AdminLayout.vue'),
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
redirect: '/admin/dashboard'
|
||||
},
|
||||
{
|
||||
path: 'dashboard',
|
||||
name: 'AdminDashboard',
|
||||
component: () => import('@/views/admin/DashboardView.vue')
|
||||
},
|
||||
{
|
||||
path: 'requests',
|
||||
name: 'AdminRequests',
|
||||
component: () => import('@/views/admin/RequestsView.vue')
|
||||
},
|
||||
{
|
||||
path: 'employees',
|
||||
name: 'AdminEmployees',
|
||||
component: () => import('@/views/admin/EmployeesView.vue')
|
||||
},
|
||||
{
|
||||
path: 'employees/add',
|
||||
name: 'AdminEmployeeAdd',
|
||||
component: () => import('@/views/admin/AddEmployeeView.vue')
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/admin/dashboard',
|
||||
name: 'admin-dashboard',
|
||||
component: () => import('../views/admin/DashboardView.vue'),
|
||||
meta: { requiresAdmin: true }
|
||||
},
|
||||
{
|
||||
path: '/admin/employees/add',
|
||||
name: 'add-employee',
|
||||
component: () => import('../views/admin/AddEmployeeView.vue'),
|
||||
meta: { requiresAdmin: true }
|
||||
path: '/admin/login',
|
||||
name: 'AdminLogin',
|
||||
component: () => import('@/views/admin/AdminLoginView.vue')
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
router.beforeEach((to, _, next) => {
|
||||
const authStore = useAuthStore();
|
||||
|
||||
if (to.meta.requiresAuth && !authStore.isAuthenticated) {
|
||||
next({ name: 'login' });
|
||||
} else if (to.meta.requiresAdmin && !authStore.isAdmin) {
|
||||
next({ name: 'admin-login' });
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
Reference in New Issue
Block a user