|
@@ -2,20 +2,15 @@
|
|
|
<div class="ranking-board-page">
|
|
|
<!-- 右上角倒计时显示 -->
|
|
|
<div class="countdown-display">
|
|
|
- <el-card shadow="never" class="countdown-card">
|
|
|
+ <!-- <el-card shadow="never" class="countdown-card"> -->
|
|
|
+ <el-button size="default" type="primary">
|
|
|
<div class="countdown-content">
|
|
|
- <el-icon class="countdown-icon"><Timer /></el-icon>
|
|
|
- <span class="countdown-text">{{ countdownSeconds }}s</span>
|
|
|
- <!-- <el-button
|
|
|
- type="text"
|
|
|
- size="small"
|
|
|
- @click="stopAutoRefresh"
|
|
|
- class="stop-btn"
|
|
|
- >
|
|
|
- <el-icon><Close /></el-icon>
|
|
|
- </el-button> -->
|
|
|
+ <!-- <el-icon class="countdown-icon"><Timer /></el-icon> -->
|
|
|
+ <span>{{ countdownSeconds }}秒后刷新</span>
|
|
|
</div>
|
|
|
- </el-card>
|
|
|
+ </el-button>
|
|
|
+
|
|
|
+ <!-- </el-card> -->
|
|
|
</div>
|
|
|
<!-- 赛事名称标题 -->
|
|
|
<div class="event-title">
|
|
@@ -253,20 +248,21 @@ const teamRefreshing = ref(false); // 团队排行榜刷新状态
|
|
|
|
|
|
// 自动刷新相关
|
|
|
const autoRefreshInterval = ref<NodeJS.Timeout | null>(null);
|
|
|
-const autoRefreshSeconds = 300; // 默认300秒自动刷新
|
|
|
+const autoRefreshSeconds = ref(300); // 默认300秒自动刷新
|
|
|
// 添加倒计时相关状态
|
|
|
-const countdownSeconds = ref(300); // 倒计时秒数
|
|
|
+const countdownSeconds = ref(0); // 倒计时秒数
|
|
|
const countdownInterval = ref<NodeJS.Timeout | null>(null); // 倒计时定时器
|
|
|
|
|
|
// 启动倒计时
|
|
|
const startCountdown = () => {
|
|
|
- countdownSeconds.value = autoRefreshSeconds;
|
|
|
+ stopCountdown();
|
|
|
+ countdownSeconds.value = autoRefreshSeconds.value;
|
|
|
|
|
|
countdownInterval.value = setInterval(() => {
|
|
|
countdownSeconds.value--;
|
|
|
|
|
|
if (countdownSeconds.value <= 0) {
|
|
|
- countdownSeconds.value = autoRefreshSeconds;
|
|
|
+ countdownSeconds.value = autoRefreshSeconds.value;
|
|
|
}
|
|
|
}, 1000);
|
|
|
};
|
|
@@ -605,7 +601,6 @@ const refreshAllData = async () => {
|
|
|
refreshTeamRanking(),
|
|
|
loadProjectProgress()
|
|
|
]);
|
|
|
-
|
|
|
ElMessage.success('所有数据已刷新');
|
|
|
} catch (error) {
|
|
|
console.error('刷新数据失败:', error);
|
|
@@ -623,22 +618,11 @@ const startAutoRefresh = () => {
|
|
|
}
|
|
|
|
|
|
autoRefreshInterval.value = setInterval(() => {
|
|
|
- refreshAllData();
|
|
|
- }, autoRefreshSeconds * 1000);
|
|
|
+ // refreshAllData();
|
|
|
+ }, autoRefreshSeconds.value * 1000);
|
|
|
// 开启倒计时
|
|
|
startCountdown();
|
|
|
- ElMessage.success(`已开启自动刷新,每${autoRefreshSeconds}秒刷新一次`);
|
|
|
-};
|
|
|
-
|
|
|
-// 停止自动刷新
|
|
|
-const stopAutoRefresh = () => {
|
|
|
- if (autoRefreshInterval.value) {
|
|
|
- clearInterval(autoRefreshInterval.value);
|
|
|
- autoRefreshInterval.value = null;
|
|
|
- }
|
|
|
- // 停止倒计时
|
|
|
- stopCountdown();
|
|
|
- ElMessage.info('已停止自动刷新');
|
|
|
+ ElMessage.success(`已开启自动刷新,每${autoRefreshSeconds.value}秒刷新一次`);
|
|
|
};
|
|
|
|
|
|
// 组件卸载时清理定时器
|
|
@@ -652,17 +636,22 @@ onUnmounted(() => {
|
|
|
|
|
|
onMounted(async () => {
|
|
|
try{
|
|
|
+ // refreshAllData();
|
|
|
+ startAutoRefresh();
|
|
|
const res = await listScoreRanking(defaultEventInfo.value.eventId.toString());
|
|
|
// 按照totalScore字段降序排序(分数高的在前面)
|
|
|
athleteScoreList.value = res.data.sort((a, b) => b.totalScore - a.totalScore);
|
|
|
- // 加载队伍积分排行榜
|
|
|
- await loadTeamScores();
|
|
|
- // 加载分组选项
|
|
|
- await loadRankGroupOptions();
|
|
|
- // 加载项目进度信息
|
|
|
- await loadProjectProgress();
|
|
|
- // 开启自动刷新
|
|
|
- startAutoRefresh();
|
|
|
+ // 并行加载其他数据
|
|
|
+ await Promise.all([
|
|
|
+ // 加载队伍积分排行榜
|
|
|
+ loadTeamScores(),
|
|
|
+ // 加载分组选项
|
|
|
+ loadRankGroupOptions(),
|
|
|
+ // 加载项目进度信息
|
|
|
+ loadProjectProgress()
|
|
|
+ ]);
|
|
|
+ // // 开启自动刷新
|
|
|
+ // startAutoRefresh();
|
|
|
} catch (error) {
|
|
|
console.error('加载数据失败:', error);
|
|
|
}
|