New login design, added basic logic for multiplayer (WIP)

This commit is contained in:
2024-05-04 00:27:55 +02:00
parent f63cc93454
commit b16863a363
18 changed files with 206 additions and 78 deletions

View File

@ -7,16 +7,24 @@
<script setup lang="ts">
import Game from '@/components/Game.vue'
import Login from '@/components/screens/Login.vue'
import { onMounted, onUnmounted, type Ref, ref } from 'vue'
import SocketioService from '@/services/socketio.service';
import { onMounted, onUnmounted, type Ref, ref, watch } from 'vue'
import { useSocketStore } from '@/stores/socket'
import { storeToRefs } from 'pinia'
const screen:Ref<string> = ref('login');
const socket = useSocketStore();
onMounted(() => {
SocketioService.setupSocketConnection();
// SocketioService.setupSocketConnection();
});
onUnmounted(() => {
SocketioService.disconnect();
const { isAuthenticated } = storeToRefs(socket);
watch(isAuthenticated, (isAuthenticated) => {
if (isAuthenticated) {
screen.value = 'game';
} else {
screen.value = 'login';
}
});
</script>