From 4ce366864edc2138e6fa18720ef3d685fd711426 Mon Sep 17 00:00:00 2001 From: kron Date: Tue, 28 Oct 2025 16:44:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8C=B9=E9=85=8D=E7=8E=AF?= =?UTF-8?q?=E8=8A=82=E7=9A=84=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Matching.vue | 144 ++++++++++++++++-------------------- 1 file changed, 64 insertions(+), 80 deletions(-) diff --git a/src/components/Matching.vue b/src/components/Matching.vue index f83086b..d8fdc4d 100644 --- a/src/components/Matching.vue +++ b/src/components/Matching.vue @@ -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; }); @@ -107,30 +109,13 @@ onBeforeUnmount(() => { class="matching-bg" /> - + - {{ name }} - - - - {{ 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;