@slidev/client 0.49.0-beta.1 → 0.49.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,80 @@
1
+ import type { RouteLocationNormalized, RouteRecordRaw } from 'vue-router'
2
+ import configs from '#slidev/configs'
3
+ import setups from '#slidev/setups/routes'
4
+
5
+ export default function setupRoutes() {
6
+ const routes: RouteRecordRaw[] = []
7
+
8
+ if (__SLIDEV_FEATURE_PRESENTER__) {
9
+ function passwordGuard(to: RouteLocationNormalized) {
10
+ if (!configs.remote || configs.remote === to.query.password)
11
+ return true
12
+ if (configs.remote && to.query.password === undefined) {
13
+ // eslint-disable-next-line no-alert
14
+ const password = prompt('Enter password')
15
+ if (configs.remote === password)
16
+ return true
17
+ }
18
+ if (to.params.no)
19
+ return { path: `/${to.params.no}` }
20
+ return { path: '' }
21
+ }
22
+
23
+ routes.push(
24
+ {
25
+ name: 'entry',
26
+ path: '/entry',
27
+ component: () => import('../pages/entry.vue'),
28
+ },
29
+ {
30
+ name: 'overview',
31
+ path: '/overview',
32
+ component: () => import('../pages/overview.vue'),
33
+ },
34
+ {
35
+ name: 'notes',
36
+ path: '/notes',
37
+ component: () => import('../pages/notes.vue'),
38
+ beforeEnter: passwordGuard,
39
+ },
40
+ {
41
+ name: 'presenter',
42
+ path: '/presenter/:no',
43
+ component: () => import('../pages/presenter.vue'),
44
+ beforeEnter: passwordGuard,
45
+ },
46
+ {
47
+ path: '/presenter',
48
+ redirect: { path: '/presenter/1' },
49
+ },
50
+ )
51
+ }
52
+
53
+ if (__SLIDEV_HAS_SERVER__) {
54
+ routes.push(
55
+ {
56
+ name: 'print',
57
+ path: '/print',
58
+ component: () => import('../pages/print.vue'),
59
+ },
60
+ {
61
+ path: '/presenter/print',
62
+ component: () => import('../pages/presenter/print.vue'),
63
+ },
64
+ )
65
+ }
66
+
67
+ routes.push(
68
+ {
69
+ name: 'play',
70
+ path: '/:no',
71
+ component: () => import('../pages/play.vue'),
72
+ },
73
+ {
74
+ path: '',
75
+ redirect: { path: '/1' },
76
+ },
77
+ )
78
+
79
+ return setups.reduce((routes, setup) => setup(routes), routes)
80
+ }
package/routes.ts DELETED
@@ -1,68 +0,0 @@
1
- import type { RouteLocationNormalized, RouteRecordRaw } from 'vue-router'
2
- import configs from '#slidev/configs'
3
-
4
- export const routes: RouteRecordRaw[] = [
5
- {
6
- name: 'print',
7
- path: '/print',
8
- component: () => import('./pages/print.vue'),
9
- },
10
-
11
- // Redirects
12
- { path: '', redirect: { path: '/1' } },
13
- ]
14
-
15
- if (__SLIDEV_FEATURE_PRESENTER__) {
16
- function passwordGuard(to: RouteLocationNormalized) {
17
- if (!configs.remote || configs.remote === to.query.password)
18
- return true
19
- if (configs.remote && to.query.password === undefined) {
20
- // eslint-disable-next-line no-alert
21
- const password = prompt('Enter password')
22
- if (configs.remote === password)
23
- return true
24
- }
25
- if (to.params.no)
26
- return { path: `/${to.params.no}` }
27
- return { path: '' }
28
- }
29
-
30
- routes.push({
31
- path: '/presenter/print',
32
- component: () => import('./pages/presenter/print.vue'),
33
- })
34
- if (__SLIDEV_HAS_SERVER__) {
35
- routes.push({
36
- name: 'entry',
37
- path: '/entry',
38
- component: () => import('./pages/entry.vue'),
39
- })
40
- routes.push({
41
- name: 'overview',
42
- path: '/overview',
43
- component: () => import('./pages/overview.vue'),
44
- })
45
- routes.push({
46
- name: 'notes',
47
- path: '/notes',
48
- component: () => import('./pages/notes.vue'),
49
- beforeEnter: passwordGuard,
50
- })
51
- }
52
- routes.push({
53
- name: 'presenter',
54
- path: '/presenter/:no',
55
- component: () => import('./pages/presenter.vue'),
56
- beforeEnter: passwordGuard,
57
- })
58
- routes.push({
59
- path: '/presenter',
60
- redirect: { path: '/presenter/1' },
61
- })
62
- }
63
-
64
- routes.push({
65
- name: 'play',
66
- path: '/:no',
67
- component: () => import('./pages/play.vue'),
68
- })