From: Codebuddy Date: Mon, 7 Sep 2026 09:35:09 +0000 (+0800) Subject: fix(frontend): 编辑任务名称时暂停列表自动刷新,避免输入框被刷新清空 X-Git-Url: http://acesimba.cloud/gitweb/?a=commitdiff_plain;h=b27d4f2069467887cf54b582de422c7fbfdbfc40;p=codebuddy-web.git fix(frontend): 编辑任务名称时暂停列表自动刷新,避免输入框被刷新清空 --- diff --git a/frontend/index.html b/frontend/index.html index 9f9b250..46c2a3d 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -638,6 +638,7 @@ body { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; heigh // 列表页自动刷新:进入时启动,离开/退出时停止 let pickerTimer = null; let pickerRefreshing = false; + let editingTaskId = null; // 正在内联编辑的任务 id;非 null 时暂停自动刷新重建,避免打断输入 function startPickerRefresh() { stopPickerRefresh(); pickerTimer = setInterval(refreshTasks, 5000); @@ -647,6 +648,7 @@ body { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; heigh } async function refreshTasks() { if (pickerRefreshing) return; + if (editingTaskId) return; // 正在编辑任务名称/描述/分组,跳过本轮重建,避免输入框被刷新清空 pickerRefreshing = true; try { await renderTasks(); @@ -887,6 +889,7 @@ body { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; heigh // 进入卡片内联编辑模式:编辑名称、描述与所属分组 function enterEditMode(card, t) { + editingTaskId = t.id; const curGroup = t.group || ''; const groupOpts = '' + groupsCache.map(g => @@ -911,7 +914,7 @@ body { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; heigh descInput.addEventListener('input', updateCounter); nameInput.focus(); nameInput.select(); - card.querySelector('.tc-cancel').onclick = () => renderTasks(); + card.querySelector('.tc-cancel').onclick = () => { editingTaskId = null; renderTasks(); }; card.querySelector('.tc-save').onclick = async () => { const newName = nameInput.value.trim(); const newDesc = descInput.value; @@ -922,6 +925,7 @@ body { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; heigh body: JSON.stringify({ name: newName, description: newDesc, group: newGroup }), }); if (!res.ok) { const d = await res.json().catch(()=>({})); alert(d.error || '保存失败'); return; } + editingTaskId = null; await renderTasks(); }; }