1
0

Инициализация проекта

Загрузка проекта на GIT
This commit is contained in:
2026-01-11 15:01:35 +07:00
commit 301e179160
28 changed files with 7769 additions and 0 deletions

57
front_vue/src/router.js Normal file
View File

@@ -0,0 +1,57 @@
import { createRouter, createWebHistory } from 'vue-router'
import MainApp from './views/MainApp.vue'
import LoginPage from './views/LoginPage.vue'
import TeamPage from './views/TeamPage.vue'
import { authApi } from './api'
// Проверка авторизации
const checkAuth = async () => {
try {
const data = await authApi.check()
return data.status === 'ok'
} catch {
return false
}
}
const routes = [
{
path: '/',
name: 'main',
component: MainApp,
meta: { requiresAuth: true }
},
{
path: '/team',
name: 'team',
component: TeamPage,
meta: { requiresAuth: true }
},
{
path: '/login',
name: 'login',
component: LoginPage
}
]
const router = createRouter({
history: createWebHistory(),
routes
})
// Navigation guard — проверка авторизации
router.beforeEach(async (to, from, next) => {
const isAuth = await checkAuth()
if (to.meta.requiresAuth && !isAuth) {
// Не авторизован — на логин
next('/login')
} else if (to.path === '/login' && isAuth) {
// Уже авторизован — на главную
next('/')
} else {
next()
}
})
export default router