update:优化性能问题

This commit is contained in:
2026-08-17 10:11:28 +08:00
parent 2628a17b3f
commit 63fb4ae85a
15 changed files with 395 additions and 137 deletions
+6 -1
View File
@@ -9,11 +9,13 @@ const props = defineProps({
const show = ref(false);
const count = ref(props.countdown);
const timer = ref(null);
const showTimer = ref(null);
const updateTimer = (value) => {
count.value = Math.round(value);
};
onMounted(() => {
setTimeout(() => {
showTimer.value = setTimeout(() => {
showTimer.value = null;
show.value = true;
timer.value = setInterval(() => {
if (count.value === 0) {
@@ -27,7 +29,10 @@ onMounted(() => {
uni.$on("update-timer", updateTimer);
});
onBeforeUnmount(() => {
if (showTimer.value) clearTimeout(showTimer.value);
showTimer.value = null;
if (timer.value) clearInterval(timer.value);
timer.value = null;
uni.$off("update-timer", updateTimer);
});
</script>