This commit is contained in:
kron
2025-07-22 14:42:13 +08:00
parent d3029865cf
commit e5a28fd4ac
2 changed files with 20 additions and 5 deletions

View File

@@ -1,7 +1,8 @@
<script setup>
import { ref, onMounted, onUnmounted } from "vue";
import { ref, watch, onMounted, onUnmounted } from "vue";
import { onShow } from "@dcloudio/uni-app";
import { isGamingAPI, getCurrentGameAPI } from "@/apis";
import { debounce } from "@/util";
import useStore from "@/store";
import { storeToRefs } from "pinia";
const store = useStore();
@@ -19,13 +20,29 @@ onShow(async () => {
show.value = isGaming;
}
});
const onClick = async () => {
watch(
() => user.value,
async (value) => {
if (!value.id) {
show.value = false;
} else {
const isGaming = await isGamingAPI();
show.value = isGaming;
}
}
);
const onClick = debounce(async () => {
const isGaming = await isGamingAPI();
show.value = isGaming;
if (isGaming) {
const result = await getCurrentGameAPI();
} else {
uni.showToast({
title: "比赛已结束",
icon: "none",
});
}
};
});
const gameOver = () => {
show.value = false;
};