初步完成返回游戏功能,待测试完善

This commit is contained in:
kron
2025-07-05 17:24:52 +08:00
parent c269a4b431
commit 1ea3f19238
8 changed files with 126 additions and 33 deletions

View File

@@ -1,5 +1,5 @@
<script setup>
import { ref, watch, onUnmounted } from "vue";
import { ref, watch, onMounted, onUnmounted } from "vue";
const props = defineProps({
start: {
type: Boolean,
@@ -33,11 +33,14 @@ watch(
(newVal) => {
if (newVal.includes("红队")) barColor.value = "#FF6060";
if (newVal.includes("蓝队")) barColor.value = "#5FADFF";
},
{
immediate: true,
}
);
watch(
() => props.seq,
() => [props.seq, props.total],
() => {
if (timer.value) clearInterval(timer.value);
remain.value = props.total;
@@ -77,7 +80,16 @@ watch(
}
);
const updateRemain = (value) => {
remain.value = Math.floor(value);
};
onMounted(() => {
uni.$on("update-ramain", updateRemain);
});
onUnmounted(() => {
uni.$off("update-ramain", updateRemain);
if (timer.value) clearInterval(timer.value);
});
</script>