mirror of
https://github.com/cjo4m06/mcp-shrimp-task-manager.git
synced 2025-07-27 08:32:27 +08:00
更新 readTasks 函數以將日期字串轉換為 Date 物件,確保任務的時間屬性正確處理。
This commit is contained in:
parent
26ee08e8ca
commit
12c6d425d3
@ -32,7 +32,15 @@ async function ensureDataDir() {
|
|||||||
async function readTasks(): Promise<Task[]> {
|
async function readTasks(): Promise<Task[]> {
|
||||||
await ensureDataDir();
|
await ensureDataDir();
|
||||||
const data = await fs.readFile(TASKS_FILE, "utf-8");
|
const data = await fs.readFile(TASKS_FILE, "utf-8");
|
||||||
return JSON.parse(data).tasks;
|
const tasks = JSON.parse(data).tasks;
|
||||||
|
|
||||||
|
// 將日期字串轉換回 Date 物件
|
||||||
|
return tasks.map((task: any) => ({
|
||||||
|
...task,
|
||||||
|
createdAt: task.createdAt ? new Date(task.createdAt) : new Date(),
|
||||||
|
updatedAt: task.updatedAt ? new Date(task.updatedAt) : new Date(),
|
||||||
|
completedAt: task.completedAt ? new Date(task.completedAt) : undefined,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 寫入所有任務
|
// 寫入所有任務
|
||||||
|
Loading…
x
Reference in New Issue
Block a user