服务端优化: - Socket.IO 配置优化,支持高并发 WebSocket 连接 - 添加 connectTimeout、perMessageDeflate 等参数 压测脚本: - 新增 vote-real-scenario.yaml 真实场景压测配置 - 支持 100人瞬间爆发、每人7票、不同投票速度模拟 - 添加随机延迟函数模拟真实用户行为 - 强制 WebSocket 传输避免 HTTP 连接限制 前端修复: - 修复 PostcardItem、PostcardDisplay 奖项名称硬编码问题 - 组件现在从后端 awards 配置动态获取奖项名称 - 修复 LiveVotingView、AdminControl 传递 awards 数据 - 新增 gala 压测命令到 package.json 测试验证: - 100人并发压测通过,成功率 100% - P95 延迟 0.7ms,远低于 500ms 阈值 - 系统可稳定支持 3.3 倍现场负载
164 lines
3.6 KiB
Vue
164 lines
3.6 KiB
Vue
<script setup lang="ts">
|
|
import { computed, ref, onMounted, onUnmounted } from 'vue';
|
|
import PostcardItem from './PostcardItem.vue';
|
|
import type { VotingProgram, AwardConfig } from '@gala/shared/types';
|
|
|
|
export interface Props {
|
|
programs: VotingProgram[];
|
|
awards?: AwardConfig[];
|
|
columns?: number;
|
|
rows?: number;
|
|
}
|
|
|
|
const props = withDefaults(defineProps<Props>(), {
|
|
columns: 4,
|
|
rows: 2,
|
|
});
|
|
|
|
// Calculate visible programs based on grid size
|
|
const maxVisible = computed(() => props.columns * props.rows);
|
|
|
|
const visiblePrograms = computed(() => {
|
|
return props.programs.slice(0, maxVisible.value);
|
|
});
|
|
|
|
// Refs for postcard items (for stamp animation targeting)
|
|
const postcardRefs = ref<Map<string, InstanceType<typeof PostcardItem>>>(new Map());
|
|
|
|
function setPostcardRef(id: string, el: any) {
|
|
if (el) {
|
|
postcardRefs.value.set(id, el);
|
|
} else {
|
|
postcardRefs.value.delete(id);
|
|
}
|
|
}
|
|
|
|
// Get stamp target element for a specific program
|
|
function getStampTarget(programId: string): HTMLElement | null {
|
|
const postcard = postcardRefs.value.get(programId);
|
|
return postcard?.stampTargetRef || null;
|
|
}
|
|
|
|
// Expose for parent component (animation system)
|
|
defineExpose({
|
|
getStampTarget,
|
|
postcardRefs,
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
class="postcard-grid"
|
|
:style="{
|
|
'--columns': columns,
|
|
'--rows': rows,
|
|
}"
|
|
>
|
|
<PostcardItem
|
|
v-for="program in visiblePrograms"
|
|
:key="program.id"
|
|
:ref="(el) => setPostcardRef(program.id, el)"
|
|
:id="program.id"
|
|
:name="program.name"
|
|
:team-name="program.teamName"
|
|
:performer="(program as any).performer"
|
|
:remark="(program as any).remark"
|
|
:order="program.order"
|
|
:votes="program.votes"
|
|
:stamps="program.stamps"
|
|
:awards="awards"
|
|
class="grid-item"
|
|
/>
|
|
|
|
<!-- Empty slots for incomplete grid -->
|
|
<div
|
|
v-for="n in Math.max(0, maxVisible - visiblePrograms.length)"
|
|
:key="`empty-${n}`"
|
|
class="grid-item empty-slot"
|
|
>
|
|
<div class="empty-placeholder">
|
|
<span class="empty-icon">📮</span>
|
|
<span class="empty-text">待添加节目</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
.postcard-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(var(--columns, 4), 1fr);
|
|
grid-template-rows: repeat(var(--rows, 2), 1fr);
|
|
gap: 40px;
|
|
padding: 40px 80px 80px;
|
|
width: 100%;
|
|
height: 100%;
|
|
box-sizing: border-box;
|
|
background: transparent;
|
|
overflow: visible; // Allow shadows and rotation to bleed out if needed
|
|
|
|
// Responsive breakpoints
|
|
@media (max-width: 1200px) {
|
|
grid-template-columns: repeat(3, 1fr);
|
|
gap: 30px;
|
|
padding: 30px;
|
|
}
|
|
|
|
@media (max-width: 900px) {
|
|
grid-template-columns: repeat(2, 1fr);
|
|
grid-template-rows: auto;
|
|
gap: 20px;
|
|
padding: 20px;
|
|
overflow-y: auto;
|
|
height: auto;
|
|
min-height: 100%;
|
|
}
|
|
|
|
@media (max-width: 500px) {
|
|
grid-template-columns: 1fr;
|
|
gap: 16px;
|
|
padding: 16px;
|
|
}
|
|
}
|
|
|
|
.grid-item {
|
|
min-width: 0;
|
|
min-height: 0;
|
|
}
|
|
|
|
.empty-slot {
|
|
background: rgba(255, 255, 255, 0.03);
|
|
border: 2px dashed rgba(255, 255, 255, 0.1);
|
|
border-radius: 8px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
transition: all 0.3s ease;
|
|
|
|
&:hover {
|
|
background: rgba(255, 255, 255, 0.05);
|
|
border-color: rgba(255, 255, 255, 0.2);
|
|
}
|
|
}
|
|
|
|
.empty-placeholder {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
gap: 12px;
|
|
color: rgba(255, 255, 255, 0.25);
|
|
|
|
.empty-icon {
|
|
font-size: 48px;
|
|
opacity: 0.6;
|
|
filter: grayscale(1) brightness(0.8);
|
|
}
|
|
|
|
.empty-text {
|
|
font-size: 16px;
|
|
font-family: 'Kaiti', 'STKaiti', serif;
|
|
letter-spacing: 2px;
|
|
}
|
|
}
|
|
</style>
|