bug修复
This commit is contained in:
@@ -48,6 +48,8 @@ const props = defineProps({
|
||||
});
|
||||
|
||||
const latestOne = ref(null);
|
||||
const prevScores = ref([]);
|
||||
const prevBlueScores = ref([]);
|
||||
// const startCount = ref(false);
|
||||
const timer = ref(null);
|
||||
|
||||
@@ -63,12 +65,15 @@ const timer = ref(null);
|
||||
|
||||
watch(
|
||||
() => props.scores,
|
||||
(newVal, oldVal) => {
|
||||
latestOne.value = newVal[newVal.length - 1];
|
||||
if (timer.value) clearTimeout(timer.value);
|
||||
timer.value = setTimeout(() => {
|
||||
latestOne.value = null;
|
||||
}, 1000);
|
||||
(newVal) => {
|
||||
if (newVal.length - prevScores.value.length === 1) {
|
||||
latestOne.value = newVal[newVal.length - 1];
|
||||
if (timer.value) clearTimeout(timer.value);
|
||||
timer.value = setTimeout(() => {
|
||||
latestOne.value = null;
|
||||
}, 1000);
|
||||
}
|
||||
prevScores.value = [...newVal];
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
@@ -78,11 +83,14 @@ watch(
|
||||
watch(
|
||||
() => props.blueScores,
|
||||
(newVal) => {
|
||||
latestOne.value = newVal[newVal.length - 1];
|
||||
if (timer.value) clearTimeout(timer.value);
|
||||
timer.value = setTimeout(() => {
|
||||
latestOne.value = null;
|
||||
}, 1000);
|
||||
if (newVal.length - prevBlueScores.value.length === 1) {
|
||||
latestOne.value = newVal[newVal.length - 1];
|
||||
if (timer.value) clearTimeout(timer.value);
|
||||
timer.value = setTimeout(() => {
|
||||
latestOne.value = null;
|
||||
}, 1000);
|
||||
}
|
||||
prevBlueScores.value = [...newVal];
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
@@ -141,7 +149,7 @@ const simulShoot2 = async () => {
|
||||
<view
|
||||
v-if="bow.ring > 0"
|
||||
:class="`hit ${
|
||||
index === scores.length - 1 && showLatestArrow ? 'pump-in' : ''
|
||||
index === scores.length - 1 && latestOne ? 'pump-in' : ''
|
||||
}`"
|
||||
:style="{
|
||||
left: calcRealX(bow.x),
|
||||
@@ -149,7 +157,7 @@ const simulShoot2 = async () => {
|
||||
backgroundColor:
|
||||
index === scores.length - 1 &&
|
||||
!blueScores.length &&
|
||||
showLatestArrow &&
|
||||
latestOne &&
|
||||
mode !== 'team'
|
||||
? 'green'
|
||||
: 'red',
|
||||
@@ -161,7 +169,7 @@ const simulShoot2 = async () => {
|
||||
<view
|
||||
v-if="bow.ring > 0"
|
||||
:class="`hit ${
|
||||
index === blueScores.length - 1 && showLatestArrow ? 'pump-in' : ''
|
||||
index === blueScores.length - 1 && latestOne ? 'pump-in' : ''
|
||||
}`"
|
||||
:style="{
|
||||
left: calcRealX(bow.x),
|
||||
@@ -240,7 +248,6 @@ const simulShoot2 = async () => {
|
||||
font-size: 8px;
|
||||
text-align: center;
|
||||
line-height: 10px;
|
||||
transition: all 0.3s ease;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.hit > text {
|
||||
|
||||
@@ -98,16 +98,12 @@ watch(
|
||||
watch(
|
||||
() => props.start,
|
||||
(newVal) => {
|
||||
if (!newVal && timer.value) {
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
}
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
if (newVal) {
|
||||
remain.value = props.total;
|
||||
timer.value = setInterval(() => {
|
||||
if (remain.value > 0) remain.value--;
|
||||
}, 1000);
|
||||
} else {
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -118,9 +114,11 @@ watch(
|
||||
const updateRemain = (value) => {
|
||||
if (timer.value) clearInterval(timer.value);
|
||||
remain.value = Math.floor(value);
|
||||
timer.value = setInterval(() => {
|
||||
if (remain.value > 0) remain.value--;
|
||||
}, 1000);
|
||||
if (remain.value > 0) {
|
||||
timer.value = setInterval(() => {
|
||||
if (remain.value > 0) remain.value--;
|
||||
}, 1000);
|
||||
}
|
||||
};
|
||||
|
||||
const updateSound = () => {
|
||||
|
||||
Reference in New Issue
Block a user