95 lines
2.3 KiB
JavaScript
95 lines
2.3 KiB
JavaScript
|
||
|
||
const emailRouteComponent = () => import('@/pages/apps/email/index.vue')
|
||
|
||
// 👉 Redirects
|
||
const redirects = [
|
||
// ℹ️ We are redirecting to different pages based on role.
|
||
// NOTE: Role is just for UI purposes. ACL is based on abilities.
|
||
{
|
||
path: '/',
|
||
name: 'index',
|
||
meta: {
|
||
middleware: to => {
|
||
const { data: sessionData } = useAuth()
|
||
|
||
const userRole = sessionData.value?.user.role
|
||
|
||
if (userRole === 'admin')
|
||
return { name: 'dashboards-crm' }
|
||
if (userRole === 'client')
|
||
return { name: 'access-control' }
|
||
|
||
return { name: 'login', query: to.query }
|
||
},
|
||
},
|
||
component: h('div'),
|
||
},
|
||
{
|
||
path: '/pages/user-profile',
|
||
name: 'pages-user-profile',
|
||
redirect: () => ({ name: 'pages-user-profile-tab', params: { tab: 'profile' } }),
|
||
},
|
||
{
|
||
path: '/pages/account-settings',
|
||
name: 'pages-account-settings',
|
||
redirect: () => ({ name: 'pages-account-settings-tab', params: { tab: 'account' } }),
|
||
},
|
||
]
|
||
|
||
const routes = [
|
||
// Email filter
|
||
{
|
||
path: '/apps/email/filter/:filter',
|
||
name: 'apps-email-filter',
|
||
component: emailRouteComponent,
|
||
meta: {
|
||
navActiveLink: 'apps-email',
|
||
layoutWrapperClasses: 'layout-content-height-fixed',
|
||
},
|
||
},
|
||
|
||
// Email label
|
||
{
|
||
path: '/apps/email/label/:label',
|
||
name: 'apps-email-label',
|
||
component: emailRouteComponent,
|
||
meta: {
|
||
// contentClass: 'email-application',
|
||
navActiveLink: 'apps-email',
|
||
layoutWrapperClasses: 'layout-content-height-fixed',
|
||
},
|
||
},
|
||
{
|
||
path: '/dashboards/logistics',
|
||
name: 'dashboards-logistics',
|
||
component: () => import('@/pages/apps/logistics/dashboard.vue'),
|
||
},
|
||
{
|
||
path: '/dashboards/academy',
|
||
name: 'dashboards-academy',
|
||
component: () => import('@/pages/apps/academy/dashboard.vue'),
|
||
},
|
||
{
|
||
path: '/apps/ecommerce/dashboard',
|
||
name: 'apps-ecommerce-dashboard',
|
||
component: () => import('@/pages/dashboards/ecommerce.vue'),
|
||
},
|
||
]
|
||
|
||
|
||
// https://router.vuejs.org/api/interfaces/routeroptions.html
|
||
export default {
|
||
routes: scannedRoutes => [
|
||
...redirects,
|
||
...routes,
|
||
...scannedRoutes,
|
||
],
|
||
scrollBehaviorType: 'smooth',
|
||
scrollBehavior(to) {
|
||
if (to.hash)
|
||
return { el: to.hash, behavior: 'smooth', top: 60 }
|
||
|
||
return { top: 0 }
|
||
},
|
||
} |