generated from template/apps-template
update
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
// import { Life, NocoApi } from '@kevisual/noco/mod.ts';
|
||||
import { Life, NocoApi } from '../mod.ts';
|
||||
import { generateMultipleRandomItems } from './random-data';
|
||||
|
||||
// const token = 'your'
|
||||
// const baseId = 'your_base_id';
|
||||
|
||||
const token = 'CPrDfoajtCjayEYK17wOljE7R2E7DoTIw_7oUnjb'
|
||||
const baseId = 'p1pderowf0zhugt'
|
||||
let tableId = 'mierezd5z73kj26'
|
||||
const token = 'bMLb3rzj9Qz_nOuQ0dj9PRYQbPK_79C2Yfbq5Xae'
|
||||
const baseId = 'p7k66s6p7lss31j'
|
||||
const nocoApi = new NocoApi({
|
||||
baseURL: 'http://localhost:8080',
|
||||
token
|
||||
@@ -14,18 +13,12 @@ const nocoApi = new NocoApi({
|
||||
|
||||
const life = new Life({ nocoApi, baseId });
|
||||
|
||||
// const tableRes = await life.createTable({
|
||||
// title: '测试表格2',
|
||||
// });
|
||||
// tableId = tableRes.data?.id || '';
|
||||
// console.log('tableId', tableId);
|
||||
|
||||
life.nocoApi.record.table = tableId;
|
||||
const datas = generateMultipleRandomItems(1);
|
||||
const tableRes = await life.createTable();
|
||||
console.log('tableRes', tableRes);
|
||||
|
||||
const datas = generateMultipleRandomItems(100);
|
||||
for (const data of datas) {
|
||||
console.log('data', data);
|
||||
const createRes = await life.nocoApi.record.create(data);
|
||||
console.log('createRes', createRes);
|
||||
const createRes = await life.creatItem(data);
|
||||
console.log(createRes);
|
||||
}
|
||||
|
||||
|
||||
21
scripts/get-list.ts
Normal file
21
scripts/get-list.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { Life, NocoApi } from '../mod.ts';
|
||||
import { generateMultipleRandomItems } from './random-data';
|
||||
import util from 'node:util';
|
||||
|
||||
// const token = 'your'
|
||||
// const baseId = 'your_base_id';
|
||||
|
||||
const token = 'Qd7Xvz6Ui3SlzjdaqONZxHd6Gw_STk4sa4HqDKC5'
|
||||
const baseId = 'paqa769bfeh467p'
|
||||
let tableId = 'mz5hmnw8o6qfccf'
|
||||
const nocoApi = new NocoApi({
|
||||
baseURL: 'http://localhost:8080',
|
||||
token,
|
||||
});
|
||||
|
||||
const life = new Life({ nocoApi, baseId, tableId });
|
||||
|
||||
nocoApi.record.table = tableId;
|
||||
const res = await life.nocoApi.record.list()
|
||||
|
||||
console.log('uitl', util.inspect(res, { depth: 4 }));
|
||||
@@ -3,8 +3,52 @@ type Item = {
|
||||
'标题': string;
|
||||
'描述': 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 = [
|
||||
'探索未知的宇宙',
|
||||
@@ -29,23 +73,25 @@ export function generateRandomItem(): Item {
|
||||
'回顾了历史伟人对社会的贡献和影响。',
|
||||
'总结了科技进步对生活方式的改变。'
|
||||
];
|
||||
|
||||
const tagsList = [
|
||||
['宇宙', '探索', '科学'],
|
||||
['人工智能', '技术', '未来'],
|
||||
['可持续发展', '环境', '社会'],
|
||||
['历史', '人物', '影响'],
|
||||
['科技', '生活', '进步']
|
||||
];
|
||||
|
||||
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],
|
||||
// '标签': tagsList[randomIndex],
|
||||
'标签': ['b'],
|
||||
'类型': types[Math.floor(Math.random() * types.length)].title,
|
||||
'启动时间': randomDate.toISOString(),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -53,7 +99,6 @@ export function generateMultipleRandomItems(count: number): Item[] {
|
||||
const items: Item[] = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
const item = generateRandomItem();
|
||||
item.Id = i + 1;
|
||||
items.push(item);
|
||||
}
|
||||
return items;
|
||||
|
||||
Reference in New Issue
Block a user