diff --git a/src/frontend/src/components/EdictBoard.tsx b/src/frontend/src/components/EdictBoard.tsx index cfab024..4f0bed9 100644 --- a/src/frontend/src/components/EdictBoard.tsx +++ b/src/frontend/src/components/EdictBoard.tsx @@ -333,6 +333,45 @@ export default function EdictBoard() { } catch { toast('网络错误', 'err'); } }; + // 项目操作处理 + const handleProjectAction = async (action: 'archive' | 'delete', projectId: string) => { + setShowProjectAction(false); + const projName = projects[projectId]?.name || projectId; + setShowProjectConfirm({ id: projectId, name: projName, action }); + }; + + const confirmProjectAction = async () => { + if (!showProjectConfirm) return; + const { id, action } = showProjectConfirm; + try { + const res = await fetch(`/api/projects/${id}/${action === 'archive' ? 'archive' : ''}`, { + method: action === 'archive' ? 'POST' : 'DELETE', + }); + if (res.ok) { + toast(action === 'archive' ? `📦 已归档 ${id}` : `🗑️ 已删除 ${id}`); + setSelectedProjectId(''); + loadLive(); + } else { + toast('操作失败', 'err'); + } + } catch { toast('网络错误', 'err'); } + setShowProjectConfirm(null); + }; + + // 新建项目 + const handleCreateProject = async (id: string, name: string) => { + try { + const res = await fetch('/api/projects', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ id, name }), + }); + if (res.ok) { toast(`✅ 已创建 ${name}`); loadLive(); setSelectedProjectId(id); } + else { const d = await res.json(); toast(d.detail || '创建失败', 'err'); } + } catch { toast('网络错误', 'err'); } + setShowNewProject(false); + }; + const tasks = v2tasks as V2Task[]; // 第 1 行筛选器:全部/活跃/归档