perf(frontend): 工具页分页/历史截断/轻量轮询/共享纯逻辑(审查 F5/F6/F9/F12/G3)

- F9 新增 useTablePaging composable 并接入 7 个工具页"匹配结果"表(只切渲染窗口,
  不加选择语义;每页 100 条)+ 深色分页样式
- F6 历史任务抽屉渲染截断(默认 50 条 + "显示全部/收起"),全选口径改为当前可见条目
- F5 新增 task-progress-polling 适配器:等待任务终态的紧循环走 /tasks/progress/light,
  异常或空响应回退重型 batch;已接入跟价/定时匹配的 waitForTaskTerminal
- F12 背景图 bg.jpg 251KB → 166KB(1920 宽 + quality 80,image-set 仍优先 webp)
- G3 抽出共享纯逻辑 task-queue-state(开始时间表序列化校验 + 记录缺失错误判定),
  5 个工具页删除逐字重复实现
- 新增 4 个单测文件(分页切片/历史截断/轻量轮询归一/任务队列纯逻辑)
This commit is contained in:
2026-09-14 06:23:46 +08:00
parent e76714c32e
commit 67223f8950
18 changed files with 684 additions and 69 deletions
@@ -23,7 +23,7 @@
<div v-if="!items.length" class="empty-tasks">{{ emptyText }}</div>
<ul v-else class="history-list">
<li v-for="item in items" :key="item.key" class="history-item-row" :class="{ 'is-selected': isSelected(item.key) }">
<li v-for="item in visibleHistoryItems" :key="item.key" class="history-item-row" :class="{ 'is-selected': isSelected(item.key) }">
<label v-if="onBatchDelete" class="row-check" @click.stop>
<input v-model="selectedSet" type="checkbox" :value="item.key" :disabled="batchDeleting" />
</label>
@@ -39,6 +39,13 @@
</div>
</li>
</ul>
<!-- 渲染截断(F6):超上限时只渲染前 N 条,避免历史很多时打开抽屉即产生大量 DOM -->
<div v-if="historySlice.capped || showAll" class="history-paging">
<button v-if="historySlice.capped" type="button" class="btn-more" @click="showAll = true">
显示全部(还有 {{ historySlice.hiddenCount }} 条)
</button>
<button v-else type="button" class="btn-more" @click="showAll = false">收起</button>
</div>
</div>
</el-drawer>
</div>
@@ -50,6 +57,7 @@ import { ElMessageBox } from 'element-plus'
import TaskItemCard from './TaskItemCard.vue'
import type { TaskItemView } from './types'
import { sliceHistoryItems } from '../../utils/history-paging.ts'
const props = withDefaults(defineProps<{
/** 历史任务数量(按钮角标) */
@@ -71,14 +79,21 @@ const open = ref(false)
const batchDeleting = ref(false)
/** 勾选集合:以 TaskItemView.key 为维度 */
const selectedSet = ref<Set<string>>(new Set())
/** 是否展开全部历史(默认只渲染前 HISTORY_VISIBLE_LIMIT 条) */
const showAll = ref(false)
const historySlice = computed(() => sliceHistoryItems(props.items, showAll.value))
const visibleHistoryItems = computed(() => historySlice.value.visible)
const selectedKeys = computed(() => selectedSet.value)
const allSelected = computed({
get: () => Boolean(props.items.length) && selectedSet.value.size === props.items.length,
// 全选口径=当前可见条目(截断状态下就是屏幕上这几条),避免"全选"选中看不见的条目
get: () => Boolean(visibleHistoryItems.value.length)
&& visibleHistoryItems.value.every((item) => selectedSet.value.has(item.key)),
set: (checked: boolean) => {
const next = new Set<string>()
if (checked) {
props.items.forEach((item) => next.add(item.key))
visibleHistoryItems.value.forEach((item) => next.add(item.key))
}
selectedSet.value = next
},
@@ -87,6 +102,8 @@ const allSelected = computed({
watch(open, (value) => {
if (!value) {
selectedSet.value = new Set()
// 关闭后回到"只渲染前 N 条",下次打开不会因为上次展开过而全量渲染
showAll.value = false
}
})
@@ -133,6 +150,27 @@ async function confirmBatchDelete() {
white-space: nowrap;
}
.history-paging {
display: flex;
justify-content: center;
padding: 8px 0 4px;
}
.btn-more {
padding: 5px 14px;
border: 1px solid #3e4a62;
border-radius: 6px;
background: #242424;
color: #9fb0c8;
font-size: 12px;
cursor: pointer;
}
.btn-more:hover {
background: #2b3447;
color: #f5f8fc;
}
.history-btn:hover {
background: #2b3447;
color: #f5f8fc;