fix(brand): 品牌检测提交统一立即执行,去掉无人消费的"添加到队列"模式

queue 模式只建 pending 无后台消费者,任务会永久停在排队中;统一走 /api/brand/run 立即执行(与历史链路一致)
This commit is contained in:
2026-09-08 21:54:02 +08:00
parent 197643a8fa
commit 3cc5a64609
@@ -40,16 +40,7 @@
</div>
<div class="section-title">运行方式</div>
<div class="run-mode-zone">
<label class="run-mode-row">
<input type="radio" name="brand-run-mode" value="immediate" v-model="runMode" />
<span class="run-mode-text">立即执行前台运行可实时取消</span>
</label>
<label class="run-mode-row">
<input type="radio" name="brand-run-mode" value="queue" v-model="runMode" />
<span class="run-mode-text">添加到任务队列后台排队执行</span>
</label>
</div>
<p class="loading-msg">提交后立即开始检测可在右侧任务列表查看进度或取消</p>
<div class="run-row">
<button
@@ -58,7 +49,7 @@
:disabled="!selectedPaths.length || submitting || !hasBridge || !hasUid"
@click="submitRun"
>
{{ submitting ? '提交中...' : runMode === 'immediate' ? '立即运行品牌检测' : '添加到任务队列' }}
{{ submitting ? '提交中...' : '立即运行品牌检测' }}
</button>
</div>
<p v-if="!hasBridge || !hasUid" class="env-tip">
@@ -121,7 +112,6 @@ import type { TaskItemView, TaskStatCard } from '@/shared/components/tasks/types
import { getPywebviewApi } from '@/shared/bridges/pywebview'
import {
cancelBrandTask,
createBrandTask,
deleteBrandTask,
getBrandTaskDownloadUrl,
getBrandTasks,
@@ -136,7 +126,6 @@ import type { BrandExpandFolderItem } from '@/shared/api/types/modules/brand'
const uploadedFiles = ref<UploadFileVo[]>([])
const strategy = ref<'Terms' | 'Simple'>('Terms')
const runMode = ref<'immediate' | 'queue'>('immediate')
const submitting = ref(false)
const tasks = ref<BrandTaskItem[]>([])
@@ -364,20 +353,11 @@ async function submitRun() {
relativePath: f.relativePath,
fileUrl: f.url || f.localPath,
}))
if (runMode.value === 'immediate') {
const res = await runBrandNow(files, strategy.value)
if (res.success && res.task_id) {
ElMessage.success(`已创建任务 ${res.task_id},客户端开始检测`)
} else {
throw new Error((res as { error?: string }).error || '运行失败')
}
const res = await runBrandNow(files, strategy.value)
if (res.success && res.task_id) {
ElMessage.success(`已创建任务 ${res.task_id},开始检测`)
} else {
const res = await createBrandTask(files, strategy.value)
if (res.success && res.task_id) {
ElMessage.success(`任务 ${res.task_id} 已添加到队列`)
} else {
throw new Error((res as { error?: string }).error || '添加失败')
}
throw new Error((res as { error?: string }).error || '运行失败')
}
uploadedFiles.value = []
await loadTasks()