Files
tgCrewAdmin/src/router/routes.ts
2025-04-18 23:36:23 +03:00

168 lines
4.5 KiB
TypeScript

import type { RouteRecordRaw, RouteLocationNormalized } from 'vue-router'
import { useProjectsStore } from '../stores/projects'
const setProjectBeforeEnter = (to: RouteLocationNormalized) => {
const id = Number(to.params.id)
const projectsStore = useProjectsStore()
projectsStore.setCurrentProjectId(
!isNaN(id) && projectsStore.projectById(id) ? id : null
)
}
const routes: RouteRecordRaw[] = [
{
path: '/',
component: () => import('layouts/MainLayout.vue'),
children: [
{
path: '',
redirect: '/projects'
},
{
name: 'projects',
path: '/projects',
component: () => import('pages/ProjectsPage.vue'),
meta: { hideBackButton: true }
},
{
name: 'project_add',
path: '/project/add',
component: () => import('pages/ProjectCreatePage.vue')
},
{
name: 'project_info',
path: '/project/:id(\\d+)/info',
component: () => import('pages/ProjectInfoPage.vue'),
beforeEnter: setProjectBeforeEnter
},
{
name: 'company_mask',
path: '/project/:id(\\d+)/company-mask',
component: () => import('pages/CompanyMaskPage.vue'),
beforeEnter: setProjectBeforeEnter
},
{
path: '/project/:id(\\d+)',
component: () => import('pages/ProjectPage.vue'),
beforeEnter: setProjectBeforeEnter,
children: [
{
name: 'project',
path: '',
redirect: { name: 'chats' }
},
{
name: 'chats',
path: 'chats',
component: () => import('components/admin/project-page/ProjectPageChats.vue'),
meta: { backRoute: '/projects' }
},
{
name: 'persons',
path: 'persons',
component: () => import('components/admin/project-page/ProjectPagePersons.vue'),
meta: { backRoute: '/projects' }
},
{
name: 'companies',
path: 'companies',
component: () => import('components/admin/project-page/ProjectPageCompanies.vue'),
meta: { backRoute: '/projects' }
}
]
},
{
name: 'company_info',
path: '/project/:id(\\d+)/company/:companyId',
component: () => import('pages/CompanyInfoPage.vue'),
beforeEnter: setProjectBeforeEnter
},
{
name: 'person_info',
path: '/project/:id(\\d+)/person/:personId',
component: () => import('pages/PersonInfoPage.vue'),
beforeEnter: setProjectBeforeEnter
},
{
name: 'account',
path: '/account',
component: () => import('pages/AccountPage.vue')
},
{
name: 'create_account',
path: '/create-account',
component: () => import('src/pages/AccountCreatePage.vue')
},
{
name: 'change_account_password',
path: '/change-password',
component: () => import('pages/AccountChangePasswordPage.vue')
},
{
name: 'change_account_email',
path: '/change-email',
component: () => import('pages/AccountChangeEmailPage.vue')
},
{
name: 'subscribe',
path: '/subscribe',
component: () => import('pages/SubscribePage.vue')
},
{
name: 'terms',
path: '/terms-of-use',
component: () => import('pages/TermsPage.vue')
},
{
name: 'privacy',
path: '/privacy',
component: () => import('pages/PrivacyPage.vue')
},
{
name: 'your_company',
path: '/your-company',
component: () => import('src/pages/CompanyYourPage.vue')
},
{
name: 'login',
path: '/login',
component: () => import('pages/LoginPage.vue')
},
{
name: 'recovery_password',
path: '/recovery-password',
component: () => import('src/pages/AccountForgotPasswordPage.vue')
},
{
name: 'add_company',
path: '/add-company',
component: () => import('src/pages/CompanyCreatePage.vue')
},
{
name: 'person_info',
path: '/person-info',
component: () => import('pages/PersonInfoPage.vue')
},
{
name: 'settings',
path: '/settings',
component: () => import('pages/SettingsPage.vue')
}
]
},
{
path: '/:catchAll(.*)*',
component: () => import('pages/ErrorNotFound.vue'),
}
]
export default routes