Skip to content

Commit

Permalink
refactor: move route components to pages/
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Feb 24, 2024
1 parent a9dabda commit b8f63cc
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 32 deletions.
File renamed without changes.
Expand Up @@ -7,8 +7,8 @@ import { sharedState } from '../state/shared'
import { fullscreen } from '../state'
import { total } from '../logic/nav'
import { rawRoutes } from '../routes'
import NoteDisplay from './NoteDisplay.vue'
import IconButton from './IconButton.vue'
import NoteDisplay from '../internals/NoteDisplay.vue'
import IconButton from '../internals/IconButton.vue'
const slideTitle = configs.titleTemplate.replace('%s', configs.title || 'Slidev')
useHead({
Expand Down
Expand Up @@ -5,11 +5,11 @@ import { isEmbedded, isPrintMode, next, prev, useSwipeControls } from '../logic/
import { isDrawing } from '../logic/drawings'
import { registerShortcuts } from '../logic/shortcuts'
import { configs, themeVars } from '../env'
import Controls from './Controls.vue'
import SlideContainer from './SlideContainer.vue'
import NavControls from './NavControls.vue'
import SlidesShow from './SlidesShow.vue'
import PrintStyle from './PrintStyle.vue'
import Controls from '../internals/Controls.vue'
import SlideContainer from '../internals/SlideContainer.vue'
import NavControls from '../internals/NavControls.vue'
import SlidesShow from '../internals/SlidesShow.vue'
import PrintStyle from '../internals/PrintStyle.vue'
registerShortcuts()
Expand All @@ -33,11 +33,11 @@ const persistNav = computed(() => isScreenVertical.value || showEditor.value)
const Editor = shallowRef<any>()
if (__DEV__ && __SLIDEV_FEATURE_EDITOR__)
import('./Editor.vue').then(v => Editor.value = v.default)
import('../internals/Editor.vue').then(v => Editor.value = v.default)
const DrawingControls = shallowRef<any>()
if (__SLIDEV_FEATURE_DRAWINGS__)
import('./DrawingControls.vue').then(v => DrawingControls.value = v.default)
import('../internals/DrawingControls.vue').then(v => DrawingControls.value = v.default)
</script>

<template>
Expand Down
Expand Up @@ -11,16 +11,16 @@ import { getSlideClass } from '../utils'
import { useTimer } from '../logic/utils'
import { isDrawing } from '../logic/drawings'
import { useFixedClicks } from '../composables/useClicks'
import SlideContainer from './SlideContainer.vue'
import NavControls from './NavControls.vue'
import SlidesOverview from './SlidesOverview.vue'
import NoteEditor from './NoteEditor.vue'
import NoteStatic from './NoteStatic.vue'
import Goto from './Goto.vue'
import SlidesShow from './SlidesShow.vue'
import SlideWrapper from './SlideWrapper'
import DrawingControls from './DrawingControls.vue'
import IconButton from './IconButton.vue'
import SlideWrapper from '../internals/SlideWrapper'
import SlideContainer from '../internals/SlideContainer.vue'
import NavControls from '../internals/NavControls.vue'
import SlidesOverview from '../internals/SlidesOverview.vue'
import NoteEditor from '../internals/NoteEditor.vue'
import NoteStatic from '../internals/NoteStatic.vue'
import Goto from '../internals/Goto.vue'
import SlidesShow from '../internals/SlidesShow.vue'
import DrawingControls from '../internals/DrawingControls.vue'
import IconButton from '../internals/IconButton.vue'
const main = ref<HTMLDivElement>()
Expand Down Expand Up @@ -54,7 +54,7 @@ watch([currentRoute, queryClicks], () => {
const Editor = shallowRef<any>()
if (__DEV__ && __SLIDEV_FEATURE_EDITOR__)
import('./Editor.vue').then(v => Editor.value = v.default)
import('../internals/Editor.vue').then(v => Editor.value = v.default)
// sync presenter cursor
onMounted(() => {
Expand Down
Expand Up @@ -2,9 +2,9 @@
import { computed } from 'vue'
import { useStyleTag } from '@vueuse/core'
import { useHead } from '@unhead/vue'
import { configs, themeVars } from '../env'
import { rawRoutes, total } from '../logic/nav'
import NoteDisplay from './NoteDisplay.vue'
import { configs, themeVars } from '../../env'
import { rawRoutes, total } from '../../logic/nav'
import NoteDisplay from '../../internals/NoteDisplay.vue'
useStyleTag(`
@page {
Expand All @@ -24,7 +24,9 @@ html #page-root {
}
`)
useHead({ title: `Notes - ${configs.title}` })
useHead({
title: `Notes - ${configs.title}`,
})
const slidesWithNote = computed(() => rawRoutes
.map(route => route.meta?.slide)
Expand Down
Expand Up @@ -3,8 +3,8 @@ import { watchEffect } from 'vue'
import { windowSize } from '../state'
import { isPrintMode } from '../logic/nav'
import { themeVars } from '../env'
import PrintContainer from './PrintContainer.vue'
import PrintStyle from './PrintStyle.vue'
import PrintContainer from '../internals/PrintContainer.vue'
import PrintStyle from '../internals/PrintStyle.vue'
watchEffect(() => {
if (isPrintMode)
Expand Down
22 changes: 16 additions & 6 deletions packages/client/routes.ts
Expand Up @@ -15,13 +15,19 @@ export const routes: RouteRecordRaw[] = [
{
name: 'play',
path: '/',
component: () => import('./internals/Play.vue'),
component: () => import('./pages/play.vue'),
children: [
...rawRoutes,
...redirects,
],
},
{ name: 'print', path: '/print', component: () => import('./internals/Print.vue') },
{
name: 'print',
path: '/print',
component: () => import('./pages/print.vue'),
},

// Redirects
{ path: '', redirect: { path: '/1' } },
{ path: '/:pathMatch(.*)', redirect: { path: '/1' } },
]
Expand All @@ -40,24 +46,28 @@ if (__SLIDEV_FEATURE_PRESENTER__) {
return { path: `/${to.params.no}` }
return { path: '' }
}
routes.push({ path: '/presenter/print', component: () => import('./internals/PresenterPrint.vue') })

routes.push({
path: '/presenter/print',
component: () => import('./pages/presenter/print.vue'),
})
if (__SLIDEV_HAS_SERVER__) {
routes.push({
name: 'entry',
path: '/entry',
component: () => import('./internals/EntrySelect.vue'),
component: () => import('./pages/entry.vue'),
})
routes.push({
name: 'notes',
path: '/notes',
component: () => import('./internals/NotesView.vue'),
component: () => import('./pages/notes.vue'),
beforeEnter: passwordGuard,
})
}
routes.push({
name: 'presenter',
path: '/presenter/:no',
component: () => import('./internals/Presenter.vue'),
component: () => import('./pages/presenter.vue'),
beforeEnter: passwordGuard,
})
routes.push({
Expand Down

0 comments on commit b8f63cc

Please sign in to comment.