UNPKG

press-next

Version:

Vue3 组件库,支持 Composition API

320 lines (300 loc) 8.65 kB
// demo-data/index.ts import { treeDataList } from './list'; // 从list.ts导入真实数据并重新导出 export { treeDataList } from './list'; // 基于list.ts真实数据结构定义接口 export interface BattleData { nodeItem: { utime: number; }; realStatus: number; abnormalErr: boolean; schid: string; curBo: number; teamList: Array<{ score: number; teamid: string; teamname: string; fromBracketDesc: string; teamavatar: string; }>; bracketIdDesc: string; timeDesc: string; statusDesc: string; isStatusHighList: boolean; showLiveIcon: boolean; leftTeamInfo: { score: number; teamid: string; teamname: string; fromBracketDesc: string; teamavatar: string; scoreDesc: string; teamNameDesc: string; teamNameSkeleton: boolean; teamAvatarSkeleton: boolean; teamAvatar: string; }; rightTeamInfo: { score: number; teamid: string; teamname: string; fromBracketDesc: string; teamavatar: string; scoreDesc: string; teamNameDesc: string; teamNameSkeleton: boolean; teamAvatarSkeleton: boolean; teamAvatar: string; }; } export interface RoundInfo { start_battle_type: number; show_stime: number; ready_time_utime: number; bo_type: number; round_name: string; } // 获取真实数据并创建不同状态的演示数据 export function getMockData() { // 默认演示头像 const DEFAULT_BYE_AVATAR = 'https://image-1251917893.file.myqcloud.com/Esports/new/user/lk.png'; const DEFAULT_PENDING_AVATAR = 'https://image-1251917893.file.myqcloud.com/Esports/new/user/dd.png'; // 使用list.ts中的真实数据 const realRoundData = treeDataList[0][0]; // 获取第一个轮次数据 const realBattleData = realRoundData.battleList[0]; // 获取第一场对战数据 // 创建已结束状态的对战数据 const finishedBattle: BattleData = { nodeItem: { ...realBattleData.nodeItem, utime: Date.now(), }, realStatus: 100, // 已结束状态 abnormalErr: realBattleData.abnormalErr, schid: '500-0', curBo: realBattleData.curBo, teamList: realBattleData.teamList, bracketIdDesc: realBattleData.bracketIdDesc, timeDesc: '11/18 12:00', statusDesc: '已结束', isStatusHighList: realBattleData.isStatusHighList, showLiveIcon: realBattleData.showLiveIcon, leftTeamInfo: { ...realBattleData.upTeamInfo, score: 2, }, rightTeamInfo: { ...realBattleData.downTeamInfo, score: 1, }, }; // 创建比赛中状态的对战数据 const liveBattle: BattleData = { nodeItem: { ...realBattleData.nodeItem, utime: Date.now(), }, realStatus: 50, // 比赛中状态 abnormalErr: realBattleData.abnormalErr, schid: '500-1', curBo: realBattleData.curBo, teamList: realBattleData.teamList, bracketIdDesc: realBattleData.bracketIdDesc, timeDesc: realBattleData.timeDesc, statusDesc: '比赛中', isStatusHighList: realBattleData.isStatusHighList, showLiveIcon: true, leftTeamInfo: { ...realBattleData.upTeamInfo, teamid: 'team-id-500-1-a', score: 1, }, rightTeamInfo: { ...realBattleData.downTeamInfo, teamid: 'team-id-500-1-b', score: 0, }, }; // 创建待管理员开赛状态的对战数据 const waitingBattle: BattleData = { nodeItem: { ...realBattleData.nodeItem, utime: Date.now(), }, realStatus: 0, // 待开赛状态 abnormalErr: realBattleData.abnormalErr, schid: '500-2', curBo: realBattleData.curBo, teamList: realBattleData.teamList, bracketIdDesc: realBattleData.bracketIdDesc, timeDesc: realBattleData.timeDesc, statusDesc: '待管理员开赛', isStatusHighList: realBattleData.isStatusHighList, showLiveIcon: realBattleData.showLiveIcon, leftTeamInfo: { ...realBattleData.upTeamInfo, teamid: 'team-id-500-2-a', score: 0, }, rightTeamInfo: { ...realBattleData.downTeamInfo, teamid: 'team-id-500-2-b', teamname: '待定', // 演示待定状态 score: 0, }, }; // 创建定时开赛状态的对战数据 const scheduledBattle: BattleData = { nodeItem: { ...realBattleData.nodeItem, utime: Date.now(), }, realStatus: 10, // 定时开赛状态 abnormalErr: realBattleData.abnormalErr, schid: '500-3', curBo: realBattleData.curBo, teamList: realBattleData.teamList, bracketIdDesc: realBattleData.bracketIdDesc, timeDesc: '12/01 14:00', statusDesc: '开赛', isStatusHighList: realBattleData.isStatusHighList, showLiveIcon: realBattleData.showLiveIcon, leftTeamInfo: { ...realBattleData.upTeamInfo, teamid: 'team-id-500-3-a', score: 0, }, rightTeamInfo: { ...realBattleData.downTeamInfo, teamid: 'team-id-500-3-b', score: 0, }, }; // 弃权状态 - 右边队伍弃权,使用list.ts中的真实数据 const quitBattle: BattleData = { nodeItem: { utime: Date.now() - 3600000, // 1小时前结束 }, realStatus: 100, // 已结束 abnormalErr: false, schid: 'quit-battle-001', curBo: 3, teamList: [], bracketIdDesc: '', timeDesc: '12/05 16:00', statusDesc: '已结束', isStatusHighList: false, showLiveIcon: false, leftTeamInfo: { ...realBattleData.upTeamInfo, score: 3, scoreDesc: '3', }, rightTeamInfo: { ...realBattleData.downTeamInfo, score: 0, scoreDesc: '0', }, }; // 轮次信息 - 确保包含所有必需属性,提供默认值 const baseRoundInfo = realRoundData.roundInfo as any; const roundInfo: RoundInfo = { start_battle_type: baseRoundInfo?.start_battle_type || 1, show_stime: baseRoundInfo?.show_stime || baseRoundInfo?.ready_time_utime || Math.floor(Date.now() / 1000), ready_time_utime: baseRoundInfo?.ready_time_utime || Math.floor(Date.now() / 1000), bo_type: baseRoundInfo?.bo_type || 3, round_name: baseRoundInfo?.round_name || '比赛轮次', }; // 修正realBattleData的属性名以匹配BattleData接口 const battleData = realBattleData as any; const correctedRealBattleData: BattleData = { nodeItem: { utime: battleData.nodeItem?.utime || Date.now(), }, realStatus: battleData.realStatus || 0, abnormalErr: battleData.abnormalErr || false, schid: battleData.schid || 'default-schid', curBo: battleData.curBo || 1, teamList: battleData.teamList || [], bracketIdDesc: battleData.bracketIdDesc || '', timeDesc: battleData.timeDesc || '', statusDesc: battleData.statusDesc || '', isStatusHighList: battleData.isStatusHighList || false, showLiveIcon: battleData.showLiveIcon || false, leftTeamInfo: battleData.upTeamInfo || battleData.leftTeamInfo || { score: 0, teamid: '', teamname: '', fromBracketDesc: '', teamavatar: '', scoreDesc: '', teamNameDesc: '', teamNameSkeleton: false, teamAvatarSkeleton: false, teamAvatar: '', }, rightTeamInfo: battleData.downTeamInfo || battleData.rightTeamInfo || { score: 0, teamid: '', teamname: '', fromBracketDesc: '', teamavatar: '', scoreDesc: '', teamNameDesc: '', teamNameSkeleton: false, teamAvatarSkeleton: false, teamAvatar: '', }, }; // 轮空状态 - 右边队伍轮空,显示定时开赛时间 const byeBattle: BattleData = { nodeItem: { utime: Date.now(), }, realStatus: 10, // 定时开赛状态 abnormalErr: false, schid: 'bye-battle-001', curBo: 1, teamList: [], bracketIdDesc: '', timeDesc: '12/05 16:00', statusDesc: '开赛', isStatusHighList: false, showLiveIcon: false, leftTeamInfo: { ...realBattleData.upTeamInfo, score: 0, scoreDesc: '0', }, rightTeamInfo: { ...realBattleData.downTeamInfo, score: 0, scoreDesc: '0', teamname: '轮空', teamNameDesc: '轮空', }, }; // 组件属性配置 const componentProps = { // 不同状态的对战数据 finishedBattle, liveBattle, waitingBattle, scheduledBattle, quitBattle, byeBattle, // 轮次信息 roundInfo, // 默认头像配置 byeAvatar: DEFAULT_BYE_AVATAR, pendingAvatar: DEFAULT_PENDING_AVATAR, // 原始数据 realRoundData, realBattleData: correctedRealBattleData, }; return componentProps; } const DEMO_DATA = { ...getMockData(), }; export default DEMO_DATA;