!70 czh-20260630-修复计划滚动条问题
* czh-20260630-修复计划滚动条问题 * czh-AI-20260630-新增功能-帮助中心菜单项 * czh-AI-20260630-新增功能-帮助中心常量导出 * czh-AI-20260630-新增功能-帮助中心环境变量配置 * czh-20260630-优化拖拽效果 * czh-20260630-增加乐观更新;优化抽屉界面
This commit is contained in:
@@ -844,19 +844,48 @@
|
||||
}
|
||||
}
|
||||
|
||||
function findTaskInGroups(taskId: string): { group: TaskGroup; task: TaskItem } | null {
|
||||
for (const g of taskListGroups.value) {
|
||||
for (const l of g.taskLists) {
|
||||
for (const tg of l.groups) {
|
||||
const t = tg.tasks.find((t: TaskItem) => t.id === taskId);
|
||||
if (t) return { group: tg, task: t };
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async function onToggleTask(taskId: string) {
|
||||
// 乐观更新:立刻切换 UI
|
||||
if (isFlatView.value) {
|
||||
const idx = flatTasks.value.findIndex((t) => t.id === taskId);
|
||||
if (idx >= 0) {
|
||||
flatTasks.value[idx] = { ...flatTasks.value[idx], completed: !flatTasks.value[idx].completed };
|
||||
}
|
||||
} else {
|
||||
const found = findTaskInGroups(taskId);
|
||||
if (found) {
|
||||
found.task.completed = !found.task.completed;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await toggleTaskStatus({ id: taskId });
|
||||
} catch (e) {
|
||||
console.error('[TaskList] 切换任务状态失败', e);
|
||||
// 回滚
|
||||
if (isFlatView.value) {
|
||||
const idx = flatTasks.value.findIndex((t) => t.id === taskId);
|
||||
if (idx >= 0) {
|
||||
flatTasks.value[idx] = { ...flatTasks.value[idx], completed: !flatTasks.value[idx].completed };
|
||||
}
|
||||
} else if (currentListId.value) {
|
||||
await loadTasks(currentListId.value);
|
||||
} else {
|
||||
const found = findTaskInGroups(taskId);
|
||||
if (found) {
|
||||
found.task.completed = !found.task.completed;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('[TaskList] 切换任务状态失败', e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1057,16 +1086,41 @@
|
||||
}
|
||||
|
||||
async function onToggleSubTask(taskId: string) {
|
||||
// 乐观更新:立刻切换子任务完成状态
|
||||
if (isFlatView.value) {
|
||||
const idx = flatTasks.value.findIndex((t) => t.id === taskId);
|
||||
if (idx >= 0) {
|
||||
flatTasks.value[idx] = { ...flatTasks.value[idx], completed: !flatTasks.value[idx].completed };
|
||||
}
|
||||
} else {
|
||||
const found = findTaskInGroups(taskId);
|
||||
if (found) {
|
||||
found.task.completed = !found.task.completed;
|
||||
}
|
||||
}
|
||||
refreshDrawer();
|
||||
|
||||
try {
|
||||
await toggleTaskStatus({ id: taskId });
|
||||
if (isFlatView.value) {
|
||||
await refreshFlatViewTasks();
|
||||
} else if (currentListId.value) {
|
||||
await loadTasks(currentListId.value);
|
||||
refreshDrawer();
|
||||
}
|
||||
refreshDrawer();
|
||||
} catch (e) {
|
||||
console.error('[TaskList] 切换子任务状态失败', e);
|
||||
// 回滚
|
||||
if (isFlatView.value) {
|
||||
const idx = flatTasks.value.findIndex((t) => t.id === taskId);
|
||||
if (idx >= 0) {
|
||||
flatTasks.value[idx] = { ...flatTasks.value[idx], completed: !flatTasks.value[idx].completed };
|
||||
}
|
||||
} else {
|
||||
const found = findTaskInGroups(taskId);
|
||||
if (found) {
|
||||
found.task.completed = !found.task.completed;
|
||||
}
|
||||
}
|
||||
refreshDrawer();
|
||||
if (currentListId.value) {
|
||||
await loadTasks(currentListId.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user