38 lines
936 B
Vue
38 lines
936 B
Vue
<template>
|
|
<Notifications />
|
|
<Login v-if="screen === 'login'" />
|
|
<Register v-if="screen === 'register'" />
|
|
<Characters v-if="screen === 'characters'" />
|
|
<Game v-if="screen === 'game'" />
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { type Ref, ref } from 'vue'
|
|
import { useSocketStore } from '@/stores/socket'
|
|
import Notifications from '@/components/utilities/Notifications.vue'
|
|
import Login from '@/screens/Login.vue'
|
|
import Register from '@/screens/Register.vue'
|
|
import Characters from '@/screens/Characters.vue'
|
|
import Game from '@/screens/Game.vue'
|
|
|
|
const screen: Ref<string> = ref('login')
|
|
const socket = useSocketStore()
|
|
|
|
socket.$subscribe(
|
|
(mutation, state) => {
|
|
if (!state.connection) {
|
|
screen.value = 'login'
|
|
}
|
|
|
|
if (state.token && state.connection) {
|
|
screen.value = 'characters'
|
|
|
|
if (state.character) {
|
|
screen.value = 'game'
|
|
}
|
|
}
|
|
},
|
|
{ detached: true }
|
|
)
|
|
</script>
|