Initialize the user app and load home banners from the API.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-09 17:08:45 +03:30
co-authored by Cursor
commit a7f9c66514
190 changed files with 36160 additions and 0 deletions
+254
View File
@@ -0,0 +1,254 @@
import { createRouter, createWebHistory } from 'vue-router'
import { getCachedUser, isAuthenticated } from '@/services/authService'
const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes: [
{
path: '/login',
name: 'login',
component: () => import('@/views/auth/LoginView.vue'),
meta: { guest: true, hideNav: true },
},
{
path: '/register',
name: 'register',
component: () => import('@/views/auth/RegisterView.vue'),
meta: { guest: true, hideNav: true },
},
{
path: '/otp',
name: 'otp',
component: () => import('@/views/auth/OtpView.vue'),
meta: { guest: true, hideNav: true },
},
{
path: '/',
name: 'home',
component: () => import('@/views/home/HomeView.vue'),
meta: { requiresAuth: true },
},
{
path: '/companies',
name: 'companies',
component: () => import('@/views/companies/CompanySelectView.vue'),
meta: { requiresAuth: true },
},
{
path: '/categories',
name: 'categories',
component: () => import('@/views/categories/CategoriesView.vue'),
meta: { requiresAuth: true },
},
{
path: '/products',
name: 'products',
component: () => import('@/views/products/ProductsView.vue'),
meta: { requiresAuth: true },
},
{
path: '/product',
name: 'product',
component: () => import('@/views/products/ProductDetailView.vue'),
meta: { requiresAuth: true },
},
{
path: '/catalogs',
name: 'catalogs',
component: () => import('@/views/catalogs/CatalogsHubView.vue'),
meta: { requiresAuth: true },
},
{
path: '/catalog-request',
name: 'catalog-request',
component: () => import('@/views/catalogs/CatalogRequestView.vue'),
meta: { requiresAuth: true },
},
{
path: '/catalog-requests',
name: 'catalog-requests',
component: () => import('@/views/catalogs/CatalogRequestsView.vue'),
meta: { requiresAuth: true },
},
{
path: '/favorites',
name: 'favorites',
component: () => import('@/views/products/FavoritesView.vue'),
meta: { requiresAuth: true },
},
{
path: '/customers',
name: 'customers',
component: () => import('@/views/customers/CustomersView.vue'),
meta: { requiresAuth: true },
},
{
path: '/customers/new',
name: 'customer-new',
component: () => import('@/views/customers/CustomerCreateView.vue'),
meta: { requiresAuth: true, hideNav: true },
},
{
path: '/customer',
name: 'customer',
component: () => import('@/views/customers/CustomerDetailView.vue'),
meta: { requiresAuth: true },
},
{
path: '/meeting-report',
name: 'meeting-report',
component: () => import('@/views/customers/MeetingReportView.vue'),
meta: { requiresAuth: true, hideNav: true },
},
{
path: '/reminders',
name: 'reminders',
component: () => import('@/views/reminders/RemindersView.vue'),
meta: { requiresAuth: true },
},
{
path: '/reminder',
name: 'reminder',
component: () => import('@/views/reminders/ReminderDetailView.vue'),
meta: { requiresAuth: true, hideNav: true },
},
{
path: '/companies/:companyId/catalogs',
name: 'company-catalogs',
component: () => import('@/views/catalogs/CatalogListView.vue'),
meta: { requiresAuth: true },
},
{
path: '/companies/:companyId/catalogs/:catalogId/products',
name: 'company-products',
component: () => import('@/views/products/ProductListView.vue'),
meta: { requiresAuth: true },
},
{
path: '/cart',
name: 'cart',
component: () => import('@/views/cart/CartView.vue'),
meta: { requiresAuth: true },
},
{
path: '/orders',
name: 'orders',
component: () => import('@/views/OrdersView.vue'),
meta: { requiresAuth: true },
},
{
path: '/order',
name: 'order-query',
redirect: (to) => {
const id = String(to.query.id ?? '')
if (!id) return { name: 'orders' }
return { path: `/orders/${id}` }
},
},
{
path: '/orders/:id',
name: 'order-detail',
component: () => import('@/views/orders/OrderDetailView.vue'),
meta: { requiresAuth: true },
},
{
path: '/orders/:id/success',
name: 'order-success',
component: () => import('@/views/orders/OrderSuccessView.vue'),
meta: { requiresAuth: true, hideNav: true },
},
{
path: '/orders/:id/settlement',
name: 'settlement',
component: () => import('@/views/checkout/SettlementTypeView.vue'),
meta: { requiresAuth: true, hideNav: true },
},
{
path: '/orders/:id/cash',
name: 'cash-settlement',
component: () => import('@/views/checkout/CashSettlementView.vue'),
meta: { requiresAuth: true, hideNav: true },
},
{
path: '/orders/:id/check-mode',
name: 'check-mode',
component: () => import('@/views/checkout/CheckModeSelectView.vue'),
meta: { requiresAuth: true, hideNav: true },
},
{
path: '/orders/:id/check-form',
name: 'check-form',
component: () => import('@/views/checkout/CheckFormView.vue'),
meta: { requiresAuth: true, hideNav: true },
},
{
path: '/orders/:id/check-list',
name: 'check-list',
component: () => import('@/views/checkout/CheckListView.vue'),
meta: { requiresAuth: true, hideNav: true },
},
{
path: '/profile',
name: 'profile',
component: () => import('@/views/profile/ProfileView.vue'),
meta: { requiresAuth: true },
},
{
path: '/profile/edit',
name: 'profile-edit',
component: () => import('@/views/profile/ProfileEditView.vue'),
meta: { requiresAuth: true },
},
{
path: '/profile/security',
name: 'profile-security',
component: () => import('@/views/profile/ProfileSecurityView.vue'),
meta: { requiresAuth: true },
},
{
path: '/profile/notifications',
name: 'profile-notifications',
component: () => import('@/views/profile/ProfileNotificationsView.vue'),
meta: { requiresAuth: true },
},
{
path: '/profile/display',
name: 'profile-display',
component: () => import('@/views/profile/ProfileDisplayView.vue'),
meta: { requiresAuth: true },
},
{
path: '/profile/checks',
name: 'profile-checks',
component: () => import('@/views/profile/ProfileChecksView.vue'),
meta: { requiresAuth: true },
},
],
scrollBehavior() {
return { top: 0 }
},
})
router.beforeEach((to) => {
const authed = isAuthenticated()
if (to.meta.requiresAuth && !authed) {
return { name: 'login', query: { redirect: to.fullPath } }
}
if (to.meta.guest && authed) {
return { name: 'home' }
}
// صفحات CRM برای همه قابل مشاهده‌اند (طبق طراحی موکاپ)؛ API برای غیرواسطه خطا می‌دهد
if (to.meta.agentOnly) {
const user = getCachedUser()
if (user?.appRole !== 'agent') {
return { name: 'home' }
}
}
return true
})
export default router