feat(task-board): 手动刷新铺满全部 16 个任务面板页

用户点名「只要是任务的功能都要加上」:TaskCenterPanel 的 on-refresh 按各自骨架接线
——useLiveTaskBoard 两页强拉 history+dashboard+进度;手写 fetch 五页 allSettled
(history+dashboard+refreshTaskBatch);useHistoryPolling 三页 refreshTaskViews+活跃进度;
useTaskProgressLoop 两页加 progressLoop.refreshOnce;一次性拉取三页直挂各自 load 函数;
品牌检测复用既有 syncTasksAndResumePolling。接线守卫测试扩到 16 页。
This commit is contained in:
2026-10-22 15:48:44 +08:00
parent 6d52b95d85
commit aa7e17f95c
15 changed files with 84 additions and 1 deletions
@@ -63,6 +63,7 @@
</div>
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="syncTasksAndResumePolling"
title="品牌检测任务"
:cards="brandCards"
:current-items="currentTaskViews"
@@ -110,6 +110,7 @@
<section class="right-panel">
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="refreshBoard"
title="采集数据"
:cards="collectCards"
:current-items="currentTaskViews"
@@ -572,6 +573,11 @@ async function downloadResult(item: CollectDataHistoryItem) {
}
}
/** 手动刷新:强拉历史 + 统计 + 当前轮询任务进度(轮询意外中断后的自救出口) */
async function refreshBoard() {
await Promise.all([loadDashboard(), loadHistory(), progressLoop.refreshOnce()])
}
async function loadDashboard() {
try {
dashboard.value = await getCollectDataDashboard()
@@ -68,6 +68,7 @@
<section class="right-panel">
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="loadConvertHistory"
title="转换结果"
:cards="convertCards"
:current-items="currentTaskViews"
@@ -80,6 +80,7 @@
<section class="right-panel">
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="loadCleanHistory"
title="去重结果"
:cards="dedupeCards"
:current-items="currentTaskViews"
@@ -70,6 +70,7 @@
<section class="right-panel">
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="refreshBoard"
title="删除品牌结果"
:cards="deleteBrandCards"
:current-items="currentTaskViews"
@@ -1100,6 +1101,11 @@ async function downloadTaskResult(item: DeleteBrandResultItem) {
}
}
/** 手动刷新:loadHistory 内部已含明细重算与轮询续接,统计卡由列表派生 */
async function refreshBoard() {
await loadHistory()
}
async function loadHistory() {
try {
const response = await getDeleteBrandHistory()
@@ -154,6 +154,7 @@
<section class="right-panel">
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="refreshBoard"
title="匹配与任务"
:cards="patrolCards"
:current-items="currentTaskViews"
@@ -776,6 +777,12 @@ async function loadHistory() {
historyItems.value = data.items || [];
}
/** 手动刷新:强拉历史 + 统计 + 活跃任务进度(轮询意外中断后的自救出口) */
async function refreshBoard() {
await refreshTaskViews()
await refreshActiveTaskProgress()
}
async function refreshTaskViews() {
await Promise.all([loadDashboard(), loadHistory()]);
}
@@ -170,6 +170,7 @@
<section class="right-panel">
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="refreshBoard"
title="匹配与任务"
:cards="priceTrackCards"
:current-items="currentTaskViews"
@@ -1472,6 +1473,11 @@ function taskProgressSignature(task?: PriceTrackTaskDetailVo['task'] | null) {
].join('|')
}
/** 手动刷新:强拉历史 + 统计 + 当前轮询任务进度(轮询意外中断后的自救出口) */
async function refreshBoard() {
await Promise.allSettled([loadHistory(), loadDashboard(), refreshTaskBatch()])
}
async function refreshTaskBatch() {
const ids = pollingTaskIds.value.filter((id) => id > 0)
if (!ids.length) return
@@ -89,6 +89,7 @@
<section class="right-panel">
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="refreshBoard"
title="匹配与任务"
:cards="riskCards"
:current-items="currentTaskViews"
@@ -765,6 +766,11 @@ async function createProductRiskTaskWithRetry(items: ProductRiskShopQueueItem[],
}
}
/** 手动刷新:强拉历史 + 统计 + 当前轮询任务进度(轮询意外中断后的自救出口) */
async function refreshBoard() {
await Promise.allSettled([loadHistory(), loadDashboard(), refreshTaskBatch()])
}
async function refreshTaskBatch() {
const ids = pollingTaskIds.value.filter((id) => id > 0)
if (!ids.length) return
@@ -82,6 +82,7 @@
<section class="right-panel">
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="refreshBoard"
title="上架结果"
:cards="publishCards"
:current-items="currentTaskViews"
@@ -911,6 +912,11 @@ async function processQueue() {
}
}
/** 手动刷新:强拉历史 + 统计 + 当前轮询任务进度(轮询意外中断后的自救出口) */
async function refreshBoard() {
await Promise.all([loadDashboard(), loadHistory(), progressLoop.refreshOnce()])
}
async function loadDashboard() {
try {
dashboard.value = await getPublishDashboard()
@@ -106,6 +106,7 @@
<section class="right-panel">
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="refreshBoard"
title="匹配与任务"
:cards="queryAsinCards"
:current-items="currentTaskViews"
@@ -693,6 +694,12 @@ async function loadHistory() {
historyItems.value = (data.items || []).map((item) => withQueryAsinFallback(item));
}
/** 手动刷新:强拉历史 + 统计 + 活跃任务进度(轮询意外中断后的自救出口) */
async function refreshBoard() {
await refreshTaskViews()
await refreshActiveTaskProgress()
}
async function refreshTaskViews() {
await Promise.all([loadDashboard(), loadHistory()]);
}
@@ -70,6 +70,7 @@
<section class="right-panel">
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="refreshBoard"
title="匹配与任务"
:cards="shopDataCards"
:current-items="currentTaskViews"
@@ -355,6 +356,12 @@ async function loadHistory() {
const localFailures = historyItems.value.filter((item) => !item.taskId && !item.resultId && item.taskStatus === 'FAILED')
historyItems.value = [...localFailures, ...((await getShopDataCrawlHistory()).items || [])]
}
/** 手动刷新:强拉历史 + 统计 + 活跃任务进度(轮询意外中断后的自救出口) */
async function refreshBoard() {
await refreshViews()
if (activeTaskId.value) await refreshTaskProgress(activeTaskId.value)
}
async function refreshViews() { await Promise.all([loadDashboard(), loadHistory()]) }
async function confirmAdd() {
@@ -69,6 +69,7 @@
<section class="right-panel">
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="refreshBoard"
title="匹配与任务"
:cards="shopMatchCards"
:current-items="currentTaskViews"
@@ -495,6 +496,11 @@ function sleep(ms: number) { if (disposed) return Promise.resolve(); return time
function clearSleepTimers() { timers.clearCategory('queue-wait') }
function isTransientBackendError(error: unknown) { const message = (error instanceof Error ? error.message : String(error || '')).toLowerCase(); return TRANSIENT_BACKEND_ERROR_PATTERNS.some((pattern) => message.includes(pattern.toLowerCase())) }
async function withTransientRetry<T>(action: () => Promise<T>, onRetry: (attempt: number, maxAttempts: number) => void, maxAttempts = 10) { let attempt = 0; while (true) { if (disposed) throw new Error('component disposed'); try { return await action() } catch (error) { attempt += 1; if (!isTransientBackendError(error) || attempt >= maxAttempts) throw error; onRetry(attempt, maxAttempts); await sleep(getPollIntervalMs()) } } }
/** 手动刷新:强拉历史 + 统计 + 当前轮询任务进度(轮询意外中断后的自救出口) */
async function refreshBoard() {
await Promise.allSettled([loadHistory(), loadDashboard(), refreshTaskBatch()])
}
async function refreshTaskBatch() { if (!pollingTaskIds.value.length) return { settledTaskIds: [] as number[] }; try { // F5:主轮询只读 status 等轻量白名单字段,走 light 端点减小响应体;轻量异常/空结果时回退重型 batch(否则会漏刷新结果)
const batch = await getPollingProgressBatch('shopMatch', pollingTaskIds.value, { fallback: () => getShopMatchTaskProgressBatch(pollingTaskIds.value) }); const nextSnapshots = { ...taskSnapshots.value }; const settledTaskIds = new Set<number>(); for (const missingId of batch.missingTaskIds || []) { removeTaskLocally(missingId); delete nextSnapshots[missingId]; settledTaskIds.add(missingId) } for (const detail of batch.items || []) { const taskId = detail.task?.id; if (!taskId) continue; const prev = nextSnapshots[taskId]; nextSnapshots[taskId] = prev ? { ...prev, task: { ...(prev.task || {}), ...(detail.task || {}) } } : detail; const status = detail.task?.status || ''; if (!status) continue; taskDetails.value[taskId] = status; if (isTaskTerminalStatus(status)) { removePollingTask(taskId); settledTaskIds.add(taskId); continue } if (status === 'SCHEDULED') { stopPollingTask(taskId); settledTaskIds.add(taskId) } } taskSnapshots.value = nextSnapshots; triggerRef(taskSnapshots); saveTaskSnapshotsToStorage(); saveTaskDetailsToStorage(); restoreScheduledDispatches(); return { settledTaskIds: Array.from(settledTaskIds) } } catch { return { settledTaskIds: [] as number[] } } }
function getPollIntervalMs() { return getTaskPollIntervalMs() }
@@ -93,6 +93,7 @@
<section class="right-panel">
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="loadSplitHistory"
title="拆分结果"
:cards="splitCards"
:current-items="currentTaskViews"
@@ -188,6 +188,7 @@
<TaskCenterPanel
:on-batch-delete="batchDeleteHistory"
:on-refresh="refreshBoard"
title="匹配与任务"
:cards="withdrawCards"
:current-items="currentTaskViews"
@@ -798,6 +799,12 @@ async function loadHistory() {
historyItems.value = (data.items || []).map((item) => withWithdrawFallback(item));
}
/** 手动刷新:强拉历史 + 统计 + 活跃任务进度(轮询意外中断后的自救出口) */
async function refreshBoard() {
await refreshTaskViews()
await refreshActiveTaskProgress()
}
async function refreshTaskViews() {
await Promise.all([loadDashboard(), loadHistory()]);
}
@@ -37,7 +37,22 @@ test('轮询异常必须吞掉并重试,propagate 模式不得回流', () => {
'轮询成功后必须清零失败计数,否则一次抖动会把间隔永久拉长')
})
test('两个任务面板页都接了手动刷新', () => {
test('全部任务面板页都接了手动刷新(用户点名:只要是任务的功能都要有)', () => {
const PANELS_DIR = join(ROOT, 'src/pages/brand/components')
const PAGES = [
'BrandAppearancePatentTab.vue', 'BrandSimilarAsinTab.vue', 'BrandShopMatchTab.vue',
'BrandProductRiskTab.vue', 'BrandCollectDataTab.vue', 'BrandPriceTrackTab.vue',
'BrandQueryAsinTab.vue', 'BrandPatrolDeleteTab.vue', 'BrandDeleteBrandTab.vue',
'BrandShopDataCrawlTab.vue', 'BrandPublishTab.vue', 'BrandWithdrawTab.vue',
'BrandSplitTab.vue', 'BrandDedupeTab.vue', 'BrandConvertTab.vue', 'BrandBrandTab.vue',
]
for (const page of PAGES) {
const source = readFileSync(join(PANELS_DIR, page), 'utf8')
assert.ok(source.includes(':on-refresh="'), `${page} 没有给 TaskCenterPanel 传 on-refresh`)
}
})
test('两个 live 任务面板页的 refreshBoard 实现符合骨架契约', () => {
for (const [rel, name] of [[PATENT, '外观专利'], [SIMILAR, '货源查询']] as const) {
const source = sourceOf(rel)
assert.ok(source.includes(':on-refresh="refreshBoard"'), `${name} 页没有给 TaskCenterPanel 传 on-refresh`)