添加练习超时,重新挑战

This commit is contained in:
kron
2025-07-05 13:12:58 +08:00
parent 79c869a3f3
commit 054bf2ef21
8 changed files with 88 additions and 29 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,
@@ -9,11 +9,13 @@ const props = defineProps({
const count = ref(4);
const timer = ref(null);
const isIos = ref(true);
watch(
() => props.start,
(newVal) => {
if (newVal) {
if (timer.value) clearInterval(timer.value);
count.value = 4;
timer.value = setInterval(() => {
if (count.value <= 1) {
clearInterval(timer.value);
@@ -26,13 +28,17 @@ watch(
immediate: true,
}
);
onMounted(() => {
const deviceInfo = uni.getDeviceInfo();
isIos.value = deviceInfo.osName === "ios";
});
onUnmounted(() => {
if (timer.value) clearInterval(timer.value);
});
</script>
<template>
<view class="container">
<view class="container" :style="{ top: `calc(50% - ${isIos ? 59 : 64}px)` }">
<view class="number pump-in" v-if="count === 3">3</view>
<view class="number pump-in" v-if="count === 2">2</view>
<view class="number pump-in" v-if="count === 1">1</view>