Files
SpineParticlesWeb/src/App.vue
T
2026-10-31 11:48:29 +08:00

33 lines
1.0 KiB
Vue

<script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue'
import WelcomePage from './views/WelcomePage.vue'
import EditorWorkspace from './views/EditorWorkspace.vue'
import { i18n } from './i18n'
const editorActive = ref(window.location.hash === '#/editor')
function syncViewFromUrl() {
editorActive.value = window.location.hash === '#/editor'
document.title = i18n.global.t(editorActive.value ? 'app.title' : 'welcome.documentTitle')
}
function openEditor() {
if (window.location.hash !== '#/editor') window.location.hash = '/editor'
else syncViewFromUrl()
}
function openWelcome() {
if (window.location.hash !== '#/') window.location.hash = '/'
else syncViewFromUrl()
}
onMounted(() => {
syncViewFromUrl()
window.addEventListener('hashchange', syncViewFromUrl)
})
onUnmounted(() => window.removeEventListener('hashchange', syncViewFromUrl))
</script>
<template>
<WelcomePage v-if="!editorActive" @open-editor="openEditor" />
<EditorWorkspace v-else @home="openWelcome" />
</template>