Skip to content

Commit

Permalink
chore(router): async import routes in web pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Dec 1, 2021
1 parent ef2a090 commit 7dc7a8c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,27 @@ import {
createWebHistory,
} from 'vue-router'
import isElectron from 'is-electron'
import Landing from '@/pages/Landing.vue'
import Editor from '@/pages/Editor.vue'
import ErrorPage from '@/pages/404.vue'
import { defineAsyncComponent } from 'vue'

const electronRoutes = [
{ path: '/', component: Editor },
{ path: '/:pathMatch(.*)*', redirect: '/' },
]

const webRoutes = [
{ path: '/', component: Editor },
{ path: '/landing', component: Landing },
{ path: '/:pathMatch(.*)*', component: ErrorPage },
{
path: '/',
component: defineAsyncComponent(() => import('@/pages/Editor.vue')),
},
{
path: '/landing',
component: defineAsyncComponent(() => import('@/pages/Landing.vue')),
},
{
path: '/:pathMatch(.*)*',
component: defineAsyncComponent(() => import('@/pages/404.vue')),
},
]

export default createRouter({
Expand Down

0 comments on commit 7dc7a8c

Please sign in to comment.