Тестовый коммит после удаления husky

This commit is contained in:
2025-03-05 01:02:09 +03:00
parent 97ca5e4b64
commit 3157ad0cd9
118 changed files with 8177 additions and 8530 deletions

View File

@@ -3,80 +3,84 @@ import { useAuthStore } from '../stores/auth';
// Импортируем компоненты напрямую, если они существуют
import HomeView from '../views/HomeView.vue';
import DashboardView from '../views/DashboardView.vue';
import KanbanView from '../views/KanbanView.vue';
import KanbanBoardView from '../views/KanbanBoardView.vue';
import AccessTestPage from '../views/AccessTestPage.vue';
import ProfileView from '../views/ProfileView.vue';
import AdminView from '../views/AdminView.vue'; // Новый компонент для администраторов
import AccessTestView from '../views/AccessTestView.vue';
import ConversationsView from '../views/ConversationsView.vue';
const routes = [
{
path: '/',
name: 'home',
component: HomeView,
meta: { requiresAuth: false }
meta: { requiresAuth: false },
},
{
path: '/dashboard',
name: 'dashboard',
component: DashboardView,
meta: { requiresAuth: true, requiresAdmin: true }
},
{
path: '/access-test',
name: 'access-test',
component: AccessTestPage,
meta: { requiresAuth: true, requiresAdmin: true }
name: 'Dashboard',
component: () => import('../views/DashboardView.vue'),
meta: { requiresAuth: true, requiresAdmin: true },
},
// Перенаправляем с /chat на главную страницу
{
path: '/chat',
redirect: { name: 'home' }
},
// Маршруты для Канбан-досок
{
path: '/kanban',
name: 'kanban',
component: KanbanView,
meta: { requiresAuth: true }
},
{
path: '/kanban/boards/:id',
name: 'kanbanBoard',
component: KanbanBoardView,
meta: { requiresAuth: true }
redirect: { name: 'home' },
},
{
path: '/profile',
name: 'profile',
component: ProfileView,
meta: { requiresAuth: true }
}
meta: { requiresAuth: true },
},
{
path: '/admin',
name: 'Admin',
component: () => import('../views/AdminView.vue'),
meta: { requiresAdmin: true },
},
{
path: '/access-test',
name: 'access-test',
component: AccessTestView,
meta: { requiresAuth: true, requiresAdmin: true },
},
{
path: '/conversations',
name: 'Conversations',
component: ConversationsView,
meta: { requiresAuth: true },
},
];
const router = createRouter({
history: createWebHistory(),
routes,
scrollBehavior(to, from, savedPosition) {
return savedPosition || { top: 0 }
}
return savedPosition || { top: 0 };
},
});
// Навигационный хук для проверки аутентификации
router.beforeEach((to, from, next) => {
const auth = useAuthStore();
// Если маршрут требует аутентификации и пользователь не аутентифицирован
if (to.meta.requiresAuth && !auth.isAuthenticated) {
next({ name: 'home' });
}
// Если маршрут требует прав администратора и пользователь не администратор
else if (to.meta.requiresAdmin && !auth.isAdmin) {
next({ name: 'home' });
router.beforeEach(async (to, from, next) => {
const authStore = useAuthStore();
// Проверяем аутентификацию только если еще не проверяли
if (!authStore.checkPerformed) {
try {
await authStore.checkAuth();
} catch (error) {
console.error('Ошибка при проверке аутентификации:', error);
}
}
// В остальных случаях разрешаем переход
else {
// Проверка прав доступа
if (to.meta.requiresAuth && !authStore.isAuthenticated) {
next({ name: 'Home' });
} else if (to.meta.requiresAdmin && !authStore.isAdmin) {
next({ name: 'Home' });
} else {
next();
}
});
export default router;
export default router;