From 51b16ab3d6a083d60433ba31a626b55423a0f632 Mon Sep 17 00:00:00 2001 From: Archibald Date: Tue, 13 May 2025 14:13:28 +0500 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B1=D1=80=D0=BE?= =?UTF-8?q?=D1=81=20=D0=BD=D0=B0=20gittea?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- API/app/main.py | 2 +- WEB/src/pages/HomePage.vue | 39 ++++++- WEB/src/pages/LoginPage.vue | 216 ++++++++++++++++++++++++++++++++---- WEB/src/router/index.js | 24 ++-- 4 files changed, 240 insertions(+), 41 deletions(-) diff --git a/API/app/main.py b/API/app/main.py index 808a764..8d351b0 100644 --- a/API/app/main.py +++ b/API/app/main.py @@ -15,7 +15,7 @@ def start_app(): api_app.add_middleware( CORSMiddleware, - allow_origins=["*"], + allow_origins=["http://localhost:5173"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], diff --git a/WEB/src/pages/HomePage.vue b/WEB/src/pages/HomePage.vue index 9262e47..b522d70 100644 --- a/WEB/src/pages/HomePage.vue +++ b/WEB/src/pages/HomePage.vue @@ -1,11 +1,44 @@ \ No newline at end of file +.home-page { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + min-height: 100vh; + gap: 20px; +} + diff --git a/WEB/src/pages/LoginPage.vue b/WEB/src/pages/LoginPage.vue index f6e8ffa..ba483f6 100644 --- a/WEB/src/pages/LoginPage.vue +++ b/WEB/src/pages/LoginPage.vue @@ -1,19 +1,41 @@ - diff --git a/WEB/src/router/index.js b/WEB/src/router/index.js index 1b89a3f..6011359 100644 --- a/WEB/src/router/index.js +++ b/WEB/src/router/index.js @@ -1,20 +1,13 @@ import {createRouter, createWebHistory} from 'vue-router' -// import DashboardPage from '@/pages/DashboardPage.vue' -import LoginPage from "../pages/LoginPage.vue"; -import HomePage from "../pages/HomePage.vue"; // пример +import LoginPage from "../pages/LoginPage.vue" +import HomePage from "../pages/HomePage.vue" const routes = [ { - path: '/', component: HomePage, - meta: {requiresAuth: true} + path: '/', + component: HomePage }, - - {path: '/login', component: LoginPage}, - // { - // path: '/dashboard', - // component: DashboardPage, - // meta: { requiresAuth: true } // требовать авторизацию - // } + {path: '/login', component: LoginPage} ] const router = createRouter({ @@ -22,14 +15,11 @@ const router = createRouter({ routes }) -// Навешиваем перехватчик навигации router.beforeEach((to, from, next) => { const isAuthenticated = !!localStorage.getItem('access_token') - if (to.meta.requiresAuth && !isAuthenticated) { - next('/login') - } else if (to.path === '/login' && isAuthenticated) { - next('/dashboard') + if (to.path === '/login' && isAuthenticated) { + next('/') // теперь редирект на главную страницу } else { next() }