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) => {