UNPKG

press-next

Version:

Vue3 组件库,支持 Composition API

136 lines (123 loc) 3.07 kB
export interface CountDownConfig { time: number; customClass?: string; yearLabel?: string; monthLabel?: string; dayLabel?: string; hourLabel?: string; minuteLabel?: string; secondLabel?: string; showYear?: boolean; showMonth?: boolean; showDay?: boolean; showHour?: boolean; showMinute?: boolean; showSecond?: boolean; separator?: string; } export function getMockData(): CountDownConfig { // 计算25天16小时18分后的时间戳 const time = 25 * 24 * 60 * 60 * 1000 + 16 * 60 * 60 * 1000 + 18 * 60 * 1000; // 组件属性配置 const componentProps: CountDownConfig = { time, customClass: 'count-down-normal-style', dayLabel: '天', hourLabel: '时', minuteLabel: '分', showDay: true, showHour: true, showMinute: true, separator: ':', }; return componentProps; } // 预设配置:默认中文 export function getDefaultConfig(): CountDownConfig { return getMockData(); } // 预设配置:英文标签 export function getEnglishConfig(): CountDownConfig { const time = 25 * 24 * 60 * 60 * 1000 + 16 * 60 * 60 * 1000 + 18 * 60 * 1000; return { time, dayLabel: 'D', hourLabel: 'H', minuteLabel: 'M', }; } // 预设配置:仅时分 export function getHourMinuteConfig(): CountDownConfig { const time = 16 * 60 * 60 * 1000 + 18 * 60 * 1000; return { time, showDay: false, hourLabel: '时', minuteLabel: '分', }; } // 预设配置:自定义分隔符 export function getCustomSeparatorConfig(): CountDownConfig { const time = 25 * 24 * 60 * 60 * 1000 + 16 * 60 * 60 * 1000 + 18 * 60 * 1000; return { time, separator: '|', }; } // 预设配置:显示年月日 export function getYearMonthDayConfig(): CountDownConfig { // 2年3个月15天 const time = 2 * 365 * 24 * 60 * 60 * 1000 + 3 * 30 * 24 * 60 * 60 * 1000 + 15 * 24 * 60 * 60 * 1000; return { time, showYear: true, showMonth: true, showDay: true, showHour: false, showMinute: false, yearLabel: '年', monthLabel: '月', dayLabel: '天', }; } // 预设配置:完整时间(年月日时分) export function getFullTimeConfig(): CountDownConfig { // 1年2个月10天5小时30分 const time = 1 * 365 * 24 * 60 * 60 * 1000 + 2 * 30 * 24 * 60 * 60 * 1000 + 10 * 24 * 60 * 60 * 1000 + 5 * 60 * 60 * 1000 + 30 * 60 * 1000; return { time, showYear: true, showMonth: true, showDay: true, showHour: true, showMinute: true, yearLabel: '年', monthLabel: '月', dayLabel: '天', hourLabel: '时', minuteLabel: '分', }; } // 预设配置:仅年月 export function getYearMonthConfig(): CountDownConfig { // 3年6个月 const time = 3 * 365 * 24 * 60 * 60 * 1000 + 6 * 30 * 24 * 60 * 60 * 1000; return { time, showYear: true, showMonth: true, showDay: false, showHour: false, showMinute: false, yearLabel: '年', monthLabel: '月', }; } const DEMO_DATA = { ...getMockData(), }; export default DEMO_DATA;