添加游戏结束,隐藏返回按钮

This commit is contained in:
kron
2025-07-19 16:41:23 +08:00
parent ca317d62e0
commit 9e83bf89f7
2 changed files with 13 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
<script setup>
import { ref, onMounted } from "vue";
import { ref, onMounted, onUnmounted } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { isGamingAPI, getCurrentGameAPI } from "@/apis";
const props = defineProps({
@@ -20,6 +20,15 @@ const onClick = async () => {
const result = await getCurrentGameAPI();
}
};
const gameOver = () => {
show.value = false;
};
onMounted(() => {
uni.$on("game-over", gameOver);
});
onUnmounted(() => {
uni.$off("game-over", gameOver);
});
</script>
<template>

View File

@@ -23,7 +23,6 @@ function createWebSocket(token, onMessage) {
// 接收消息
uni.onSocketMessage((res) => {
const data = JSON.parse(res.data);
// console.log(res);
if (data.event === "pong" || !data.data.updates) return;
if (onMessage) onMessage(data.data.updates);
const msg = data.data.updates[0];
@@ -50,6 +49,9 @@ function createWebSocket(token, onMessage) {
}
}
}
if (msg.constructor === MESSAGETYPES.MatchOver) {
uni.$emit("game-over");
}
if (msg.constructor === MESSAGETYPES.PaySuccess) {
console.log(1111111, msg);
}