添加匹配环节的名字

This commit is contained in:
kron
2025-10-28 16:44:15 +08:00
parent 6087e1bf94
commit 4ce366864e

View File

@@ -11,91 +11,93 @@ const props = defineProps({
},
});
const playerNames = [
"彭妮·希利",
"埃琳娜·奥西波娃",
"凯西·考夫霍尔德",
"乐正青山",
"宇文玉兰",
"岑思宇",
"邬梓瑜",
"范子衿",
"旗鼓相当的对手",
"马乌罗·内斯波利",
"埃琳娜·奥西波娃",
"凯西·考夫霍尔德",
"乐子睿",
"时春晓",
"柏孤鸿",
"东宫锦瑟",
"段干流云",
];
const textStyles = [
{
color: "#fff9",
fontSize: "18px",
},
{
color: "#fff",
fontSize: "22px",
},
{
color: "#fed847",
fontSize: "30px",
},
];
const totalTop = ref(0);
const timer = ref(null);
const textStyles = ref([]);
const rowHeight = 100 / 7;
const totalHeight = (playerNames.length / 7) * 100 + 7;
const getTextStyle = (top) => {
const styles = [
{
color: "#fff9",
fontSize: "20px",
},
{
color: "#fff",
fontSize: "24px",
},
{
color: "#fed847",
fontSize: "30px",
},
];
const data = new Array(14).fill({
const currentTop = ref(-totalHeight + rowHeight * 0);
const timer = ref(null);
const getTextStyle = (top, index) => {
const count = Math.floor(
((totalHeight + (top + rowHeight / 3)) / rowHeight).toFixed(1)
);
if (index === 12 - count) return textStyles[0];
else if (index === 13 - count) return textStyles[1];
else if (index === 14 - count) return textStyles[2];
else if (index === 15 - count) return textStyles[1];
else if (index === 16 - count) return textStyles[0];
return {
color: "#fff6",
fontSize: "16px",
});
const unitHeight = 100 / 7;
let style = {};
if (top >= 100 - unitHeight / 2) {
for (let j = 0; j < 5; j++) {
data[j + 1] = styles[j > 2 ? 4 - j : j];
}
} else {
new Array(7).fill(1).some((_, i) => {
if (
top >= unitHeight * i - unitHeight / 2 &&
top < unitHeight * (i + 1) - unitHeight / 2
) {
for (let j = 0; j < 5; j++) {
data[7 + j + 1 - i] = styles[j > 2 ? 4 - j : j];
}
return true;
}
return false;
});
}
return data;
fontSize: "14px",
};
};
watch(
() => props.onComplete,
(newVal, oldVal) => {
if (newVal && !oldVal) {
if (timer.value) clearInterval(timer.value);
if (timer.value) {
clearInterval(timer.value);
timer.value = null;
}
timer.value = setInterval(() => {
if (totalTop.value === 100) {
const count = Math.round(
(
(totalHeight + (currentTop.value + rowHeight / 3)) /
rowHeight
).toFixed(1)
);
if (count === 10) {
clearInterval(timer.value);
timer.value = null;
setTimeout(() => {
newVal();
}, 1500);
} else {
totalTop.value += 0.5;
currentTop.value += 2;
}
textStyles.value = getTextStyle(totalTop.value);
}, 10);
}, 40);
}
}
);
onMounted(() => {
timer.value = setInterval(() => {
if (totalTop.value === 100) {
totalTop.value = 0;
if (currentTop.value >= -4) {
currentTop.value = -totalHeight;
} else {
totalTop.value += 2;
currentTop.value += 2;
}
textStyles.value = getTextStyle(totalTop.value);
}, 40);
});
onBeforeUnmount(() => {
if (timer.value) clearInterval(timer.value);
timer.value = null;
});
</script>
@@ -107,30 +109,13 @@ onBeforeUnmount(() => {
class="matching-bg"
/>
<view>
<view
class="player-names"
:style="{
top: `${totalTop - 100}%`,
}"
>
<view class="player-names" :style="{ top: `${currentTop}%` }">
<text
v-for="(name, index) in playerNames"
v-for="(name, index) in [...playerNames, ...playerNames]"
:key="index"
:style="{
lineHeight: `${95 / 7}vw`,
...(textStyles[index] || {}),
}"
>
{{ name }}
</text>
</view>
<view class="player-names" :style="{ top: `${totalTop}%` }">
<text
v-for="(name, index) in playerNames"
:key="index"
:style="{
lineHeight: `${95 / 7}vw`,
...(textStyles[index + 7] || {}),
lineHeight: `${rowHeight}vw`,
...getTextStyle(currentTop, index),
}"
>
{{ name }}
@@ -156,7 +141,7 @@ onBeforeUnmount(() => {
height: 95vw;
overflow: hidden;
position: absolute;
top: 30.5vw;
top: 30vw;
}
.matching-bg {
position: absolute;
@@ -176,7 +161,6 @@ onBeforeUnmount(() => {
}
.player-names {
width: 100%;
height: 95vw;
display: flex;
flex-direction: column;
position: absolute;