From 543aa0cd4a461285298d33a90ab3f11a9f084ca5 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Wed, 13 Mar 2024 00:17:32 +0000 Subject: Add home page --- assets/base.css | 4 +- components/editor/EditorSidebarCategory.vue | 4 +- components/editor/EditorSidebarItem.vue | 4 +- .../editor/EditorSidebarMainConfiguration.vue | 4 +- components/editor/EditorSidebarQuest.vue | 2 +- components/header/SiteHeader.vue | 18 +++- components/loader/LoaderFileSystemModal.vue | 3 + components/loader/LoaderTestDataModal.vue | 3 + layouts/default.vue | 18 +++- middleware/editor.global.ts | 13 +++ pages/category/[id].vue | 54 ---------- pages/config.vue | 17 ---- pages/editor/category/[id].vue | 54 ++++++++++ pages/editor/config.vue | 17 ++++ pages/editor/index.vue | 25 +++++ pages/editor/item/[id].vue | 51 ++++++++++ pages/editor/quest/[id].vue | 109 +++++++++++++++++++++ pages/index.vue | 70 ++++++++++++- pages/item/[id].vue | 51 ---------- pages/quest/[id].vue | 109 --------------------- stores/session.ts | 6 +- utils/util.ts | 12 ++- 22 files changed, 392 insertions(+), 256 deletions(-) create mode 100644 middleware/editor.global.ts delete mode 100644 pages/category/[id].vue delete mode 100644 pages/config.vue create mode 100644 pages/editor/category/[id].vue create mode 100644 pages/editor/config.vue create mode 100644 pages/editor/index.vue create mode 100644 pages/editor/item/[id].vue create mode 100644 pages/editor/quest/[id].vue delete mode 100644 pages/item/[id].vue delete mode 100644 pages/quest/[id].vue diff --git a/assets/base.css b/assets/base.css index 6b6443a..221ff06 100644 --- a/assets/base.css +++ b/assets/base.css @@ -66,7 +66,7 @@ --ff-monospace: monospace; } -@media (prefers-color-scheme: dark) { +/* @media (prefers-color-scheme: dark) { */ :root { --color-background: var(--c-black); --color-background-soft: var(--c-black-soft); @@ -84,7 +84,7 @@ --color-text-mute: var(--c-text-light-2); --color-text-primary: var(--c-brand-light); } -} +/* } */ *, *::before, diff --git a/components/editor/EditorSidebarCategory.vue b/components/editor/EditorSidebarCategory.vue index cfabf39..27a5ce0 100644 --- a/components/editor/EditorSidebarCategory.vue +++ b/components/editor/EditorSidebarCategory.vue @@ -22,11 +22,11 @@ const expandCategory = () => { }; const setSelectedCategory = () => { - navigateTo({ path: `/category/${category.value.id}` }) + navigateToEditorPane('category', category.value.id); }; const selected = computed(() => { - return route.path.startsWith('/category') && route.params.id === category.value.id; + return route.path.startsWith('/editor/category') && route.params.id === category.value.id; }); diff --git a/components/editor/EditorSidebarItem.vue b/components/editor/EditorSidebarItem.vue index 4696bb1..55f81d0 100644 --- a/components/editor/EditorSidebarItem.vue +++ b/components/editor/EditorSidebarItem.vue @@ -10,11 +10,11 @@ const { item } = toRefs(props); const route = useRoute(); const setSelectedItem = () => { - navigateTo({ path: `/item/${item.value.id}` }) + navigateToEditorPane('item', item.value.id); }; const selected = computed(() => { - return route.path.startsWith('/item') && route.params.id === item.value.id; + return route.path.startsWith('/editor/item') && route.params.id === item.value.id; }); diff --git a/components/editor/EditorSidebarMainConfiguration.vue b/components/editor/EditorSidebarMainConfiguration.vue index c4727c6..bf7196b 100644 --- a/components/editor/EditorSidebarMainConfiguration.vue +++ b/components/editor/EditorSidebarMainConfiguration.vue @@ -4,11 +4,11 @@ import { computed } from 'vue'; const route = useRoute(); const setSelected = () => { - navigateTo({ path: '/config' }) + navigateToEditorPane('config'); }; const selected = computed(() => { - return route.path.startsWith('/config'); + return route.path.startsWith('/editor/config'); }); diff --git a/components/editor/EditorSidebarQuest.vue b/components/editor/EditorSidebarQuest.vue index 85edb38..c40b22c 100644 --- a/components/editor/EditorSidebarQuest.vue +++ b/components/editor/EditorSidebarQuest.vue @@ -11,7 +11,7 @@ const { quest } = toRefs(props); const route = useRoute(); const setSelectedQuest = () => { - navigateTo({ path: `/quest/${quest.value.id}` }) + navigateToEditorPane('quest', quest.value.id); }; const selected = computed(() => { diff --git a/components/header/SiteHeader.vue b/components/header/SiteHeader.vue index 75686d8..015af3d 100644 --- a/components/header/SiteHeader.vue +++ b/components/header/SiteHeader.vue @@ -1,11 +1,16 @@ + + \ No newline at end of file diff --git a/middleware/editor.global.ts b/middleware/editor.global.ts new file mode 100644 index 0000000..18123ae --- /dev/null +++ b/middleware/editor.global.ts @@ -0,0 +1,13 @@ +import { useSessionStore } from "@/stores/session"; + +export default defineNuxtRouteMiddleware((to, from) => { + const session = useSessionStore(); + + if (to.fullPath === '/' && session.getSessionType !== 'none') { + return navigateTo('/editor'); + } + + if (to.fullPath.startsWith('/editor') && session.getSessionType === 'none') { + return navigateTo('/'); + } +}); diff --git a/pages/category/[id].vue b/pages/category/[id].vue deleted file mode 100644 index 3189d2a..0000000 --- a/pages/category/[id].vue +++ /dev/null @@ -1,54 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/config.vue b/pages/config.vue deleted file mode 100644 index 4dfc679..0000000 --- a/pages/config.vue +++ /dev/null @@ -1,17 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/editor/category/[id].vue b/pages/editor/category/[id].vue new file mode 100644 index 0000000..3189d2a --- /dev/null +++ b/pages/editor/category/[id].vue @@ -0,0 +1,54 @@ + + + + + \ No newline at end of file diff --git a/pages/editor/config.vue b/pages/editor/config.vue new file mode 100644 index 0000000..4dfc679 --- /dev/null +++ b/pages/editor/config.vue @@ -0,0 +1,17 @@ + + + + + \ No newline at end of file diff --git a/pages/editor/index.vue b/pages/editor/index.vue new file mode 100644 index 0000000..4e9815a --- /dev/null +++ b/pages/editor/index.vue @@ -0,0 +1,25 @@ + + + + + \ No newline at end of file diff --git a/pages/editor/item/[id].vue b/pages/editor/item/[id].vue new file mode 100644 index 0000000..c2456be --- /dev/null +++ b/pages/editor/item/[id].vue @@ -0,0 +1,51 @@ + + + + + \ No newline at end of file diff --git a/pages/editor/quest/[id].vue b/pages/editor/quest/[id].vue new file mode 100644 index 0000000..bc480d9 --- /dev/null +++ b/pages/editor/quest/[id].vue @@ -0,0 +1,109 @@ + + + + + \ No newline at end of file diff --git a/pages/index.vue b/pages/index.vue index dd46b31..a64706a 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -1,17 +1,77 @@ \ No newline at end of file diff --git a/pages/item/[id].vue b/pages/item/[id].vue deleted file mode 100644 index c2456be..0000000 --- a/pages/item/[id].vue +++ /dev/null @@ -1,51 +0,0 @@ - - - - - \ No newline at end of file diff --git a/pages/quest/[id].vue b/pages/quest/[id].vue deleted file mode 100644 index bc480d9..0000000 --- a/pages/quest/[id].vue +++ /dev/null @@ -1,109 +0,0 @@ - - - - - \ No newline at end of file diff --git a/stores/session.ts b/stores/session.ts index 40587e9..a0781bc 100644 --- a/stores/session.ts +++ b/stores/session.ts @@ -93,9 +93,11 @@ export interface QuestItemDefinition { } } +export type SessionType = 'none' | 'filesystem' | 'demo'; + export const useSessionStore = defineStore('session', { state: () => ({ - sessionType: '', + sessionType: 'none' as SessionType, session: { quests: [] as EditorQuest[], categories: [] as EditorCategory[], @@ -154,7 +156,7 @@ export const useSessionStore = defineStore('session', { } }, actions: { - setSessionType(type: string) { + setSessionType(type: SessionType) { this.sessionType = type }, setQuests(quests: EditorQuest[]) { diff --git a/utils/util.ts b/utils/util.ts index cc500e0..273191a 100644 --- a/utils/util.ts +++ b/utils/util.ts @@ -4,17 +4,19 @@ export function stripColorCodes(str: string): string { return str.replace(COLOR_CODE_REGEX, ''); } -export function navigateToEditorPane(type: 'quest' | 'category' | 'item' | null, id?: string) { +export function navigateToEditorPane(type: 'quest' | 'category' | 'item' | 'config' | null, id?: string) { if (id) { if (type === 'category') { - navigateTo({ path: '/category/' + id }) + navigateTo({ path: '/editor/category/' + id }) } else if (type === 'quest') { - navigateTo({ path: '/quest/' + id }) + navigateTo({ path: '/editor/quest/' + id }) } else if (type === 'item') { - navigateTo({ path: '/item/' + id }) + navigateTo({ path: '/editor/item/' + id }) } + } else if (type === 'config') { + navigateTo({ path: '/editor/config' }) } else if (!id && !type) { - navigateTo({ path: '/' }) + navigateTo({ path: '/editor' }) } } -- cgit v1.2.3-70-g09d2