From 8568da0e4689756b301d962403688b353b1ef184 Mon Sep 17 00:00:00 2001 From: naeeo Date: Tue, 29 Sep 2026 22:38:54 +0800 Subject: [PATCH] Show build platform badge on build list and task detail pages --- rdgenerator/models.py | 5 +++++ rdgenerator/static/rdgenerator/css/app.css | 2 ++ rdgenerator/templates/failure.html | 3 ++- rdgenerator/templates/generated.html | 1 + rdgenerator/templates/my_builds.html | 4 +++- rdgenerator/templates/waiting.html | 1 + rdgenerator/views.py | 2 ++ 7 files changed, 16 insertions(+), 2 deletions(-) diff --git a/rdgenerator/models.py b/rdgenerator/models.py index 42f0252..05b616e 100644 --- a/rdgenerator/models.py +++ b/rdgenerator/models.py @@ -98,6 +98,11 @@ class GithubRun(models.Model): """任务所属构建平台的展示名(用于日志链接等文案)。""" return "Gitea Actions" if (self.backend or "github") == "gitea" else "GitHub Actions" + @property + def backend_badge_class(self): + """任务所属构建平台对应的徽章样式类。""" + return "badge-gitea" if (self.backend or "github") == "gitea" else "badge-github" + def short_uuid(self): return self.uuid[:8] if len(self.uuid) >= 8 else self.uuid diff --git a/rdgenerator/static/rdgenerator/css/app.css b/rdgenerator/static/rdgenerator/css/app.css index 1a1c33e..48a14b9 100644 --- a/rdgenerator/static/rdgenerator/css/app.css +++ b/rdgenerator/static/rdgenerator/css/app.css @@ -453,6 +453,8 @@ input[type="file"].form-control::-webkit-file-upload-button { .badge-warning { background: var(--warning-bg); color: var(--warning); } .badge-danger { background: var(--danger-bg); color: #b91c1c; } .badge-secondary { background: #f1f3f7; color: var(--text-muted); } +.badge-github { background: #24292f; color: #fff; } +.badge-gitea { background: #e6f4d7; color: #4a7a13; } .badge-dot::before { content: ""; display: inline-block; diff --git a/rdgenerator/templates/failure.html b/rdgenerator/templates/failure.html index 1d6025f..08aceda 100644 --- a/rdgenerator/templates/failure.html +++ b/rdgenerator/templates/failure.html @@ -10,7 +10,8 @@

构建未能完成

任务状态:{{ status_label }}
- 配置名称:{{ filename }} + 配置名称:{{ filename }}
+ 构建平台:{{ backend_label }}

diff --git a/rdgenerator/templates/generated.html b/rdgenerator/templates/generated.html index 19b65cd..1e2bfaf 100644 --- a/rdgenerator/templates/generated.html +++ b/rdgenerator/templates/generated.html @@ -11,6 +11,7 @@

配置名称:{{ filename }} · 任务编号:{{ uuid }}
+ 构建平台:{{ backend_label }}
请选择与目标系统对应的安装包下载。

diff --git a/rdgenerator/templates/my_builds.html b/rdgenerator/templates/my_builds.html index 2e35938..3d54dd3 100644 --- a/rdgenerator/templates/my_builds.html +++ b/rdgenerator/templates/my_builds.html @@ -16,7 +16,8 @@ 提交时间 配置名称 - 平台 + 目标平台 + 构建平台 状态 任务编号 操作 @@ -28,6 +29,7 @@ {{ run.created_at|date:"Y-m-d H:i" }} {{ run.filename|default:"—" }} {{ run.platform_label }} + {{ run.backend_label }} {{ run.status_label }} {{ run.short_uuid }} diff --git a/rdgenerator/templates/waiting.html b/rdgenerator/templates/waiting.html index 0ee485a..964536c 100644 --- a/rdgenerator/templates/waiting.html +++ b/rdgenerator/templates/waiting.html @@ -25,6 +25,7 @@
任务信息
配置名称:{{ filename }}
目标平台:{{ platform }}
+
构建平台:{{ backend_label }}
{% if log_url %}
diff --git a/rdgenerator/views.py b/rdgenerator/views.py index d972b40..698b60a 100644 --- a/rdgenerator/views.py +++ b/rdgenerator/views.py @@ -429,6 +429,7 @@ def generator_view(request): 'platform': result['platform'], 'log_url': result['log_url'], 'backend_label': result['run'].backend_label, + 'backend_badge_class': result['run'].backend_badge_class, }) else: messages.error(request, result['error']) @@ -473,6 +474,7 @@ def check_for_file(request): 'status_badge': status_badge, 'log_url': github_log_url, 'backend_label': gh_run.backend_label, + 'backend_badge_class': gh_run.backend_badge_class, } if gh_run.status == "success":