update:优化比赛结束

This commit is contained in:
2026-07-15 16:57:48 +08:00
parent af7f70ba80
commit fa7ad8f538
2 changed files with 83 additions and 34 deletions
+15 -2
View File
@@ -27,6 +27,8 @@ const data = ref({});
const showOverlay = ref(false);
/** 自动关闭覆盖层的计时器 */
const overlayTimer = ref(null);
const overlayDelayTimer = ref(null);
let loadGeneration = 0;
/** 控制经验条是否执行进场动画(弹窗关闭后才置 true,避免动画被遮挡) */
const showExpAnim = ref(false);
@@ -175,9 +177,11 @@ function getMeleeAvatarBorderColor(rank) {
// ---- 生命周期 ----
onLoad(async (options) => {
const currentLoadId = ++loadGeneration;
if (!options.battleId) return;
const result = await getBattleAPI(options.battleId);
if (currentLoadId !== loadGeneration) return;
data.value = result;
// 从 teams 各队伍的 players 中找到当前用户,解析经验进度条所需字段
@@ -219,7 +223,8 @@ onLoad(async (options) => {
}
// 数据加载完成后延迟 1 秒再显示激励弹窗,避免进场时画面太杂
setTimeout(() => {
overlayDelayTimer.value = setTimeout(() => {
overlayDelayTimer.value = null;
showOverlay.value = true;
// 弹窗显示后 2.5 秒自动关闭
overlayTimer.value = setTimeout(() => {
@@ -229,7 +234,15 @@ onLoad(async (options) => {
});
onBeforeUnmount(() => {
if (overlayTimer.value) clearTimeout(overlayTimer.value);
loadGeneration += 1;
if (overlayDelayTimer.value) {
clearTimeout(overlayDelayTimer.value);
overlayDelayTimer.value = null;
}
if (overlayTimer.value) {
clearTimeout(overlayTimer.value);
overlayTimer.value = null;
}
});
// ---- 方法 ----