Client - add lazy loading in router
This commit is contained in:
parent
3bcc93bb1a
commit
ffa673b3bc
@ -23,21 +23,6 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
|
||||||
Chart,
|
|
||||||
BarElement,
|
|
||||||
LineElement,
|
|
||||||
PointElement,
|
|
||||||
Legend,
|
|
||||||
Title,
|
|
||||||
Tooltip,
|
|
||||||
Filler,
|
|
||||||
BarController,
|
|
||||||
CategoryScale,
|
|
||||||
LineController,
|
|
||||||
LinearScale,
|
|
||||||
} from 'chart.js'
|
|
||||||
import ChartDataLabels from 'chartjs-plugin-datalabels'
|
|
||||||
import {
|
import {
|
||||||
ComputedRef,
|
ComputedRef,
|
||||||
computed,
|
computed,
|
||||||
@ -54,21 +39,6 @@
|
|||||||
import { IAppConfig } from '@/types/application'
|
import { IAppConfig } from '@/types/application'
|
||||||
import { useStore } from '@/use/useStore'
|
import { useStore } from '@/use/useStore'
|
||||||
|
|
||||||
Chart.register(
|
|
||||||
BarElement,
|
|
||||||
LineElement,
|
|
||||||
PointElement,
|
|
||||||
Legend,
|
|
||||||
Title,
|
|
||||||
Tooltip,
|
|
||||||
Filler,
|
|
||||||
BarController,
|
|
||||||
CategoryScale,
|
|
||||||
LineController,
|
|
||||||
LinearScale,
|
|
||||||
ChartDataLabels
|
|
||||||
)
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'App',
|
name: 'App',
|
||||||
components: {
|
components: {
|
||||||
|
@ -1,3 +1,18 @@
|
|||||||
|
import {
|
||||||
|
Chart,
|
||||||
|
BarElement,
|
||||||
|
LineElement,
|
||||||
|
PointElement,
|
||||||
|
Legend,
|
||||||
|
Title,
|
||||||
|
Tooltip,
|
||||||
|
Filler,
|
||||||
|
BarController,
|
||||||
|
CategoryScale,
|
||||||
|
LineController,
|
||||||
|
LinearScale,
|
||||||
|
} from 'chart.js'
|
||||||
|
import ChartDataLabels from 'chartjs-plugin-datalabels'
|
||||||
import { createApp } from 'vue'
|
import { createApp } from 'vue'
|
||||||
|
|
||||||
import './registerServiceWorker'
|
import './registerServiceWorker'
|
||||||
@ -10,6 +25,21 @@ import { customComponents } from '@/custom-components'
|
|||||||
import { clickOutsideDirective } from '@/directives'
|
import { clickOutsideDirective } from '@/directives'
|
||||||
import { sportColors } from '@/utils/sports'
|
import { sportColors } from '@/utils/sports'
|
||||||
|
|
||||||
|
Chart.register(
|
||||||
|
BarElement,
|
||||||
|
LineElement,
|
||||||
|
PointElement,
|
||||||
|
Legend,
|
||||||
|
Title,
|
||||||
|
Tooltip,
|
||||||
|
Filler,
|
||||||
|
BarController,
|
||||||
|
CategoryScale,
|
||||||
|
LineController,
|
||||||
|
LinearScale,
|
||||||
|
ChartDataLabels
|
||||||
|
)
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
.provide('sportColors', sportColors)
|
.provide('sportColors', sportColors)
|
||||||
.use(i18n)
|
.use(i18n)
|
||||||
|
@ -9,16 +9,6 @@ import UserPictureEdition from '@/components/User/ProfileEdition/UserPictureEdit
|
|||||||
import UserPreferencesEdition from '@/components/User/ProfileEdition/UserPreferencesEdition.vue'
|
import UserPreferencesEdition from '@/components/User/ProfileEdition/UserPreferencesEdition.vue'
|
||||||
import store from '@/store'
|
import store from '@/store'
|
||||||
import { USER_STORE } from '@/store/constants'
|
import { USER_STORE } from '@/store/constants'
|
||||||
import Dashboard from '@/views/DashBoard.vue'
|
|
||||||
import LoginOrRegister from '@/views/LoginOrRegister.vue'
|
|
||||||
import NotFoundView from '@/views/NotFoundView.vue'
|
|
||||||
import PasswordResetView from '@/views/PasswordResetView.vue'
|
|
||||||
import ProfileView from '@/views/ProfileView.vue'
|
|
||||||
import StatisticsView from '@/views/StatisticsView.vue'
|
|
||||||
import AddWorkout from '@/views/workouts/AddWorkout.vue'
|
|
||||||
import EditWorkout from '@/views/workouts/EditWorkout.vue'
|
|
||||||
import Workout from '@/views/workouts/Workout.vue'
|
|
||||||
import Workouts from '@/views/workouts/WorkoutsView.vue'
|
|
||||||
|
|
||||||
const getTabFromPath = (path: string): string => {
|
const getTabFromPath = (path: string): string => {
|
||||||
const regex = /(\/profile)(\/edit)*(\/*)/
|
const regex = /(\/profile)(\/edit)*(\/*)/
|
||||||
@ -30,48 +20,56 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
{
|
{
|
||||||
path: '/',
|
path: '/',
|
||||||
name: 'Dashboard',
|
name: 'Dashboard',
|
||||||
component: Dashboard,
|
component: () =>
|
||||||
|
import(/* webpackChunkName: 'main' */ '@/views/DashBoard.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/login',
|
path: '/login',
|
||||||
name: 'Login',
|
name: 'Login',
|
||||||
component: LoginOrRegister,
|
component: () =>
|
||||||
|
import(/* webpackChunkName: 'main' */ '@/views/LoginOrRegister.vue'),
|
||||||
props: { action: 'login' },
|
props: { action: 'login' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/register',
|
path: '/register',
|
||||||
name: 'Register',
|
name: 'Register',
|
||||||
component: LoginOrRegister,
|
component: () =>
|
||||||
|
import(/* webpackChunkName: 'main' */ '@/views/LoginOrRegister.vue'),
|
||||||
props: { action: 'register' },
|
props: { action: 'register' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/password-reset/sent',
|
path: '/password-reset/sent',
|
||||||
name: 'PasswordEmailSent',
|
name: 'PasswordEmailSent',
|
||||||
component: PasswordResetView,
|
component: () =>
|
||||||
|
import(/* webpackChunkName: 'reset' */ '@/views/PasswordResetView.vue'),
|
||||||
props: { action: 'request-sent' },
|
props: { action: 'request-sent' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/password-reset/request',
|
path: '/password-reset/request',
|
||||||
name: 'PasswordResetRequest',
|
name: 'PasswordResetRequest',
|
||||||
component: PasswordResetView,
|
component: () =>
|
||||||
|
import(/* webpackChunkName: 'reset' */ '@/views/PasswordResetView.vue'),
|
||||||
props: { action: 'reset-request' },
|
props: { action: 'reset-request' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/password-reset/password-updated',
|
path: '/password-reset/password-updated',
|
||||||
name: 'PasswordUpdated',
|
name: 'PasswordUpdated',
|
||||||
component: PasswordResetView,
|
component: () =>
|
||||||
|
import(/* webpackChunkName: 'reset' */ '@/views/PasswordResetView.vue'),
|
||||||
props: { action: 'password-updated' },
|
props: { action: 'password-updated' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/password-reset',
|
path: '/password-reset',
|
||||||
name: 'PasswordReset',
|
name: 'PasswordReset',
|
||||||
component: PasswordResetView,
|
component: () =>
|
||||||
|
import(/* webpackChunkName: 'reset' */ '@/views/PasswordResetView.vue'),
|
||||||
props: { action: 'reset' },
|
props: { action: 'reset' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/profile',
|
path: '/profile',
|
||||||
name: 'Profile',
|
name: 'Profile',
|
||||||
component: ProfileView,
|
component: () =>
|
||||||
|
import(/* webpackChunkName: 'profile' */ '@/views/ProfileView.vue'),
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
path: '',
|
path: '',
|
||||||
@ -123,36 +121,53 @@ const routes: Array<RouteRecordRaw> = [
|
|||||||
{
|
{
|
||||||
path: '/statistics',
|
path: '/statistics',
|
||||||
name: 'Statistics',
|
name: 'Statistics',
|
||||||
component: StatisticsView,
|
component: () =>
|
||||||
|
import(/* webpackChunkName: 'main' */ '@/views/StatisticsView.vue'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/workouts',
|
path: '/workouts',
|
||||||
name: 'Workouts',
|
name: 'Workouts',
|
||||||
component: Workouts,
|
component: () =>
|
||||||
|
import(
|
||||||
|
/* webpackChunkName: 'workouts' */ '@/views/workouts/WorkoutsView.vue'
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/workouts/:workoutId',
|
path: '/workouts/:workoutId',
|
||||||
name: 'Workout',
|
name: 'Workout',
|
||||||
component: Workout,
|
component: () =>
|
||||||
|
import(/* webpackChunkName: 'workouts' */ '@/views/workouts/Workout.vue'),
|
||||||
props: { displaySegment: false },
|
props: { displaySegment: false },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/workouts/:workoutId/edit',
|
path: '/workouts/:workoutId/edit',
|
||||||
name: 'EditWorkout',
|
name: 'EditWorkout',
|
||||||
component: EditWorkout,
|
component: () =>
|
||||||
|
import(
|
||||||
|
/* webpackChunkName: 'workouts' */ '@/views/workouts/EditWorkout.vue'
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/workouts/:workoutId/segment/:segmentId',
|
path: '/workouts/:workoutId/segment/:segmentId',
|
||||||
name: 'WorkoutSegment',
|
name: 'WorkoutSegment',
|
||||||
component: Workout,
|
component: () =>
|
||||||
|
import(/* webpackChunkName: 'workouts' */ '@/views/workouts/Workout.vue'),
|
||||||
props: { displaySegment: true },
|
props: { displaySegment: true },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/workouts/add',
|
path: '/workouts/add',
|
||||||
name: 'AddWorkout',
|
name: 'AddWorkout',
|
||||||
component: AddWorkout,
|
component: () =>
|
||||||
|
import(
|
||||||
|
/* webpackChunkName: 'workouts' */ '@/views/workouts/AddWorkout.vue'
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/:pathMatch(.*)*',
|
||||||
|
name: 'not-found',
|
||||||
|
component: () =>
|
||||||
|
import(/* webpackChunkName: 'main' */ '@/views/NotFoundView.vue'),
|
||||||
},
|
},
|
||||||
{ path: '/:pathMatch(.*)*', name: 'not-found', component: NotFoundView },
|
|
||||||
]
|
]
|
||||||
|
|
||||||
const router = createRouter({
|
const router = createRouter({
|
||||||
|
Loading…
Reference in New Issue
Block a user