1
0

Большое обновление

1. Создание личных проектов
2. Управление командой
3. Приглашение участников
4. Уведомления

и многое другое...
This commit is contained in:
2026-01-18 20:17:02 +07:00
parent 250eac70a7
commit 190b4d0a5e
51 changed files with 6179 additions and 426 deletions

View File

@@ -3,7 +3,10 @@ import MainApp from './views/MainApp.vue'
import LoginPage from './views/LoginPage.vue'
import TeamPage from './views/TeamPage.vue'
import ArchivePage from './views/ArchivePage.vue'
import NoProjectsPage from './views/NoProjectsPage.vue'
import InvitesPage from './views/InvitesPage.vue'
import { authApi } from './api'
import { useProjectsStore } from './stores/projects'
// Кэш авторизации (чтобы не делать запрос при каждой навигации)
let authCache = {
@@ -59,18 +62,30 @@ const routes = [
path: '/',
name: 'main',
component: MainApp,
meta: { requiresAuth: true }
meta: { requiresAuth: true, requiresProject: true }
},
{
path: '/team',
name: 'team',
component: TeamPage,
meta: { requiresAuth: true }
meta: { requiresAuth: true, requiresProject: true }
},
{
path: '/archive',
name: 'archive',
component: ArchivePage,
meta: { requiresAuth: true, requiresProject: true }
},
{
path: '/no-projects',
name: 'no-projects',
component: NoProjectsPage,
meta: { requiresAuth: true }
},
{
path: '/invites',
name: 'invites',
component: InvitesPage,
meta: { requiresAuth: true }
},
{
@@ -85,10 +100,11 @@ const router = createRouter({
routes
})
// Navigation guard — проверка авторизации
// Navigation guard — проверка авторизации и наличия проектов
router.beforeEach(async (to, from, next) => {
// Если переходим между защищёнными страницами и кэш валиден — не проверяем сеть
const needsAuth = to.meta.requiresAuth
const needsProject = to.meta.requiresProject
const fromProtected = from.meta?.requiresAuth
// Форсируем проверку только при переходе на защищённую страницу извне
@@ -100,12 +116,44 @@ router.beforeEach(async (to, from, next) => {
if (needsAuth && !isAuth) {
// Не авторизован — на логин
next('/login')
} else if (to.path === '/login' && isAuth) {
return
}
if (to.path === '/login' && isAuth) {
// Уже авторизован — на главную
next('/')
} else {
next()
return
}
// Проверка наличия проектов для страниц, которые их требуют
if (needsProject && isAuth) {
const store = useProjectsStore()
// Инициализируем store если ещё не инициализирован
if (!store.initialized) {
await store.init()
}
// Нет проектов — на страницу /no-projects
if (store.projects.length === 0) {
next('/no-projects')
return
}
}
// Если на /no-projects но проекты есть — на главную
if (to.path === '/no-projects' && isAuth) {
const store = useProjectsStore()
if (!store.initialized) {
await store.init()
}
if (store.projects.length > 0) {
next('/')
return
}
}
next()
})
export default router