From 28b365991ba314344dec564331cacf4f43c6151e Mon Sep 17 00:00:00 2001 From: engigu Date: Thu, 25 Dec 2025 19:16:58 +0800 Subject: [PATCH] fix: task list icon display --- internal/controllers/log_controller.go | 13 ++++++++++--- web/src/api/index.ts | 1 + web/src/views/history/History.vue | 11 ++++++++++- web/src/views/tasks/Tasks.vue | 15 +++++++-------- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/internal/controllers/log_controller.go b/internal/controllers/log_controller.go index e9a6403..099d793 100644 --- a/internal/controllers/log_controller.go +++ b/internal/controllers/log_controller.go @@ -20,6 +20,7 @@ type TaskLogResponse struct { ID uint `json:"id"` TaskID uint `json:"task_id"` TaskName string `json:"task_name"` + TaskType string `json:"task_type"` Command string `json:"command"` Status string `json:"status"` Duration int64 `json:"duration"` @@ -61,17 +62,23 @@ func (lc *LogController) GetLogs(c *gin.Context) { var tasks []models.Task database.DB.Where("id IN ?", taskIDList).Find(&tasks) - taskMap := make(map[uint]string) + taskMap := make(map[uint]models.Task) for _, t := range tasks { - taskMap[t.ID] = t.Name + taskMap[t.ID] = t } result := make([]TaskLogResponse, len(logs)) for i, log := range logs { + task := taskMap[log.TaskID] + taskType := task.Type + if taskType == "" { + taskType = "task" + } result[i] = TaskLogResponse{ ID: log.ID, TaskID: log.TaskID, - TaskName: taskMap[log.TaskID], + TaskName: task.Name, + TaskType: taskType, Command: log.Command, Status: log.Status, Duration: log.Duration, diff --git a/web/src/api/index.ts b/web/src/api/index.ts index c9ff6d4..46436d1 100644 --- a/web/src/api/index.ts +++ b/web/src/api/index.ts @@ -285,6 +285,7 @@ export interface TaskLog { id: number task_id: number task_name: string + task_type: string command: string status: string duration: number diff --git a/web/src/views/history/History.vue b/web/src/views/history/History.vue index 09e641b..a03bcb2 100644 --- a/web/src/views/history/History.vue +++ b/web/src/views/history/History.vue @@ -5,7 +5,7 @@ import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import Pagination from '@/components/Pagination.vue' import LogViewer from './LogViewer.vue' -import { RefreshCw, X, Search, Maximize2 } from 'lucide-vue-next' +import { RefreshCw, X, Search, Maximize2, GitBranch, Terminal } from 'lucide-vue-next' import { api, type TaskLog, type LogDetail } from '@/api' import { toast } from 'vue-sonner' import pako from 'pako' @@ -101,6 +101,10 @@ function formatDuration(ms: number): string { return `${(ms / 60000).toFixed(1)}m` } +function getTaskTypeTitle(type: string) { + return type === 'repo' ? '仓库同步' : '普通任务' +} + onMounted(() => { // 从 URL 读取 task_id 参数 const taskIdParam = route.query.task_id @@ -142,6 +146,7 @@ watch(() => route.query.task_id, (newTaskId) => {
ID + 类型 任务名称 命令 状态 @@ -163,6 +168,10 @@ watch(() => route.query.task_id, (newTaskId) => { @click="selectLog(log)" > #{{ log.id }} + + + + diff --git a/web/src/views/tasks/Tasks.vue b/web/src/views/tasks/Tasks.vue index ac32dd5..be61445 100644 --- a/web/src/views/tasks/Tasks.vue +++ b/web/src/views/tasks/Tasks.vue @@ -11,7 +11,7 @@ import { Badge } from '@/components/ui/badge' import { Checkbox } from '@/components/ui/checkbox' import Pagination from '@/components/Pagination.vue' import DirTreeSelect from '@/components/DirTreeSelect.vue' -import { Plus, Play, Pencil, Trash2, Search, ScrollText, ChevronDown, X, GitBranch } from 'lucide-vue-next' +import { Plus, Play, Pencil, Trash2, Search, ScrollText, ChevronDown, X, GitBranch, Terminal } from 'lucide-vue-next' import { api, type Task, type EnvVar, type RepoConfig } from '@/api' import { toast } from 'vue-sonner' import { useSiteSettings } from '@/composables/useSiteSettings' @@ -267,8 +267,8 @@ function viewLogs(taskId: number) { router.push({ path: '/history', query: { task_id: String(taskId) } }) } -function getTaskTypeLabel(type: string) { - return type === 'repo' ? '仓库' : '普通' +function getTaskTypeTitle(type: string) { + return type === 'repo' ? '仓库同步' : '普通任务' } onMounted(() => { @@ -302,7 +302,7 @@ onMounted(() => {
ID - 类型 + 类型 名称 命令/地址 @@ -322,10 +322,9 @@ onMounted(() => { class="flex items-center gap-4 px-4 py-2 hover:bg-muted/50 transition-colors" > #{{ task.id }} - - - {{ getTaskTypeLabel(task.type || 'task') }} - + + +