Skip to content

Commit 7dc7a8c

Browse files
committed
chore(router): async import routes in web pages
1 parent ef2a090 commit 7dc7a8c

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/router.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,27 @@ import {
44
createWebHistory,
55
} from 'vue-router'
66
import isElectron from 'is-electron'
7-
import Landing from '@/pages/Landing.vue'
87
import Editor from '@/pages/Editor.vue'
9-
import ErrorPage from '@/pages/404.vue'
8+
import { defineAsyncComponent } from 'vue'
109

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

1615
const webRoutes = [
17-
{ path: '/', component: Editor },
18-
{ path: '/landing', component: Landing },
19-
{ path: '/:pathMatch(.*)*', component: ErrorPage },
16+
{
17+
path: '/',
18+
component: defineAsyncComponent(() => import('@/pages/Editor.vue')),
19+
},
20+
{
21+
path: '/landing',
22+
component: defineAsyncComponent(() => import('@/pages/Landing.vue')),
23+
},
24+
{
25+
path: '/:pathMatch(.*)*',
26+
component: defineAsyncComponent(() => import('@/pages/404.vue')),
27+
},
2028
]
2129

2230
export default createRouter({

0 commit comments

Comments
 (0)