Spaces:
Sleeping
Sleeping
refactor(HistoryDatabase): update card display to show round progress and time
Browse files- Changed card header to display round progress instead of status.
- Updated card footer to show formatted time instead of rounds.
- Introduced new methods for calculating progress class and formatting time.
- Adjusted styles for progress display and refined layout for better responsiveness.
frontend/src/components/HistoryDatabase.vue
CHANGED
|
@@ -28,11 +28,11 @@
|
|
| 28 |
@mouseleave="hoveringCard = null"
|
| 29 |
@click="navigateToProject(project)"
|
| 30 |
>
|
| 31 |
-
<!-- 卡片头部:simulation_id和
|
| 32 |
<div class="card-header">
|
| 33 |
<span class="card-id">{{ formatSimulationId(project.simulation_id) }}</span>
|
| 34 |
-
<span class="card-
|
| 35 |
-
<span class="status-dot">●</span> {{
|
| 36 |
</span>
|
| 37 |
</div>
|
| 38 |
|
|
@@ -68,7 +68,7 @@
|
|
| 68 |
<!-- 卡片底部 -->
|
| 69 |
<div class="card-footer">
|
| 70 |
<span class="card-date">{{ formatDate(project.created_at) }}</span>
|
| 71 |
-
<span class="card-
|
| 72 |
</div>
|
| 73 |
|
| 74 |
<!-- 底部装饰线 (hover时展开) -->
|
|
@@ -128,8 +128,8 @@ const containerStyle = computed(() => {
|
|
| 128 |
}
|
| 129 |
|
| 130 |
const rows = Math.ceil(total / CARDS_PER_ROW)
|
| 131 |
-
// 计算实际需要的高度:行数 * 卡片高度 + (行数-1) * 间距 +
|
| 132 |
-
const expandedHeight = rows * CARD_HEIGHT + (rows - 1) * CARD_GAP +
|
| 133 |
|
| 134 |
return { minHeight: `${expandedHeight}px` }
|
| 135 |
})
|
|
@@ -186,33 +186,24 @@ const getCardStyle = (index) => {
|
|
| 186 |
}
|
| 187 |
}
|
| 188 |
|
| 189 |
-
// 获取
|
| 190 |
-
const
|
| 191 |
-
const
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
}
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
const getStatusText = (status) => {
|
| 204 |
-
const textMap = {
|
| 205 |
-
completed: 'COMPLETED',
|
| 206 |
-
running: 'PROCESSING',
|
| 207 |
-
ready: 'READY',
|
| 208 |
-
failed: 'FAILED',
|
| 209 |
-
preparing: 'PREPARING',
|
| 210 |
-
created: 'CREATED'
|
| 211 |
}
|
| 212 |
-
return textMap[status] || 'PENDING'
|
| 213 |
}
|
| 214 |
|
| 215 |
-
// 格式化日期
|
| 216 |
const formatDate = (dateStr) => {
|
| 217 |
if (!dateStr) return ''
|
| 218 |
try {
|
|
@@ -223,6 +214,19 @@ const formatDate = (dateStr) => {
|
|
| 223 |
}
|
| 224 |
}
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
// 截断文本
|
| 227 |
const truncateText = (text, maxLength) => {
|
| 228 |
if (!text) return ''
|
|
@@ -377,9 +381,9 @@ onMounted(() => {
|
|
| 377 |
},
|
| 378 |
{
|
| 379 |
// 使用多个阈值,使检测更平滑
|
| 380 |
-
threshold: [0.
|
| 381 |
-
// 调整 rootMargin,
|
| 382 |
-
rootMargin: '0px 0px -
|
| 383 |
}
|
| 384 |
)
|
| 385 |
|
|
@@ -412,7 +416,7 @@ onUnmounted(() => {
|
|
| 412 |
width: 100%;
|
| 413 |
min-height: 280px;
|
| 414 |
margin-top: 80px;
|
| 415 |
-
padding: 60px 0
|
| 416 |
overflow: visible;
|
| 417 |
}
|
| 418 |
|
|
@@ -534,11 +538,11 @@ onUnmounted(() => {
|
|
| 534 |
font-weight: 500;
|
| 535 |
}
|
| 536 |
|
| 537 |
-
|
|
|
|
| 538 |
display: flex;
|
| 539 |
align-items: center;
|
| 540 |
gap: 6px;
|
| 541 |
-
text-transform: uppercase;
|
| 542 |
letter-spacing: 0.5px;
|
| 543 |
font-weight: 600;
|
| 544 |
font-size: 0.65rem;
|
|
@@ -548,10 +552,10 @@ onUnmounted(() => {
|
|
| 548 |
font-size: 0.5rem;
|
| 549 |
}
|
| 550 |
|
| 551 |
-
|
| 552 |
-
.card-
|
| 553 |
-
.card-
|
| 554 |
-
.card-
|
| 555 |
.card-status.pending { color: #9CA3AF; }
|
| 556 |
|
| 557 |
/* 文件列表区域 */
|
|
|
|
| 28 |
@mouseleave="hoveringCard = null"
|
| 29 |
@click="navigateToProject(project)"
|
| 30 |
>
|
| 31 |
+
<!-- 卡片头部:simulation_id和轮数进度 -->
|
| 32 |
<div class="card-header">
|
| 33 |
<span class="card-id">{{ formatSimulationId(project.simulation_id) }}</span>
|
| 34 |
+
<span class="card-progress" :class="getProgressClass(project)">
|
| 35 |
+
<span class="status-dot">●</span> {{ formatRounds(project) }}
|
| 36 |
</span>
|
| 37 |
</div>
|
| 38 |
|
|
|
|
| 68 |
<!-- 卡片底部 -->
|
| 69 |
<div class="card-footer">
|
| 70 |
<span class="card-date">{{ formatDate(project.created_at) }}</span>
|
| 71 |
+
<span class="card-time">{{ formatTime(project.created_at) }}</span>
|
| 72 |
</div>
|
| 73 |
|
| 74 |
<!-- 底部装饰线 (hover时展开) -->
|
|
|
|
| 128 |
}
|
| 129 |
|
| 130 |
const rows = Math.ceil(total / CARDS_PER_ROW)
|
| 131 |
+
// 计算实际需要的高度:行数 * 卡片高度 + (行数-1) * 间距 + 少量底部间距
|
| 132 |
+
const expandedHeight = rows * CARD_HEIGHT + (rows - 1) * CARD_GAP + 10
|
| 133 |
|
| 134 |
return { minHeight: `${expandedHeight}px` }
|
| 135 |
})
|
|
|
|
| 186 |
}
|
| 187 |
}
|
| 188 |
|
| 189 |
+
// 根据轮数进度获取样式类
|
| 190 |
+
const getProgressClass = (simulation) => {
|
| 191 |
+
const current = simulation.current_round || 0
|
| 192 |
+
const total = simulation.total_rounds || 0
|
| 193 |
+
|
| 194 |
+
if (total === 0 || current === 0) {
|
| 195 |
+
// 未开始
|
| 196 |
+
return 'not-started'
|
| 197 |
+
} else if (current >= total) {
|
| 198 |
+
// 已完成
|
| 199 |
+
return 'completed'
|
| 200 |
+
} else {
|
| 201 |
+
// 进行中
|
| 202 |
+
return 'in-progress'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 203 |
}
|
|
|
|
| 204 |
}
|
| 205 |
|
| 206 |
+
// 格式化日期(只显示日期部分)
|
| 207 |
const formatDate = (dateStr) => {
|
| 208 |
if (!dateStr) return ''
|
| 209 |
try {
|
|
|
|
| 214 |
}
|
| 215 |
}
|
| 216 |
|
| 217 |
+
// 格式化时间(显示时:分)
|
| 218 |
+
const formatTime = (dateStr) => {
|
| 219 |
+
if (!dateStr) return ''
|
| 220 |
+
try {
|
| 221 |
+
const date = new Date(dateStr)
|
| 222 |
+
const hours = date.getHours().toString().padStart(2, '0')
|
| 223 |
+
const minutes = date.getMinutes().toString().padStart(2, '0')
|
| 224 |
+
return `${hours}:${minutes}`
|
| 225 |
+
} catch {
|
| 226 |
+
return ''
|
| 227 |
+
}
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
// 截断文本
|
| 231 |
const truncateText = (text, maxLength) => {
|
| 232 |
if (!text) return ''
|
|
|
|
| 381 |
},
|
| 382 |
{
|
| 383 |
// 使用多个阈值,使检测更平滑
|
| 384 |
+
threshold: [0.4, 0.6, 0.8],
|
| 385 |
+
// 调整 rootMargin,视口底部向上收缩,需要滚动更多才触发展开
|
| 386 |
+
rootMargin: '0px 0px -150px 0px'
|
| 387 |
}
|
| 388 |
)
|
| 389 |
|
|
|
|
| 416 |
width: 100%;
|
| 417 |
min-height: 280px;
|
| 418 |
margin-top: 80px;
|
| 419 |
+
padding: 60px 0 40px;
|
| 420 |
overflow: visible;
|
| 421 |
}
|
| 422 |
|
|
|
|
| 538 |
font-weight: 500;
|
| 539 |
}
|
| 540 |
|
| 541 |
+
/* 轮数进度显示 */
|
| 542 |
+
.card-progress {
|
| 543 |
display: flex;
|
| 544 |
align-items: center;
|
| 545 |
gap: 6px;
|
|
|
|
| 546 |
letter-spacing: 0.5px;
|
| 547 |
font-weight: 600;
|
| 548 |
font-size: 0.65rem;
|
|
|
|
| 552 |
font-size: 0.5rem;
|
| 553 |
}
|
| 554 |
|
| 555 |
+
/* 进度状态颜色 */
|
| 556 |
+
.card-progress.completed { color: #10B981; } /* 已完成 - 绿色 */
|
| 557 |
+
.card-progress.in-progress { color: #F59E0B; } /* 进行中 - 橙色 */
|
| 558 |
+
.card-progress.not-started { color: #9CA3AF; } /* 未开始 - 灰色 */
|
| 559 |
.card-status.pending { color: #9CA3AF; }
|
| 560 |
|
| 561 |
/* 文件列表区域 */
|