From 47d176af512dfebfd8b8053abc1f0cccb33c42a7 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Fri, 27 Oct 2023 13:09:29 +0900 Subject: [PATCH] feat: add entry page for quick access --- packages/client/internals/EntrySelect.vue | 25 +++++++++++++++++++++++ packages/client/routes.ts | 23 ++++++++++++++------- packages/slidev/node/cli.ts | 5 +++-- 3 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 packages/client/internals/EntrySelect.vue diff --git a/packages/client/internals/EntrySelect.vue b/packages/client/internals/EntrySelect.vue new file mode 100644 index 0000000000..c03e6433c2 --- /dev/null +++ b/packages/client/internals/EntrySelect.vue @@ -0,0 +1,25 @@ + diff --git a/packages/client/routes.ts b/packages/client/routes.ts index d21391c7d1..91ea4a8951 100644 --- a/packages/client/routes.ts +++ b/packages/client/routes.ts @@ -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', @@ -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, }) diff --git a/packages/slidev/node/cli.ts b/packages/slidev/node/cli.ts index d1e9924af7..78686338bd 100644 --- a/packages/slidev/node/cli.ts +++ b/packages/slidev/node/cli.ts @@ -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) @@ -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)}`) } }