From dfeedb02f3d99163af48d9ce2c27a3bb615bcfb9 Mon Sep 17 00:00:00 2001 From: ila Date: Tue, 25 Aug 2026 17:51:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=AD=A3=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=B0=9D=E8=AF=95=E7=8A=B6=E6=80=81=E5=B1=95=E7=A4=BA=20(#61)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/chorus/generations/helpers.js | 37 ++++++++++++++++ .../src/views/chorus/generations/index.vue | 5 ++- .../unit/chorus/generation-attempts.spec.js | 43 +++++++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 admin-ui/src/views/chorus/generations/helpers.js create mode 100644 admin-ui/tests/unit/chorus/generation-attempts.spec.js diff --git a/admin-ui/src/views/chorus/generations/helpers.js b/admin-ui/src/views/chorus/generations/helpers.js new file mode 100644 index 0000000..974426c --- /dev/null +++ b/admin-ui/src/views/chorus/generations/helpers.js @@ -0,0 +1,37 @@ +const eventTitle = attempt => { + if (attempt.type === 'lease') return '任务认领' + if (attempt.type === 'local_rate_limit') return '本地限流' + if (attempt.type === 'provider') return attempt.provider_model_id ? `模型 #${attempt.provider_model_id}` : '模型未记录' + return '系统事件' +} + +export function attemptPresentation(value) { + const attempt = value && typeof value === 'object' ? value : {} + const presentation = { + title: eventTitle(attempt), + status: '进行中', + type: 'warning', + timestamp: attempt.finished_at || attempt.started_at || attempt.deferred_until || '' + } + + if (attempt.error_code) { + presentation.status = attempt.error_code + presentation.type = 'danger' + return presentation + } + if (attempt.type === 'lease') { + presentation.status = '已认领' + presentation.type = 'primary' + return presentation + } + if (attempt.type === 'local_rate_limit') { + presentation.status = attempt.deferred_until ? '等待限流窗口' : '限流检查完成' + presentation.type = attempt.deferred_until ? 'warning' : 'info' + return presentation + } + if (attempt.finished_at) { + presentation.status = '成功' + presentation.type = 'success' + } + return presentation +} diff --git a/admin-ui/src/views/chorus/generations/index.vue b/admin-ui/src/views/chorus/generations/index.vue index ded52a9..c1a1693 100644 --- a/admin-ui/src/views/chorus/generations/index.vue +++ b/admin-ui/src/views/chorus/generations/index.vue @@ -11,7 +11,7 @@

选择一条生成记录查看详情

@@ -20,10 +20,11 @@