From 9ad4d09f2a50c92a749c9690bc454690ec2f759b Mon Sep 17 00:00:00 2001 From: iHeyTang Date: Tue, 19 Aug 2025 15:24:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=BC=BA=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E7=BB=93=E6=9E=9C=E3=80=81=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=92=8C=E5=AE=8C=E6=88=90=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=9A=84=E6=98=BE=E7=A4=BA=EF=BC=8C=E4=BC=98=E5=8C=96=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E6=A0=B7=E5=BC=8F=E5=92=8C=E6=95=B0=E6=8D=AE=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- workflow_service/routes/run.py | 3 +++ workflow_service/static/css/monitor.css | 25 +++++++++++++++++ workflow_service/static/js/monitor.js | 36 ++++++++++++++++++++++++- 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/workflow_service/routes/run.py b/workflow_service/routes/run.py index b13a63d..0b19eb2 100644 --- a/workflow_service/routes/run.py +++ b/workflow_service/routes/run.py @@ -92,6 +92,9 @@ async def get_runs( "created_at": run.get("created_at"), "updated_at": run.get("updated_at"), "api_spec": run.get("api_spec"), + "result": run.get("result"), # 添加任务结果 + "error_message": run.get("error_message"), # 添加错误信息 + "completed_at": run.get("completed_at"), # 添加完成时间 } ) diff --git a/workflow_service/static/css/monitor.css b/workflow_service/static/css/monitor.css index b9814d1..c3c1514 100644 --- a/workflow_service/static/css/monitor.css +++ b/workflow_service/static/css/monitor.css @@ -282,6 +282,31 @@ body { .task-meta { color: #7f8c8d; font-size: 0.85em; + margin-bottom: 8px; +} + +.task-meta > div { + margin-bottom: 4px; +} + +.task-result { + color: #27ae60; + font-size: 0.85em; + margin-top: 8px; + padding: 8px; + background: #f0fff4; + border-radius: 6px; + border-left: 3px solid #27ae60; +} + +.task-error { + color: #e74c3c; + font-size: 0.85em; + margin-top: 8px; + padding: 8px; + background: #fff5f5; + border-radius: 6px; + border-left: 3px solid #e74c3c; } .error-message { diff --git a/workflow_service/static/js/monitor.js b/workflow_service/static/js/monitor.js index 2150047..9a4c113 100644 --- a/workflow_service/static/js/monitor.js +++ b/workflow_service/static/js/monitor.js @@ -112,6 +112,37 @@ function updateRecentTasks(tasks) { 'failed': '失败' }[task.status] || task.status; + // 格式化时间 + const formatTime = (timeStr) => { + if (!timeStr) return 'N/A'; + try { + return new Date(timeStr).toLocaleString(); + } catch { + return timeStr; + } + }; + + // 格式化结果数据 + const formatResult = (result) => { + if (!result) return '暂无结果'; + try { + const parsed = JSON.parse(result); + if (typeof parsed === 'object') { + // 如果是对象,尝试提取关键信息 + if (parsed.images && Array.isArray(parsed.images)) { + return `生成图片: ${parsed.images.length} 张`; + } + if (parsed.output && typeof parsed.output === 'object') { + return `输出数据: ${Object.keys(parsed.output).length} 项`; + } + return `结果数据: ${JSON.stringify(parsed).substring(0, 100)}...`; + } + return `结果: ${String(result).substring(0, 100)}...`; + } catch { + return `结果: ${String(result).substring(0, 100)}...`; + } + }; + container.innerHTML += `
@@ -120,8 +151,11 @@ function updateRecentTasks(tasks) {
ID: ${task.id}
-
创建时间: ${new Date(task.created_at).toLocaleString()}
+
创建时间: ${formatTime(task.created_at)}
+ ${task.completed_at ? `
完成时间: ${formatTime(task.completed_at)}
` : ''}
+ ${task.error_message ? `
❌ 错误: ${task.error_message}
` : ''} + ${task.result ? `
📊 ${formatResult(task.result)}
` : ''}
`; });