Files
noco-auto/scripts/random-data.ts
2025-12-04 14:22:53 +08:00

105 lines
2.5 KiB
TypeScript

type Item = {
Id?: number;
'标题': string;
'描述': string;
'总结': string;
'类型': string;
'启动时间'?: string;
}
const tasks = [{
title: '非任务',
},
{
title: '运行中',
},
{
title: '已停止',
},
{
title: '个人计划',
},
{
title: '已完成',
},
{
title: 'AI自动化'
}
];
const types = [{
title: '每日',
},
{
title: '每周',
},
{
title: '每月',
},
{
title: '每年',
},
{
title: '每年农历',
},
{
title: '备忘',
},
{
title: '归档',
},
{
title: '智能',
},]
export function generateRandomItem(): Item {
const titles = [
'探索未知的宇宙',
'人工智能的未来',
'可持续发展的重要性',
'历史上的伟大人物',
'科技改变生活'
];
const descriptions = [
'这是一段关于宇宙探索的描述,涵盖了最新的发现和理论。',
'本文探讨了人工智能的发展趋势及其对社会的影响。',
'讨论了可持续发展的概念及其在现代社会中的应用。',
'介绍了历史上几位对世界产生重大影响的人物。',
'分析了科技进步如何改变了我们的日常生活。'
];
const summaries = [
'本文总结了宇宙探索的现状和未来方向。',
'总结了人工智能技术的发展及其潜在挑战。',
'概述了可持续发展的关键要素和实践方法。',
'回顾了历史伟人对社会的贡献和影响。',
'总结了科技进步对生活方式的改变。'
];
const randomIndex = Math.floor(Math.random() * titles.length);
// 生成本月的随机时间
const now = new Date();
const year = now.getFullYear();
const month = now.getMonth();
const daysInMonth = new Date(year, month + 1, 0).getDate();
const randomDay = Math.floor(Math.random() * daysInMonth) + 1;
const randomHour = Math.floor(Math.random() * 24);
const randomMinute = Math.floor(Math.random() * 60);
const randomSecond = Math.floor(Math.random() * 60);
const randomDate = new Date(year, month, randomDay, randomHour, randomMinute, randomSecond);
return {
'标题': titles[randomIndex],
'描述': descriptions[randomIndex],
'总结': summaries[randomIndex],
'类型': types[Math.floor(Math.random() * types.length)].title,
'启动时间': randomDate.toISOString(),
};
}
export function generateMultipleRandomItems(count: number): Item[] {
const items: Item[] = [];
for (let i = 0; i < count; i++) {
const item = generateRandomItem();
items.push(item);
}
return items;
}