Files
crawler-plugin/frontend-vue/src/shared/components/tasks/TaskItemCard.vue
T

134 lines
2.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<li class="task-item">
<div class="left">
<span class="id" :title="item.title">{{ item.title || '-' }}</span>
<div class="files">任务 ID:{{ item.taskId ?? '-' }}</div>
<div class="files">开始时间:{{ item.startedAt || '-' }}</div>
<div class="files">结束时间:{{ item.finishedAt || '-' }}</div>
<div v-for="line in item.extraLines || []" :key="line" class="files">{{ line }}</div>
<slot name="extra" :item="item" />
<div v-if="item.progress" class="file-progress">
<div v-if="item.progress.stage || item.progress.countLabel" class="file-progress-meta">
<span>{{ item.progress.stage || '处理中' }}</span>
<span v-if="item.progress.countLabel">{{ item.progress.countLabel }}</span>
<span v-else>总进度 {{ item.progress.percent }}%</span>
</div>
<div class="file-progress-track">
<div class="file-progress-bar" :style="{ width: `${item.progress.percent}%` }"></div>
</div>
</div>
</div>
<div class="task-right">
<span class="status" :class="item.statusClass">{{ item.statusText }}</span>
<slot name="actions" :item="item" />
</div>
</li>
</template>
<script setup lang="ts">
import type { TaskItemView } from './types'
defineProps<{
item: TaskItemView
}>()
</script>
<style scoped>
.task-item {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 12px;
padding: 12px 14px;
border: 1px solid #2e3a52;
border-radius: 8px;
margin-bottom: 8px;
background: #242424;
}
.left {
flex: 1;
min-width: 0;
}
.id {
color: #f5f8fc;
font-size: 13px;
font-weight: 600;
display: block;
margin-bottom: 4px;
word-break: break-all;
}
.files {
color: #5e6878;
font-size: 12px;
line-height: 1.5;
word-break: break-all;
}
.task-right {
display: flex;
gap: 8px;
align-items: center;
flex-wrap: wrap;
flex-shrink: 0;
}
.status {
padding: 4px 10px;
border-radius: 6px;
font-size: 12px;
white-space: nowrap;
}
.status.success {
background: rgba(46, 204, 113, .18);
color: #2ecc71;
}
.status.failed {
background: rgba(231, 76, 60, .18);
color: #ff6b6b;
}
.status.running {
background: rgba(52, 152, 219, .18);
color: #3498db;
}
.status.pending {
background: rgba(149, 165, 166, .18);
color: #a0acbe;
}
.file-progress {
margin-top: 8px;
max-width: 520px;
}
.file-progress-meta {
display: flex;
justify-content: space-between;
gap: 12px;
color: #d8c278;
font-size: 12px;
}
.file-progress-track {
margin-top: 5px;
height: 8px;
border-radius: 999px;
overflow: hidden;
background: #333f55;
border: 1px solid #3b3b3b;
}
.file-progress-bar {
height: 100%;
border-radius: inherit;
background: linear-gradient(90deg, #4aa3ff, #f0c75e);
transition: width .25s ease;
}
</style>