今日任务动态
const raw = dv.current()["journal-date"];
const dateStr = typeof raw?.toFormat === "function" ? raw.toFormat("yyyy-MM-dd") : String(raw);
const start = dv.date(dateStr);
const end = start.plus({ days: 1 });
function renderTasks(tasks, depth = 0) {
let lines = [];
for (const t of tasks) {
const indent = depth > 0 ? " ".repeat(depth) : "";
lines.push(indent + "- " + t.text);
if (t.subtasks && t.subtasks.length > 0) {
lines = lines.concat(renderTasks(t.subtasks, depth + 1));
}
}
return lines;
}
function getRootTasks(allTasks) {
const subLines = new Set();
for (const t of allTasks) {
if (t.subtasks) for (const s of t.subtasks) subLines.add(s.line);
}
return allTasks.filter(t => !subLines.has(t.line));
}
dv.table(["任务", "待办项"],
dv.pages('"CYG-Works/需求任务-Tasks"')
.where(p => {
if (p.file.cday >= start && p.file.cday < end) return true;
return p.file.lists.some(item => item.text.includes(dateStr));
})
.sort(p => p.file.mday, "desc")
.map(p => [
p.file.link,
renderTasks(getRootTasks(p.file.tasks)).join("\n")
])
);
工作日志
const raw = dv.current()["journal-date"];
const dateStr = typeof raw?.toFormat === "function" ? raw.toFormat("yyyy-MM-dd") : String(raw);
function collectChildren(item, depth = 0) {
let lines = [];
for (const child of (item.children || [])) {
const prefix = depth > 0 ? " ".repeat(depth) : " ";
lines.push(prefix + item.symbol + " " + child.text);
lines = lines.concat(collectChildren(child, depth + 1));
}
return lines;
}
const rows = [];
const pages = dv.pages('"CYG-Works/需求任务-Tasks"').sort(p => p.file.name, "desc");
for (const page of pages) {
const entries = page.file.lists.where(item => !item.task && item.text.includes(dateStr));
let first = true;
for (const entry of entries) {
const time = entry.text.trim();
const content = collectChildren(entry).join("\n");
rows.push([first ? page.file.link : "", time, content]);
first = false;
}
}
dv.table(["任务", "时间", "内容"], rows);
备注