/** 任務列表組件 */ const TaskList = ({ tasks, currentTaskId, onCancel, onRemove }) => { if (!tasks || tasks.length === 0) { return null; } const getStatusColor = (status) => { switch (status) { case 'running': return 'bg-blue-100 text-blue-800 border-blue-500'; case 'pending': return 'bg-yellow-100 text-yellow-800 border-yellow-500'; case 'completed': return 'bg-green-100 text-green-800 border-green-500'; case 'cancelled': return 'bg-gray-100 text-gray-800 border-gray-500'; case 'failed': return 'bg-red-100 text-red-800 border-red-500'; default: return 'bg-gray-100 text-gray-800 border-gray-500'; } }; const getStatusText = (status) => { switch (status) { case 'pending': return '等待中'; case 'running': return '執行中'; case 'completed': return '已完成'; case 'cancelled': return '已取消'; case 'failed': return '執行失敗'; default: return status; } }; // 計算等待中的任務位置 const getPendingPosition = (task, allTasks) => { if (task.status !== 'pending') { return null; } const pendingTasks = allTasks.filter(t => t.status === 'pending'); const index = pendingTasks.findIndex(t => t.task_id === task.task_id); return index >= 0 ? index + 1 : null; }; return (