UNPKG

press-next

Version:

Vue3 组件库,支持 Composition API

67 lines (58 loc) 2.08 kB
// 生成mock数据的函数 export function getMockData(length = 4) { // 队伍成员接口 interface TeamMember { id?: string | number; name: string; avatar: string; isCaptain?: boolean; } // 队伍数据接口 interface TeamItemData { teamName: string; teamType?: string; members: TeamMember[]; maxMembers?: number; addButtonText?: string; showCheckbox?: boolean; checked?: boolean; } const teamItem: TeamItemData = { teamName: '王者战队', members: [ { id: 1, name: '队长小明', avatar: 'https://picsum.photos/40/40?random=11', isCaptain: true }, { id: 2, name: '小红', avatar: 'https://picsum.photos/40/40?random=12' }, { id: 3, name: '小刚', avatar: 'https://picsum.photos/40/40?random=13' }, ], addButtonText: '加入战队', showCheckbox: false, checked: false, }; const teamNames = ['王者战队', '荣耀之师', '巅峰战士', '传奇军团', '无敌战队', '钻石联盟', '星耀之光', '最强王者']; const memberNames = ['小明', '小红', '小刚', '小华', '小强', '小美', '小军', '阿强', '阿明', '阿华']; const addButtonTexts = ['加入战队', '申请加入', '等你加入']; return Array.from({ length }).map((_, index) => { const memberCount = Math.floor(Math.random() * 3) + 2; // 2-4个成员 const members: TeamMember[] = []; for (let j = 0; j < memberCount; j += 1) { members.push({ id: index * 10 + j + 1, name: j === 0 ? `队长${memberNames[j % memberNames.length]}` : memberNames[j % memberNames.length], avatar: `https://picsum.photos/40/40?random=${index * 10 + j + 1}`, isCaptain: j === 0, }); } return { ...teamItem, teamName: `${teamNames[index % teamNames.length]}${index + 1}`, members, addButtonText: addButtonTexts[index % addButtonTexts.length], showCheckbox: index % 3 === 0, checked: index % 4 === 0, }; }); } const DEMO_DATA = { teamList: getMockData(4), }; export default DEMO_DATA;