feat(采集数据): 等待中卡片给出排队位;启动入口补到「当前任务」区
装机截图(任务 33462)暴露上一笔的漏改:「启动任务」只加在历史区插槽 #history-item-actions, 而等待中的单实际出现在「当前任务」卡片(走 #item-actions,那里只有重试/删除)—— 于是"历史行可补点"这句话对用户真正看到的那一屏不成立。两个插槽现在都有入口。 排队位显示按本账号数:COLLECT_DATA 是各客户端 activate 后入本机队列,别人的 PENDING 不占你这台 机器。现网全表 4 支 PENDING、33462 前面 3 支,但那 3 支属于 1293/1312/1318;报一个跨账号的 「前面还有 3 个」会把人引去等一个不会来的位置。N=0 时文案直接说「这一单还没被启动」—— 数字本身就是答案,并跟着给下一步(点「启动任务」)。 计算搬进 useCollectDataDispatch(组件 846 行,仍在可读棘轮基线 861 之下,未动基线)。 判据两格新增并反向验过:摘掉 #item-actions 的按钮/把排队数改成连 RUNNING 一起数,各出真红。 用户端 npm test 1024、test:mount 66、vue-tsc rc=0。
This commit is contained in:
@@ -120,6 +120,8 @@
|
||||
history-empty-text="暂无历史记录"
|
||||
>
|
||||
<template #item-actions="{ item }">
|
||||
<button v-if="canStartTask(itemSource(item))" type="button" class="btn-run"
|
||||
@click="startPendingTask(itemSource(item))">启动任务</button>
|
||||
<button v-if="canRetryTask(itemSource(item))" type="button" class="btn-retry"
|
||||
@click="retryTaskRecord(itemSource(item))">重试</button>
|
||||
<button type="button" class="btn-delete" @click="deleteTaskRecord(itemSource(item))">删除</button>
|
||||
@@ -156,7 +158,7 @@ import { useTaskProgressLoop } from '@/shared/composables/useTaskProgressLoop'
|
||||
import { createCategorizedTimers } from '@/shared/utils/categorized-timers'
|
||||
import { saveUrlWithProgress } from '@/shared/utils/download-progress'
|
||||
import { checkParseResult } from '@/shared/dispatch-guard'
|
||||
import { useCollectDataDispatch } from '@/shared/composables/useCollectDataDispatch'
|
||||
import { pendingQueueText, useCollectDataDispatch } from '@/shared/composables/useCollectDataDispatch'
|
||||
import { passGuard } from '@/shared/dispatch-guard-ui'
|
||||
import {
|
||||
parseCollectData,
|
||||
@@ -702,9 +704,11 @@ function toCollectTaskView(item: CollectDataHistoryItem): TaskItemView {
|
||||
+ `${item.brandQueryFailedReason ? `(${item.brandQueryFailedReason})` : ''}`
|
||||
: ''
|
||||
const percent = taskProgressPercent(item)
|
||||
const pendingQueueLine = pendingQueueText(item, currentItems.value)
|
||||
const finishedAt = item.finishedAt ? formatDateTime(item.finishedAt) : isActive ? '进行中' : '-'
|
||||
const extraLines: string[] = isActive
|
||||
? [
|
||||
...(pendingQueueLine ? [pendingQueueLine] : []),
|
||||
...(item.rowCount != null ? [`行数:${item.rowCount}`] : []),
|
||||
`总数据去重过滤:${item.dedupeFilteredCount ?? 0}`,
|
||||
`无效品牌过滤:${item.invalidFilteredCount ?? 0}`,
|
||||
|
||||
@@ -52,6 +52,43 @@ export function buildCollectQueuePayload(taskId: number, src: CollectDispatchSou
|
||||
* 提交即启动与历史「等待中」单重启共用的启动链。
|
||||
* 返回 true 只在「已 activate 且已进本机队列」时成立,调用方据此决定是否刷新看板。
|
||||
*/
|
||||
/** 排队位置要读的那几列(历史行与轮询占位行都满足这个形状) */
|
||||
export type QueuePositionItem = {
|
||||
taskId?: number
|
||||
taskStatus?: string
|
||||
createdAt?: string
|
||||
startedAt?: string
|
||||
}
|
||||
|
||||
function createdAtKey(item: QueuePositionItem): string {
|
||||
return item.createdAt || item.startedAt || ''
|
||||
}
|
||||
|
||||
/**
|
||||
* 排队位置只按**本账号**数:COLLECT_DATA 是各客户端 activate 后入本机队列,别人的 PENDING 不占你这台机器。
|
||||
* 报一个跨账号的「前面还有 3 个」会把人引去等一个不会来的位置——现网 33462 前面那 3 支属于 1293/1312/1318,
|
||||
* 而它真正的问题是"没有一次启动动作到达服务端",所以 N=0 时要把这句说出来,数字本身才是答案。
|
||||
*/
|
||||
export function pendingAheadCount(item: QueuePositionItem, siblings: QueuePositionItem[]): number {
|
||||
const mine = siblings.filter((it) => (it.taskStatus || '').toUpperCase() === 'PENDING' && it.taskId !== item.taskId)
|
||||
const self = createdAtKey(item)
|
||||
if (!self) return mine.length
|
||||
return mine.filter((it) => {
|
||||
const other = createdAtKey(it)
|
||||
if (!other) return false
|
||||
if (other !== self) return other < self
|
||||
return (it.taskId ?? 0) < (item.taskId ?? 0)
|
||||
}).length
|
||||
}
|
||||
|
||||
export function pendingQueueText(item: QueuePositionItem, siblings: QueuePositionItem[]): string {
|
||||
if ((item.taskStatus || '').toUpperCase() !== 'PENDING') return ''
|
||||
const ahead = pendingAheadCount(item, siblings)
|
||||
return ahead > 0
|
||||
? `排队:你前面还有 ${ahead} 个任务在等待`
|
||||
: '排队:你前面没有待启动的任务——这一单还没被启动,点「启动任务」即开始采集'
|
||||
}
|
||||
|
||||
export function useCollectDataDispatch(hooks: CollectDispatchHooks) {
|
||||
/** 正在启动中的任务号:同一单重复点击会二次 activate,第二次只是被条件更新拒掉的无效请求 */
|
||||
const startingTaskIds = shallowRef<Set<number>>(new Set())
|
||||
|
||||
@@ -66,3 +66,27 @@ test('缺桌面壳时不得静默 return:文案要点名「等待中」与下
|
||||
assert.match(segment, /等待中/, '只说「环境不支持」会把用户引去等一个不会来的自动重试——这一单不会自己开始跑')
|
||||
assert.match(segment, /启动任务/, '必须点名可补救的那一步')
|
||||
})
|
||||
|
||||
// 2026-11-06 装机截图的现场:33462 显示在「当前任务」卡片里,那里只有「重试/删除」——
|
||||
// 第一版把「启动任务」只加在历史区插槽(#history-item-actions),当前任务区走的是 #item-actions,
|
||||
// 于是"历史行可补点"这句话对用户实际看到的那一屏不成立。两个插槽都要有。
|
||||
test('启动入口必须两个区都有:当前任务区的 PENDING 行同样能点启动', () => {
|
||||
const itemActions = TAB.slice(
|
||||
TAB.indexOf('<template #item-actions="{ item }">'),
|
||||
TAB.indexOf('</template>', TAB.indexOf('<template #item-actions="{ item }">')))
|
||||
assert.match(itemActions, /v-if="canStartTask\(itemSource\(item\)\)"[^>]*>\s*启动任务/,
|
||||
'「当前任务」区是等待中单实际出现的地方,这里没有启动入口=用户看到的还是那一屏死路')
|
||||
assert.match(itemActions, /@click="startPendingTask\(itemSource\(item\)\)"/)
|
||||
})
|
||||
|
||||
test('排队数只按本账号数,且 N=0 时要把「没人启动」说出来', () => {
|
||||
const ahead = bodyOf(CHAIN, 'export function pendingAheadCount')
|
||||
assert.match(ahead, /=== 'PENDING'/,
|
||||
'只数 PENDING:RUNNING 的单不占排队位(各客户端只跑自己那单),混进来会把数字说大')
|
||||
assert.match(ahead, /createdAt \|\| item\.startedAt|createdAtKey/,
|
||||
'排队位置按建单时间比,别的都不构成 FIFO 语义')
|
||||
const text = bodyOf(CHAIN, 'export function pendingQueueText')
|
||||
assert.match(text, /还没被启动/,
|
||||
'N=0 才是这一类单的真答案:它不是排在谁后面,是没有一次启动动作到达服务端(现网 33462)')
|
||||
assert.match(text, /点「启动任务」/, '数字要跟着给下一步,不能只报一个 0')
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user