Skip to content

Commit

Permalink
feat: add entry page for quick access
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Oct 27, 2023
1 parent 5fa52ce commit 47d176a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
25 changes: 25 additions & 0 deletions packages/client/internals/EntrySelect.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<template>
<div class="h-full w-full flex items-center justify-center gap-5 lt-md:flex-col">
<RouterLink
to="/"
class="flex flex-col gap-2 items-center justify-center h-40 min-w-40 rounded bg-gray:10 p4 hover:bg-gray/20"
>
<carbon:presentation-file class="text-3em op50" />
Slides
</RouterLink>
<RouterLink
to="/presenter"
class="flex flex-col gap-2 items-center justify-center h-40 min-w-40 rounded bg-gray:10 p4 hover:bg-gray/20"
>
<carbon:user-speaker class="text-3em op50" />
Presenter
</RouterLink>
<RouterLink
to="/notes"
class="flex flex-col gap-2 items-center justify-center h-40 min-w-40 rounded bg-gray:10 p4 hover:bg-gray/20"
>
<carbon:catalog class="text-3em op50" />
Notes
</RouterLink>
</div>
</template>
23 changes: 16 additions & 7 deletions packages/client/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ if (__SLIDEV_FEATURE_PRESENTER__) {
return { path: '' }
}
routes.push({ path: '/presenter/print', component: () => import('./internals/PresenterPrint.vue') })
routes.push({
name: 'notes',
path: '/notes',
component: () => import('./internals/NotesView.vue'),
beforeEnter: passwordGuard,
})
if (__SLIDEV_HAS_SERVER__) {
routes.push({
name: 'entry',
path: '/entry',
component: () => import('./internals/EntrySelect.vue'),
})
routes.push({
name: 'notes',
path: '/notes',
component: () => import('./internals/NotesView.vue'),
beforeEnter: passwordGuard,
})
}
routes.push({
name: 'presenter',
path: '/presenter/:no',
Expand All @@ -61,7 +68,9 @@ if (__SLIDEV_FEATURE_PRESENTER__) {
}

export const router = createRouter({
history: __SLIDEV_HASH_ROUTE__ ? createWebHashHistory(import.meta.env.BASE_URL) : createWebHistory(import.meta.env.BASE_URL),
history: __SLIDEV_HASH_ROUTE__
? createWebHashHistory(import.meta.env.BASE_URL)
: createWebHistory(import.meta.env.BASE_URL),
routes,
})

Expand Down
5 changes: 3 additions & 2 deletions packages/slidev/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ function printInfo(options: ResolvedSlidevOptions, port?: number, remote?: strin
if (port) {
const query = remote ? `?password=${remote}` : ''
const presenterPath = `${options.data.config.routerMode === 'hash' ? '/#/' : '/'}presenter/${query}`
const entryPath = `${options.data.config.routerMode === 'hash' ? '/#/' : '/'}entry${query}/`
console.log()
console.log(`${dim(' public slide show ')} > ${cyan(`http://localhost:${bold(port)}/`)}`)
if (query)
Expand All @@ -555,12 +556,12 @@ function printInfo(options: ResolvedSlidevOptions, port?: number, remote?: strin
.forEach(v => (v || [])
.filter(details => String(details.family).slice(-1) === '4' && !details.address.includes('127.0.0.1'))
.forEach(({ address }) => {
lastRemoteUrl = `http://${address}:${port}${presenterPath}`
lastRemoteUrl = `http://${address}:${port}${entryPath}`
console.log(`${dim(' remote control ')} > ${blue(lastRemoteUrl)}`)
}))

if (tunnelUrl) {
lastRemoteUrl = `${tunnelUrl}${presenterPath}`
lastRemoteUrl = `${tunnelUrl}${entryPath}`
console.log(`${dim(' remote via tunnel')} > ${yellow(lastRemoteUrl)}`)
}
}
Expand Down

0 comments on commit 47d176a

Please sign in to comment.