forked from slidevjs/slidev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroutes.ts
More file actions
111 lines (104 loc) · 2.72 KB
/
routes.ts
File metadata and controls
111 lines (104 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import type { RouteLocationNormalized, RouteRecordRaw } from 'vue-router'
import configs from '#slidev/configs'
import setups from '#slidev/setups/routes'
export default function setupRoutes() {
const routes: RouteRecordRaw[] = []
function passwordGuard(to: RouteLocationNormalized) {
if (!configs.remote || configs.remote === to.query.password)
return true
if (configs.remote && to.query.password === undefined) {
// eslint-disable-next-line no-alert
const password = prompt('Enter password')
if (configs.remote === password)
return true
}
if (to.params.no)
return { path: `/${to.params.no}` }
return { path: '' }
}
if (__SLIDEV_FEATURE_PRESENTER__) {
routes.push(
{
name: 'entry',
path: '/entry',
component: () => import('../pages/entry.vue'),
beforeEnter: passwordGuard,
},
{
name: 'overview',
path: '/overview',
component: () => import('../pages/overview.vue'),
beforeEnter: passwordGuard,
},
{
name: 'notes',
path: '/notes',
component: () => import('../pages/notes.vue'),
beforeEnter: passwordGuard,
},
{
name: 'notes-edit',
path: '/notes-edit',
component: () => import('../pages/notes-edit.vue'),
beforeEnter: passwordGuard,
},
{
name: 'presenter',
path: '/presenter/:no',
component: () => import('../pages/presenter.vue'),
beforeEnter: passwordGuard,
},
{
path: '/presenter',
redirect: { path: '/presenter/1' },
},
)
}
if (__SLIDEV_FEATURE_PRINT__) {
routes.push(
{
name: 'print',
path: '/print',
component: () => import('../pages/print.vue'),
beforeEnter: passwordGuard,
},
{
path: '/presenter/print',
component: () => import('../pages/presenter/print.vue'),
beforeEnter: passwordGuard,
},
{
path: '/overview/print',
component: () => import('../pages/overview/print.vue'),
beforeEnter: passwordGuard,
},
)
}
if (__SLIDEV_FEATURE_BROWSER_EXPORTER__) {
routes.push(
{
name: 'export',
path: '/export/:no?',
component: () => import('../pages/export.vue'),
beforeEnter: passwordGuard,
},
)
}
routes.push(
{
name: 'play',
path: '/:no',
component: () => import('../pages/play.vue'),
},
{
path: '',
redirect: { path: '/1' },
},
{
path: '/:pathMatch(.*)*',
name: 'NotFound',
component: () => import('../pages/404.vue'),
},
)
return setups.reduce((routes, setup) => setup(routes), routes)
}