Unverified Commit 4d1ab1f1 authored by NGPixel's avatar NGPixel

feat: handle create path

parent 3da8fb41
...@@ -108,6 +108,7 @@ ...@@ -108,6 +108,7 @@
icon='las la-print' icon='las la-print'
color='grey' color='grey'
aria-label='Print' aria-label='Print'
@click='printPage'
) )
q-tooltip Print q-tooltip Print
template(v-if='editorStore.isActive') template(v-if='editorStore.isActive')
...@@ -230,13 +231,19 @@ function openEditorSettings () { ...@@ -230,13 +231,19 @@ function openEditorSettings () {
} }
async function discardChanges () { async function discardChanges () {
// Is it the home page in create mode? // From create mode
if (editorStore.mode === 'create' && pageStore.path === '' && pageStore.locale === 'en') { if (editorStore.mode === 'create') {
editorStore.$patch({ editorStore.$patch({
isActive: false, isActive: false,
editor: '' editor: ''
}) })
siteStore.overlay = 'Welcome'
// Is it the home page in create mode?
if ((pageStore.path === '' || pageStore.path === 'home') && pageStore.locale === 'en') {
siteStore.overlay = 'Welcome'
}
router.replace('/')
return return
} }
...@@ -371,4 +378,8 @@ async function editPage () { ...@@ -371,4 +378,8 @@ async function editPage () {
await pageStore.pageEdit() await pageStore.pageEdit()
$q.loading.hide() $q.loading.hide()
} }
function printPage () {
window.print()
}
</script> </script>
...@@ -262,7 +262,24 @@ const lastModified = computed(() => { ...@@ -262,7 +262,24 @@ const lastModified = computed(() => {
// WATCHERS // WATCHERS
watch(() => route.path, async (newValue) => { watch(() => route.path, async (newValue) => {
// -> Enter Create Mode?
if (newValue.startsWith('/_create')) {
if (!route.params.editor) {
$q.notify({
type: 'negative',
message: 'No editor specified!'
})
return router.replace('/')
}
$q.loading.show()
await pageStore.pageCreate({ editor: route.params.editor })
$q.loading.hide()
}
// -> Moving to a non-page path? Ignore
if (newValue.startsWith('/_')) { return } if (newValue.startsWith('/_')) { return }
// -> Load Page
try { try {
await pageStore.pageLoad({ path: newValue }) await pageStore.pageLoad({ path: newValue })
if (editorStore.isActive) { if (editorStore.isActive) {
......
...@@ -2,14 +2,6 @@ import { usePageStore } from 'src/stores/page' ...@@ -2,14 +2,6 @@ import { usePageStore } from 'src/stores/page'
const routes = [ const routes = [
{ {
path: '/',
component: () => import('../layouts/MainLayout.vue'),
children: [
{ path: '', component: () => import('../pages/Index.vue') },
{ path: '_create/:editor?', component: () => import('../pages/Index.vue') }
]
},
{
path: '/login', path: '/login',
component: () => import('layouts/AuthLayout.vue'), component: () => import('layouts/AuthLayout.vue'),
children: [ children: [
...@@ -85,11 +77,14 @@ const routes = [ ...@@ -85,11 +77,14 @@ const routes = [
// }, // },
// -------------------------------- // --------------------------------
// SYSTEM ROUTES CATCH-ALL FALLBACK // CREATE
// -------------------------------- // --------------------------------
{ {
path: '/_:catchAll(.*)*', path: '/_create/:editor?',
redirect: '/_error/notfound' component: () => import('../layouts/MainLayout.vue'),
children: [
{ path: '', component: () => import('../pages/Index.vue') }
]
}, },
// ----------------------- // -----------------------
// STANDARD PAGE CATCH-ALL // STANDARD PAGE CATCH-ALL
......
...@@ -352,7 +352,7 @@ export const usePageStore = defineStore('page', { ...@@ -352,7 +352,7 @@ export const usePageStore = defineStore('page', {
mode: 'edit' mode: 'edit'
}) })
this.router.push('/_create') this.router.push(`/_create/${editor}`)
}, },
/** /**
* PAGE - EDIT * PAGE - EDIT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment