feat: cron task style fix

This commit is contained in:
engigu
2025-12-21 14:30:59 +08:00
parent f0beb8a654
commit d8b5b75eaf
11 changed files with 174 additions and 67 deletions
+3 -3
View File
@@ -117,12 +117,12 @@ onMounted(loadLogs)
<div class="flex gap-4">
<!-- 日志列表 -->
<div class="flex-1 rounded-lg border bg-card">
<div class="flex-1 min-w-0 rounded-lg border bg-card">
<!-- 表头 -->
<div class="flex items-center gap-4 px-4 py-2 border-b bg-muted/50 text-sm text-muted-foreground font-medium">
<span class="w-12 shrink-0">ID</span>
<span class="w-32 shrink-0">任务名称</span>
<span class="flex-1">命令</span>
<span :class="selectedLog ? 'w-40 shrink-0' : 'flex-1'">命令</span>
<span class="w-12 shrink-0 text-center">状态</span>
<span class="w-20 text-right shrink-0">耗时</span>
<span class="w-40 text-right shrink-0">执行时间</span>
@@ -143,7 +143,7 @@ onMounted(loadLogs)
>
<span class="w-12 shrink-0 text-muted-foreground text-sm">#{{ log.id }}</span>
<span class="w-32 font-medium truncate shrink-0 text-sm">{{ log.task_name }}</span>
<code class="flex-1 text-muted-foreground truncate text-xs bg-muted px-2 py-1 rounded">{{ log.command }}</code>
<code :class="['text-muted-foreground truncate text-xs bg-muted px-2 py-1 rounded', selectedLog ? 'w-40 shrink-0' : 'flex-1']">{{ log.command }}</code>
<span class="w-12 flex justify-center shrink-0">
<span :class="['w-2 h-2 rounded-full', log.status === 'success' ? 'bg-green-500' : log.status === 'failed' ? 'bg-red-500' : 'bg-yellow-500']" />
</span>
@@ -58,15 +58,6 @@ function handlePageChange(page: number) {
loadLogs()
}
function getBrowserInfo(userAgent: string): string {
if (!userAgent) return '未知'
if (userAgent.includes('Chrome')) return 'Chrome'
if (userAgent.includes('Firefox')) return 'Firefox'
if (userAgent.includes('Safari')) return 'Safari'
if (userAgent.includes('Edge')) return 'Edge'
return '其他'
}
onMounted(loadLogs)
</script>
@@ -98,9 +89,8 @@ onMounted(loadLogs)
<div class="flex items-center gap-4 px-4 py-2 border-b bg-muted/50 text-sm text-muted-foreground font-medium">
<span class="w-24 shrink-0">用户名</span>
<span class="w-32 shrink-0">IP 地址</span>
<span class="w-20 shrink-0">浏览器</span>
<span class="w-16 shrink-0 text-center">状态</span>
<span class="flex-1">消息</span>
<span class="flex-1">User Agent</span>
<span class="w-40 shrink-0 text-right">时间</span>
</div>
<!-- 列表 -->
@@ -115,13 +105,12 @@ onMounted(loadLogs)
>
<span class="w-24 shrink-0 font-medium text-sm truncate">{{ log.username }}</span>
<code class="w-32 shrink-0 text-xs text-muted-foreground bg-muted px-2 py-1 rounded">{{ log.ip }}</code>
<span class="w-20 shrink-0 text-xs text-muted-foreground">{{ getBrowserInfo(log.user_agent) }}</span>
<span class="w-16 shrink-0 flex justify-center">
<Badge :variant="log.status === 'success' ? 'default' : 'destructive'" class="text-xs">
{{ log.status === 'success' ? '成功' : '失败' }}
</Badge>
</span>
<span class="flex-1 text-sm text-muted-foreground truncate">{{ log.message }}</span>
<span class="flex-1 text-xs text-muted-foreground truncate" :title="log.user_agent">{{ log.user_agent || '-' }}</span>
<span class="w-40 shrink-0 text-right text-xs text-muted-foreground">{{ log.created_at }}</span>
</div>
</div>
+2 -2
View File
@@ -139,7 +139,7 @@ onMounted(loadTasks)
<span class="w-12 shrink-0">ID</span>
<span class="w-40 shrink-0">名称</span>
<span class="flex-1">命令</span>
<span class="w-28 shrink-0">定时规则</span>
<span class="w-32 shrink-0">定时规则</span>
<span class="w-40 shrink-0">上次执行</span>
<span class="w-40 shrink-0">下次执行</span>
<span class="w-12 shrink-0 text-center">状态</span>
@@ -158,7 +158,7 @@ onMounted(loadTasks)
<span class="w-12 shrink-0 text-muted-foreground text-sm">#{{ task.id }}</span>
<span class="w-40 font-medium truncate shrink-0 text-sm">{{ task.name }}</span>
<code class="flex-1 text-muted-foreground truncate text-xs bg-muted px-2 py-1 rounded">{{ task.command }}</code>
<code class="w-28 shrink-0 text-muted-foreground text-xs bg-muted px-2 py-1 rounded">{{ task.schedule }}</code>
<code class="w-36 shrink-0 text-muted-foreground text-xs bg-muted px-2 py-1 rounded">{{ task.schedule }}</code>
<span class="w-40 shrink-0 text-muted-foreground text-xs">{{ task.last_run || '-' }}</span>
<span class="w-40 shrink-0 text-muted-foreground text-xs">{{ task.next_run || '-' }}</span>
<span class="w-12 flex justify-center shrink-0 cursor-pointer" @click="toggleTask(task, !task.enabled)" :title="task.enabled ? '点击禁用' : '点击启用'">