press-next
Version:
Vue3 组件库,支持 Composition API
75 lines (62 loc) • 1.85 kB
text/typescript
// 用户信息接口
export interface UserInfo {
nickname: string; // 用户昵称
avatar?: string; // 用户头像
killCount?: number; // 击杀数
}
// 按钮配置接口
export interface CtrlButton {
text: string; // 按钮文本
type?: 'primary' | 'default'; // 按钮类型
action?: string; // 按钮操作标识
}
export function getMockData() {
// 用户信息数据
const userInfo: UserInfo = {
nickname: '用户昵称最长十个字',
avatar: 'https://avatars.githubusercontent.com/u/9064066?v=4',
killCount: 12,
};
// 用户信息数据 - 长昵称测试
const longNicknameUser: UserInfo = {
nickname: '这是一个非常长的用户昵称用来测试省略号效果',
avatar: 'https://avatars.githubusercontent.com/u/6128107?v=4',
killCount: 25,
};
// 用户信息数据 - 无头像
const noAvatarUser: UserInfo = {
nickname: '无头像用户',
killCount: 8,
};
// 默认按钮配置(2个)
const defaultButtons: CtrlButton[] = [
{ text: '查看榜单', type: 'default', action: 'viewRanking' },
{ text: '去对局', type: 'primary', action: 'goToMatch' },
];
// 单按钮配置
const singleButton: CtrlButton[] = [
{ text: '开始比赛', type: 'primary', action: 'startMatch' },
];
// 自定义双按钮配置
const customButtons: CtrlButton[] = [
{ text: '分享战绩', type: 'default', action: 'share' },
{ text: '继续游戏', type: 'primary', action: 'continue' },
];
// 组件属性配置
const componentProps = {
// 基础用法
userInfo,
rankText: '第1名',
ctrlButtons: defaultButtons,
// 其他测试数据
longNicknameUser,
noAvatarUser,
singleButton,
customButtons,
};
return componentProps;
}
const DEMO_DATA = {
...getMockData(),
};
export default DEMO_DATA;