修复投票计数与状态同步,完善票据与戳显示

修复投票系统:禁止重复投票、恢复状态、同步大屏

完善投票流程与展示:计数准确、状态可恢复、样式统一
This commit is contained in:
empty
2026-01-28 21:37:05 +08:00
parent 66ca67c137
commit d090c80e50
27 changed files with 1541 additions and 1023 deletions

View File

@@ -38,16 +38,28 @@ export interface VotingState {
currentProgramId: string | null; // 当前投票节目 ID
currentProgramIndex: number; // 当前节目序号 (0-based index)
programs: VotingProgram[]; // 节目列表(已排序)
awards: AwardConfig[]; // 奖项列表
allowLateCatch: boolean; // 补投票开关(默认 true
votingStartedAt?: number; // 当前节目投票开始时间(用于计时)
}
// 奖项配置
export interface AwardConfig {
id: string;
name: string;
icon: string;
remark?: string; // 奖项备注
order: number;
}
export type ProgramVotingStatus = 'pending' | 'voting' | 'completed';
export interface VotingProgram {
id: string;
name: string;
teamName: string;
performer?: string; // 表演者
remark?: string; // 节目备注
order: number; // 初始顺序
status: ProgramVotingStatus; // 投票状态
votes: number; // 票数
@@ -148,14 +160,13 @@ export const PRIZE_CONFIG: PrizeConfig[] = [
// Default programs for voting
export const DEFAULT_PROGRAMS: VotingProgram[] = [
{ id: 'p1', name: '龙腾四海', teamName: '市场部', order: 1, status: 'pending', votes: 0, stamps: [] },
{ id: 'p2', name: '金马奔腾', teamName: '技术部', order: 2, status: 'pending', votes: 0, stamps: [] },
{ id: 'p3', name: '春风得意', teamName: '人力资源部', order: 3, status: 'pending', votes: 0, stamps: [] },
{ id: 'p4', name: '鸿运当头', teamName: '财务部', order: 4, status: 'pending', votes: 0, stamps: [] },
{ id: 'p5', name: '马到成功', teamName: '运营部', order: 5, status: 'pending', votes: 0, stamps: [] },
{ id: 'p6', name: '一马当先', teamName: '产品部', order: 6, status: 'pending', votes: 0, stamps: [] },
{ id: 'p7', name: '万马奔腾', teamName: '设计部', order: 7, status: 'pending', votes: 0, stamps: [] },
{ id: 'p8', name: '龙马精神', teamName: '销售部', order: 8, status: 'pending', votes: 0, stamps: [] },
{ id: 'p1', name: '龙腾四海', teamName: '市场部', performer: '待定', order: 1, remark: '赞美节目如琥珀般凝固了某个经典、美好、闪光的瞬间。', status: 'pending', votes: 0, stamps: [] },
{ id: 'p2', name: '金马奔腾', teamName: '技术部', performer: '待定', order: 2, remark: '强调节目留下了值得回味的\'声音\',可以是歌声、朗诵声。', status: 'pending', votes: 0, stamps: [] },
{ id: 'p3', name: '春风得意', teamName: '人力', performer: '待定', order: 3, remark: '赞美节目引发了跨越时代的共鸣。', status: 'pending', votes: 0, stamps: [] },
{ id: 'p4', name: '鸿运当头', teamName: '财务部', performer: '待定', order: 4, remark: '形容节目用声音和表演编织了一个时代的梦境。', status: 'pending', votes: 0, stamps: [] },
{ id: 'p5', name: '马到成功', teamName: '运营部', performer: '待定', order: 5, remark: '既指复刻了过去的潮流,也指创造了今晚的潮流。', status: 'pending', votes: 0, stamps: [] },
{ id: 'p6', name: '一马当先', teamName: '产品部', performer: '待定', order: 6, remark: '强调节目的独特韵味与精心打磨。', status: 'pending', votes: 0, stamps: [] },
{ id: 'p7', name: '万马奔腾', teamName: '设计部', performer: '待定', order: 7, remark: '赞美节目与时代精神同频共振。', status: 'pending', votes: 0, stamps: [] },
];
// ============================================================================
@@ -170,6 +181,7 @@ export const INITIAL_ADMIN_STATE: AdminState = {
currentProgramId: null,
currentProgramIndex: -1,
programs: DEFAULT_PROGRAMS,
awards: [],
allowLateCatch: true,
},
lottery: {

View File

@@ -19,6 +19,7 @@ export interface VoteUpdatePayload {
candidateId: string;
category: VoteCategory;
totalVotes: number;
programVotes?: number;
delta: number;
}
@@ -97,6 +98,7 @@ export interface ConnectionAckPayload {
export interface SyncStatePayload {
votes: Record<VoteCategory, Record<string, number>>; // category -> candidateId -> count
userVotedCategories: VoteCategory[];
userTickets?: Record<string, string | null>;
currentDraw?: {
isActive: boolean;
prizeLevel: PrizeLevel;