From bfbe468b569c6463aaeb62ab70a3f6b4a9206204 Mon Sep 17 00:00:00 2001 From: MoonTestUse1 Date: Thu, 2 Jan 2025 02:08:17 +0600 Subject: [PATCH] =?UTF-8?q?=D1=87=D0=B8=D0=BD=D0=B8=D0=BC=20=D0=B1=D0=B8?= =?UTF-8?q?=D0=BB=D0=B408?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/router/index.ts | 22 +++--- frontend/src/views/AdminDashboardView.vue | 24 ++++++ frontend/src/views/AdminLoginView.vue | 89 +++++++++++++++++++++++ 3 files changed, 126 insertions(+), 9 deletions(-) create mode 100644 frontend/src/views/AdminDashboardView.vue create mode 100644 frontend/src/views/AdminLoginView.vue diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts index 86eb3af..b494b7b 100644 --- a/frontend/src/router/index.ts +++ b/frontend/src/router/index.ts @@ -23,26 +23,30 @@ const router = createRouter({ name: 'requests', component: () => import('@/views/RequestsView.vue'), meta: { requiresAuth: true } + }, + { + path: '/admin/dashboard', + name: 'admin-dashboard', + component: () => import('@/views/AdminDashboardView.vue'), + meta: { requiresAdmin: true } } ] }); router.beforeEach((to, from, next) => { - console.log('Проверка маршрута:', to.path) - - if (to.meta.requiresAuth) { - console.log('Маршрут требует авторизации') + if (to.meta.requiresAdmin) { + const adminToken = localStorage.getItem('admin_token') + if (!adminToken) { + next('/admin') + return + } + } else if (to.meta.requiresAuth) { const token = localStorage.getItem('token') - console.log('Токен:', token ? 'Присутствует' : 'Отсутствует') - if (!token) { - console.log('Перенаправление на /login') next('/login') return } } - - console.log('Разрешаем переход') next() }) diff --git a/frontend/src/views/AdminDashboardView.vue b/frontend/src/views/AdminDashboardView.vue new file mode 100644 index 0000000..56008b7 --- /dev/null +++ b/frontend/src/views/AdminDashboardView.vue @@ -0,0 +1,24 @@ + + + \ No newline at end of file diff --git a/frontend/src/views/AdminLoginView.vue b/frontend/src/views/AdminLoginView.vue new file mode 100644 index 0000000..14edb69 --- /dev/null +++ b/frontend/src/views/AdminLoginView.vue @@ -0,0 +1,89 @@ + + + \ No newline at end of file