138 lines
3.2 KiB
Vue
138 lines
3.2 KiB
Vue
<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;
|
||
}
|
||
|
||
/* 状态徽章与同排动作按钮共用一套尺寸(12px 字号 + 6px 10px 内边距),
|
||
否则徽章比按钮矮一截、字也小一号——各 Tab 的按钮样式自己写,徽章只有这里一处。 */
|
||
.status {
|
||
padding: 6px 10px;
|
||
border-radius: 6px;
|
||
font-size: 12px;
|
||
white-space: nowrap;
|
||
}
|
||
|
||
.status.success {
|
||
background: rgba(46, 204, 113, .18);
|
||
color: #2ecc71;
|
||
}
|
||
|
||
/* 「失败」永远和「删除」并排出现:底色与文字色取同一个红(rgba .12 + #ff8f8f),
|
||
别再用更浓的 .18 + #ff6b6b,否则同一排里徽章比按钮更刺眼。 */
|
||
.status.failed {
|
||
background: rgba(231, 76, 60, .12);
|
||
color: #ff8f8f;
|
||
}
|
||
|
||
.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>
|