fix: socket game

This commit is contained in:
hiyu 2024-06-15 19:51:09 +07:00
parent d5d091ea83
commit facb23cefd

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, reactive, computed, watch } from "vue"; import { ref, reactive, computed, watch, onUnmounted } from "vue";
import socket from "@/socket"; import socket from "@/socket";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
import CountDown from "@/helpers/CountDown"; import CountDown from "@/helpers/CountDown";
@ -65,6 +65,11 @@ io.on("game-info", (data) => {
getGameHistory(); getGameHistory();
}); });
onUnmounted(() => {
io.disconnect();
})
const toggleChoice = (idx) => { const toggleChoice = (idx) => {
choices.value[idx].active = !choices.value[idx].active; choices.value[idx].active = !choices.value[idx].active;
if (!choices.value[idx].active) { if (!choices.value[idx].active) {