Typescript enhancements, fixed character disconnect emit

This commit is contained in:
2024-07-22 15:39:55 +02:00
parent b8702a8ff8
commit 71e5069857
5 changed files with 135 additions and 58 deletions

View File

@ -32,7 +32,7 @@
<script setup lang="ts">
import config from '@/config'
import 'phaser'
import { onUnmounted, watch, ref } from 'vue'
import { onUnmounted, watch, ref, onBeforeUnmount } from 'vue'
import { storeToRefs } from 'pinia'
import { Game, Scene } from 'phavuer'
import { useGameStore } from '@/stores/game'
@ -52,12 +52,7 @@ const assetStore = useAssetStore()
const isLoaded = ref(false)
const { assets } = storeToRefs(assetStore)
onUnmounted(() => {
gameStore.disconnectSocket()
})
// On page close
addEventListener('beforeunload', () => {
onBeforeUnmount(() => {
gameStore.disconnectSocket()
})