refactor(phase-6): 拆分交付工作区与任务中心,五支队列 Tab 收敛到共享匹配表

- DeliveryVideoWorkspace 2690→2176 行,弹窗与结果面板下沉为 4 个子组件,类型抽到共享模块
- TaskCenterBoardPage 1017→834 行,任务表/变体表下沉,失败条与轮询入口留在页面
- 巡店删除/取款/查 ASIN/跟价/商品风险五支 Tab 共用 BrandShopMatchTable,纯逻辑收敛到 brand-shop-match-shared
- admin manualChunks 增加 element-plus 分组(915KB 独立 chunk)
- 源码钉按新落点更新:分页与表格断言读子组件,页面接线断言保留
This commit is contained in:
2026-10-24 21:53:10 +08:00
parent a7682bffef
commit 969f86c612
18 changed files with 1472 additions and 1272 deletions
@@ -164,71 +164,16 @@
>
<template #cards-extra>
<div class="subsection-title">匹配结果</div>
<div v-if="!matchedItems.length" class="match-empty">
完成“匹配店铺”后,这里会展示匹配结果。
</div>
<el-table
v-else
:data="pagedMatchedItems"
:row-key="rowKeyForMatch"
:highlight-current-row="false"
class="result-table match-table"
>
<el-table-column prop="shopName" label="店铺名" min-width="120" />
<el-table-column label="匹配" width="72" align="center">
<template #default="{ row }">
<span :class="row.matched ? 'ok' : 'fail'">
{{ row.matched ? "是" : "否" }}
</span>
</template>
</el-table-column>
<el-table-column
prop="shopId"
label="店铺 ID"
min-width="120"
show-overflow-tooltip
/>
<el-table-column
prop="platform"
label="平台"
width="88"
show-overflow-tooltip
/>
<el-table-column
prop="companyName"
label="公司"
min-width="120"
show-overflow-tooltip
/>
<el-table-column label="状态" width="110" show-overflow-tooltip>
<template #default="{ row }">
{{ formatMatchStatus(row.matchStatus) }}
</template>
</el-table-column>
<el-table-column label="说明" min-width="180" show-overflow-tooltip>
<template #default="{ row }">
{{ formatMatchRemark(row) }}
</template>
</el-table-column>
<el-table-column label="操作" width="72" align="center">
<template #default="{ row }">
<button
type="button"
class="link-danger"
@click="removeMatchedRow(row)"
>
删除
</button>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="matchedTotal > matchedPageSize"
class="matched-pagination"
layout="total, prev, pager, next"
<BrandShopMatchTable
v-model:page="matchedPage"
:items="pagedMatchedItems"
:total="matchedTotal"
:page-size="matchedPageSize"
v-model:current-page="matchedPage"
:row-key="rowKeyForMatch"
:status-text="formatMatchStatus"
:remark-text="formatMatchRemark"
empty-text="完成“匹配店铺”后,这里会展示匹配结果。"
@remove="removeMatchedRow"
/>
</template>
<template #item-actions="{ item }">
@@ -252,6 +197,15 @@ import { userNotice } from '@/shared/utils/user-notice'
import { ElMessage } from "element-plus";
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
import TaskCenterPanel from "@/shared/components/tasks/TaskCenterPanel.vue";
import BrandShopMatchTable from './BrandShopMatchTable.vue'
import {
formatMatchRemark,
formatMatchStatus,
historyItemKey,
isTransientBackendError,
rowKeyForMatch,
uidForStorage,
} from './brand-shop-match-shared'
import type { TaskItemView, TaskStatCard } from "@/shared/components/tasks/types";
import {
addPatrolDeleteCandidate,
@@ -405,11 +359,6 @@ const hasQueueWork = computed(
!!activeTaskId.value,
);
function uidForStorage() {
return typeof window !== "undefined"
? window.localStorage.getItem("uid") || "0"
: "0";
}
function matchedStorageKey() {
return `patrol-delete:matched:${uidForStorage()}`;
@@ -423,13 +372,7 @@ function countryCodesStorageKey() {
return `patrol-delete:country-codes:${uidForStorage()}`;
}
function rowKeyForMatch(row: PatrolDeleteShopQueueItem) {
return `${(row.shopName || "").trim()}::${row.shopId || ""}`;
}
function historyItemKey(item: PatrolDeleteHistoryItem) {
return `${item.taskId ?? 0}:${item.resultId ?? 0}`;
}
function taskGroupKey(item: PatrolDeleteHistoryItem) {
return `task:${item.taskId ?? item.resultId ?? 0}`;
@@ -453,20 +396,6 @@ function clearSleepTimers() {
timers.clearCategory("queue-wait");
}
function isTransientBackendError(error: unknown) {
const message =
error instanceof Error ? error.message.toLowerCase() : String(error || "").toLowerCase();
return (
message.includes("network error") ||
message.includes("failed to fetch") ||
message.includes("timeout") ||
message.includes("503") ||
message.includes("502") ||
message.includes("504") ||
message.includes("500") ||
message.includes("load failed")
);
}
async function withTransientRetry<T>(
action: () => Promise<T>,
@@ -493,34 +422,7 @@ function createSubmissionId(taskId: number, shopName?: string) {
return `patrol-delete:${taskId}:${shopName || "shop"}:${Date.now()}`;
}
function formatMatchStatus(status?: string) {
const value = (status || "").trim();
const map: Record<string, string> = {
MATCHED: "已匹配",
PENDING: "待匹配",
CONFLICT: "需人工确认",
INDEX_STALE: "匹配已过期",
};
return map[value] || value || "-";
}
function formatMatchRemark(row: PatrolDeleteShopQueueItem) {
const message = (row.matchMessage || "").trim();
if (message) return message;
if (row.matched && row.matchStatus === "MATCHED") {
return "已匹配成功,可启动任务";
}
if (row.matched) {
return "已匹配成功,请查看状态确认";
}
if (row.matchStatus === "CONFLICT") {
return "存在多个同名店铺,请人工确认";
}
if (row.matchStatus === "PENDING") {
return "店铺尚未匹配完成,请稍后查看";
}
return "未匹配成功,请检查店铺名";
}
function buildTemplateCountrySections(): PatrolDeleteCountrySection[] {
return selectedCountryNames.value.map((country) => ({
@@ -180,37 +180,21 @@
>
<template #cards-extra>
<div class="subsection-title">匹配结果</div>
<div v-if="!matchedItems.length" class="match-empty">完成「匹配店铺」后,在此展示匹配结果,确认无误后再启动任务。</div>
<el-table v-else :data="pagedMatchedItems" :row-key="rowKeyForMatch" :highlight-current-row="false"
class="result-table match-table">
<el-table-column prop="shopName" label="店铺名" min-width="100" />
<el-table-column label="匹配" width="72" align="center">
<template #default="{ row }">
<span :class="row.matched ? 'ok' : 'fail'">{{ row.matched ? '是' : '否' }}</span>
</template>
</el-table-column>
<el-table-column prop="shopId" label="店铺ID" min-width="120" show-overflow-tooltip />
<el-table-column prop="platform" label="平台" width="88" show-overflow-tooltip />
<el-table-column prop="companyName" label="公司" min-width="100" show-overflow-tooltip />
<el-table-column label="状态" width="100" show-overflow-tooltip>
<template #default="{ row }">{{ formatMatchStatus(row.matchStatus) }}</template>
</el-table-column>
<el-table-column label="说明" min-width="140" show-overflow-tooltip>
<template #default="{ row }">{{ formatMatchRemark(row) }}</template>
</el-table-column>
<el-table-column label="操作" width="72" align="center">
<template #default="{ row }">
<button type="button" class="link-danger" @click="removeMatchedRow(row)">删除</button>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="matchedTotal > matchedPageSize"
class="matched-pagination"
layout="total, prev, pager, next"
<BrandShopMatchTable
v-model:page="matchedPage"
:items="pagedMatchedItems"
:total="matchedTotal"
:page-size="matchedPageSize"
v-model:current-page="matchedPage"
:row-key="rowKeyForMatch"
:status-text="formatMatchStatus"
:remark-text="formatMatchRemark"
empty-text="完成「匹配店铺」后,在此展示匹配结果,确认无误后再启动任务。"
:shop-name-min-width="100"
shop-id-label="店铺ID"
:company-min-width="100"
:status-width="100"
:remark-min-width="140"
@remove="removeMatchedRow"
/>
</template>
<template #item-actions="{ item }">
@@ -245,6 +229,7 @@ import {
import ModuleTemplateDownload from '@/shared/components/ModuleTemplateDownload.vue'
import FileUploadZone from '@/shared/components/FileUploadZone.vue'
import TaskCenterPanel from '@/shared/components/tasks/TaskCenterPanel.vue'
import BrandShopMatchTable from './BrandShopMatchTable.vue'
import type { TaskItemView, TaskStatCard } from '@/shared/components/tasks/types'
import { getPywebviewApi, type PywebviewApi } from '@/shared/bridges/pywebview'
import { useExcelFileUpload } from '@/shared/composables/useExcelFileUpload'
@@ -940,7 +925,7 @@ async function runMatch() {
}
}
function formatMatchStatus(status: string | undefined) {
function formatMatchStatus(status?: string | null) {
const s = (status || '').trim()
const map: Record<string, string> = { MATCHED: '已匹配', PENDING: '待匹配', CONFLICT: '需人工确认', INDEX_STALE: '匹配已过期' }
return map[s] || (s ? s : '—')
@@ -99,37 +99,21 @@
>
<template #cards-extra>
<div class="subsection-title">匹配结果</div>
<div v-if="!matchedItems.length" class="match-empty">完成「匹配店铺」后,在此展示匹配结果,确认无误后再启动任务。</div>
<el-table v-else :data="pagedMatchedItems" :row-key="rowKeyForMatch" :highlight-current-row="false"
class="result-table match-table">
<el-table-column prop="shopName" label="店铺名" min-width="100" />
<el-table-column label="匹配" width="72" align="center">
<template #default="{ row }">
<span :class="row.matched ? 'ok' : 'fail'">{{ row.matched ? '是' : '否' }}</span>
</template>
</el-table-column>
<el-table-column prop="shopId" label="店铺ID" min-width="120" show-overflow-tooltip />
<el-table-column prop="platform" label="平台" width="88" show-overflow-tooltip />
<el-table-column prop="companyName" label="公司" min-width="100" show-overflow-tooltip />
<el-table-column label="状态" width="100" show-overflow-tooltip>
<template #default="{ row }">{{ formatMatchStatus(row.matchStatus) }}</template>
</el-table-column>
<el-table-column label="说明" min-width="140" show-overflow-tooltip>
<template #default="{ row }">{{ formatMatchRemark(row) }}</template>
</el-table-column>
<el-table-column label="操作" width="72" align="center">
<template #default="{ row }">
<button type="button" class="link-danger" @click="removeMatchedRow(row)">删除</button>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="matchedTotal > matchedPageSize"
class="matched-pagination"
layout="total, prev, pager, next"
<BrandShopMatchTable
v-model:page="matchedPage"
:items="pagedMatchedItems"
:total="matchedTotal"
:page-size="matchedPageSize"
v-model:current-page="matchedPage"
:row-key="rowKeyForMatch"
:status-text="formatMatchStatus"
:remark-text="formatMatchRemark"
empty-text="完成「匹配店铺」后,在此展示匹配结果,确认无误后再启动任务。"
:shop-name-min-width="100"
shop-id-label="店铺ID"
:company-min-width="100"
:status-width="100"
:remark-min-width="140"
@remove="removeMatchedRow"
/>
</template>
<template #item-actions="{ item }">
@@ -155,6 +139,7 @@ import { userNotice } from '@/shared/utils/user-notice'
import { ElMessage } from 'element-plus'
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
import TaskCenterPanel from '@/shared/components/tasks/TaskCenterPanel.vue'
import BrandShopMatchTable from './BrandShopMatchTable.vue'
import type { TaskItemView, TaskStatCard } from '@/shared/components/tasks/types'
import { LISTING_FILTER_OPTIONS, RISK_LISTING_FILTER_KEY, productRiskFilterIssues, type ListingFilterValue } from '@/pages/brand/components/listingFilters'
import {
@@ -1073,7 +1058,7 @@ async function downloadResult(item: ProductRiskHistoryItem) {
}
}
function formatMatchStatus(status: string | undefined) {
function formatMatchStatus(status?: string | null) {
const s = (status || '').trim()
const map: Record<string, string> = {
MATCHED: '已匹配',
@@ -116,71 +116,16 @@
>
<template #cards-extra>
<div class="subsection-title">匹配结果</div>
<div v-if="!matchedItems.length" class="match-empty">
完成“匹配店铺”后,这里会展示匹配结果。
</div>
<el-table
v-else
:data="pagedMatchedItems"
:row-key="rowKeyForMatch"
:highlight-current-row="false"
class="result-table match-table"
>
<el-table-column prop="shopName" label="店铺名" min-width="120" />
<el-table-column label="匹配" width="72" align="center">
<template #default="{ row }">
<span :class="row.matched ? 'ok' : 'fail'">
{{ row.matched ? "是" : "否" }}
</span>
</template>
</el-table-column>
<el-table-column
prop="shopId"
label="店铺 ID"
min-width="120"
show-overflow-tooltip
/>
<el-table-column
prop="platform"
label="平台"
width="88"
show-overflow-tooltip
/>
<el-table-column
prop="companyName"
label="公司"
min-width="120"
show-overflow-tooltip
/>
<el-table-column label="状态" width="110" show-overflow-tooltip>
<template #default="{ row }">
{{ formatMatchStatus(row.matchStatus) }}
</template>
</el-table-column>
<el-table-column label="说明" min-width="180" show-overflow-tooltip>
<template #default="{ row }">
{{ formatMatchRemark(row) }}
</template>
</el-table-column>
<el-table-column label="操作" width="72" align="center">
<template #default="{ row }">
<button
type="button"
class="link-danger"
@click="removeMatchedRow(row)"
>
删除
</button>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="matchedTotal > matchedPageSize"
class="matched-pagination"
layout="total, prev, pager, next"
<BrandShopMatchTable
v-model:page="matchedPage"
:items="pagedMatchedItems"
:total="matchedTotal"
:page-size="matchedPageSize"
v-model:current-page="matchedPage"
:row-key="rowKeyForMatch"
:status-text="formatMatchStatus"
:remark-text="formatMatchRemark"
empty-text="完成“匹配店铺”后,这里会展示匹配结果。"
@remove="removeMatchedRow"
/>
</template>
<template #item-actions="{ item }">
@@ -205,6 +150,15 @@ import { ElMessage } from "element-plus";
import type { TableInstance } from "element-plus";
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
import TaskCenterPanel from "@/shared/components/tasks/TaskCenterPanel.vue";
import BrandShopMatchTable from './BrandShopMatchTable.vue'
import {
formatMatchRemark,
formatMatchStatus,
historyItemKey,
isTransientBackendError,
rowKeyForMatch,
uidForStorage,
} from './brand-shop-match-shared'
import type { TaskItemView, TaskStatCard } from "@/shared/components/tasks/types";
import {
addQueryAsinCandidate,
@@ -356,11 +310,6 @@ const hasQueuedTaskWork = computed(
const hasQueueWork = computed(() => queueWorkerRunning.value || hasQueuedTaskWork.value);
const isQueueBusy = computed(() => queueWorkerRunning.value && hasQueuedTaskWork.value);
function uidForStorage() {
return typeof window !== "undefined"
? window.localStorage.getItem("uid") || "0"
: "0";
}
function matchedStorageKey() {
return `query-asin:matched:${uidForStorage()}`;
@@ -374,13 +323,7 @@ function taskStartTimeStorageKey() {
return `query-asin:start-times:${uidForStorage()}`;
}
function rowKeyForMatch(row: QueryAsinShopQueueItem) {
return `${(row.shopName || "").trim()}::${row.shopId || ""}`;
}
function historyItemKey(item: QueryAsinHistoryItem) {
return `${item.taskId ?? 0}:${item.resultId ?? 0}`;
}
let disposed = false;
@@ -400,20 +343,6 @@ function clearSleepTimers() {
timers.clearCategory("queue-wait");
}
function isTransientBackendError(error: unknown) {
const message =
error instanceof Error ? error.message.toLowerCase() : String(error || "").toLowerCase();
return (
message.includes("network error") ||
message.includes("failed to fetch") ||
message.includes("timeout") ||
message.includes("503") ||
message.includes("502") ||
message.includes("504") ||
message.includes("500") ||
message.includes("load failed")
);
}
async function withTransientRetry<T>(
action: () => Promise<T>,
@@ -440,34 +369,7 @@ function createSubmissionId(taskId: number, shopName?: string) {
return `query-asin:${taskId}:${shopName || "shop"}:${Date.now()}`;
}
function formatMatchStatus(status?: string) {
const value = (status || "").trim();
const map: Record<string, string> = {
MATCHED: "已匹配",
PENDING: "待匹配",
CONFLICT: "需人工确认",
INDEX_STALE: "匹配已过期",
};
return map[value] || value || "-";
}
function formatMatchRemark(row: QueryAsinShopQueueItem) {
const message = (row.matchMessage || "").trim();
if (message) return message;
if (row.matched && row.matchStatus === "MATCHED") {
return "已匹配成功,可启动任务";
}
if (row.matched) {
return "已匹配成功,请查看状态确认";
}
if (row.matchStatus === "CONFLICT") {
return "存在多个同名店铺,请人工确认";
}
if (row.matchStatus === "PENDING") {
return "店铺尚未匹配完成,请稍后查看";
}
return "未匹配成功,请检查店铺名";
}
function flattenQueryAsinRows(record: Pick<QueryAsinHistoryItem, "shopName" | "queryAsins">) {
const sections = readQueryAsins(record);
@@ -0,0 +1,113 @@
<script setup lang="ts" generic="T extends BrandShopMatchRow">
import type { BrandShopMatchRow } from './brand-shop-match-shared'
const page = defineModel<number>('page', { required: true })
defineProps<{
items: T[]
total: number
pageSize: number
rowKey: (row: T) => string
statusText: (status?: string | null) => string
remarkText: (row: T) => string
emptyText: string
shopNameMinWidth?: number
shopIdLabel?: string
companyMinWidth?: number
statusWidth?: number
remarkMinWidth?: number
}>()
const emit = defineEmits<{
remove: [T]
}>()
</script>
<template>
<div v-if="!items.length" class="match-empty">{{ emptyText }}</div>
<template v-else>
<el-table
:data="items"
:row-key="rowKey"
:highlight-current-row="false"
class="result-table match-table"
>
<el-table-column prop="shopName" label="店铺名" :min-width="shopNameMinWidth ?? 120" />
<el-table-column label="匹配" width="72" align="center">
<template #default="{ row }">
<span :class="row.matched ? 'ok' : 'fail'">
{{ row.matched ? '是' : '否' }}
</span>
</template>
</el-table-column>
<el-table-column prop="shopId" :label="shopIdLabel ?? '店铺 ID'" min-width="120" show-overflow-tooltip />
<el-table-column prop="platform" label="平台" width="88" show-overflow-tooltip />
<el-table-column prop="companyName" label="公司" :min-width="companyMinWidth ?? 120" show-overflow-tooltip />
<el-table-column label="状态" :width="statusWidth ?? 110" show-overflow-tooltip>
<template #default="{ row }">
{{ statusText(row.matchStatus) }}
</template>
</el-table-column>
<el-table-column label="说明" :min-width="remarkMinWidth ?? 180" show-overflow-tooltip>
<template #default="{ row }">
{{ remarkText(row) }}
</template>
</el-table-column>
<el-table-column label="操作" width="72" align="center">
<template #default="{ row }">
<button type="button" class="link-danger" @click="emit('remove', row)">删除</button>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="total > pageSize"
class="matched-pagination"
layout="total, prev, pager, next"
:total="total"
:page-size="pageSize"
v-model:current-page="page"
/>
</template>
</template>
<style scoped>
.match-empty {
color: #5e6878;
font-size: 13px;
padding: 12px 8px;
margin-bottom: 12px;
text-align: center;
}
.match-table {
margin-bottom: 18px;
}
.match-table :deep(.el-table__body tr:hover > td.el-table__cell),
.match-table :deep(.el-table__body tr.hover-row > td.el-table__cell),
.match-table :deep(.el-table__body tr.current-row > td.el-table__cell) {
background-color: var(--el-table-tr-bg-color, #242424) !important;
}
.result-table {
--el-table-bg-color: #242424;
--el-table-tr-bg-color: #242424;
--el-table-header-bg-color: #2e3a52;
--el-table-text-color: #c8d2e2;
--el-table-border-color: #333;
}
.ok {
color: #27ae60;
}
.fail {
color: #e67e22;
}
.link-danger {
background: none;
border: none;
color: #e74c3c;
cursor: pointer;
font-size: 12px;
padding: 0;
}
.link-danger:hover {
text-decoration: underline;
}
</style>
@@ -121,67 +121,16 @@
完成“匹配店铺”后,这里会展示匹配结果。
</div>
<div v-else class="match-zone-scroll">
<el-table
:data="pagedMatchedItems"
:row-key="rowKeyForMatch"
:highlight-current-row="false"
class="result-table match-table"
>
<el-table-column prop="shopName" label="店铺名" min-width="120" />
<el-table-column label="匹配" width="72" align="center">
<template #default="{ row }">
<span :class="row.matched ? 'ok' : 'fail'">
{{ row.matched ? "是" : "否" }}
</span>
</template>
</el-table-column>
<el-table-column
prop="shopId"
label="店铺 ID"
min-width="120"
show-overflow-tooltip
/>
<el-table-column
prop="platform"
label="平台"
width="88"
show-overflow-tooltip
/>
<el-table-column
prop="companyName"
label="公司"
min-width="120"
show-overflow-tooltip
/>
<el-table-column label="状态" width="110" show-overflow-tooltip>
<template #default="{ row }">
{{ formatMatchStatus(row.matchStatus) }}
</template>
</el-table-column>
<el-table-column label="说明" min-width="180" show-overflow-tooltip>
<template #default="{ row }">
{{ formatMatchRemark(row) }}
</template>
</el-table-column>
<el-table-column label="操作" width="72" align="center">
<template #default="{ row }">
<button
type="button"
class="link-danger"
@click="removeMatchedRow(row)"
>
删除
</button>
</template>
</el-table-column>
</el-table>
<el-pagination
v-if="matchedTotal > matchedPageSize"
class="matched-pagination"
layout="total, prev, pager, next"
<BrandShopMatchTable
v-model:page="matchedPage"
:items="pagedMatchedItems"
:total="matchedTotal"
:page-size="matchedPageSize"
v-model:current-page="matchedPage"
:row-key="rowKeyForMatch"
:status-text="formatMatchStatus"
:remark-text="formatMatchRemark"
empty-text="完成“匹配店铺”后,这里会展示匹配结果。"
@remove="removeMatchedRow"
/>
</div>
</div>
@@ -273,6 +222,15 @@ import { formatDateTime } from '@/shared/utils/datetime'
import { RUNNING_UNTIL_DONE_STATUS_OPTIONS, taskStatusClass, taskStatusText } from '@/shared/utils/task-status-text'
import { useHistoryPolling } from '@/shared/composables/useHistoryPolling'
import { runBatchDelete } from '@/shared/utils/batch-delete'
import BrandShopMatchTable from './BrandShopMatchTable.vue'
import {
formatMatchRemark,
formatMatchStatus,
historyItemKey,
isTransientBackendError,
rowKeyForMatch,
uidForStorage,
} from './brand-shop-match-shared'
import { isRecordMissingError, parseTaskStartTimes, removeTaskStartTime, upsertTaskStartTime } from '@/shared/utils/task-queue-state.ts'
import { useTablePaging } from '@/shared/composables/useTablePaging.ts'
import { getModuleProgressLight } from '@/shared/api/progress-light.ts'
@@ -389,11 +347,6 @@ function toWithdrawTaskView(item: WithdrawTaskGroupItem): TaskItemView {
};
}
function uidForStorage() {
return typeof window !== "undefined"
? window.localStorage.getItem("uid") || "0"
: "0";
}
function matchedStorageKey() {
return `withdraw:matched:${uidForStorage()}`;
@@ -407,13 +360,7 @@ function taskStartTimeStorageKey() {
return `withdraw:start-times:${uidForStorage()}`;
}
function rowKeyForMatch(row: WithdrawShopQueueItem) {
return `${(row.shopName || "").trim()}::${row.shopId || ""}`;
}
function historyItemKey(item: WithdrawHistoryItem) {
return `${item.taskId ?? 0}:${item.resultId ?? 0}`;
}
function batchKeyForItems(items: WithdrawShopQueueItem[]) {
return items.map((item) => rowKeyForMatch(item)).join("||");
@@ -513,20 +460,6 @@ function clearSleepTimers() {
timers.clearCategory("queue-wait");
}
function isTransientBackendError(error: unknown) {
const message =
error instanceof Error ? error.message.toLowerCase() : String(error || "").toLowerCase();
return (
message.includes("network error") ||
message.includes("failed to fetch") ||
message.includes("timeout") ||
message.includes("503") ||
message.includes("502") ||
message.includes("504") ||
message.includes("500") ||
message.includes("load failed")
);
}
async function withTransientRetry<T>(
action: () => Promise<T>,
@@ -553,34 +486,7 @@ function createSubmissionId(taskId: number, shopName?: string) {
return `withdraw:${taskId}:${shopName || "shop"}:${Date.now()}`;
}
function formatMatchStatus(status?: string) {
const value = (status || "").trim();
const map: Record<string, string> = {
MATCHED: "已匹配",
PENDING: "待匹配",
CONFLICT: "需人工确认",
INDEX_STALE: "匹配已过期",
};
return map[value] || value || "-";
}
function formatMatchRemark(row: WithdrawShopQueueItem) {
const message = (row.matchMessage || "").trim();
if (message) return message;
if (row.matched && row.matchStatus === "MATCHED") {
return "已匹配成功,可启动任务";
}
if (row.matched) {
return "已匹配成功,请查看状态确认";
}
if (row.matchStatus === "CONFLICT") {
return "存在多个同名店铺,请人工确认";
}
if (row.matchStatus === "PENDING") {
return "店铺尚未匹配完成,请稍后查看";
}
return "未匹配成功,请检查店铺名";
}
function withWithdrawFallback<T extends WithdrawHistoryItem | WithdrawShopQueueItem>(
item: T,
@@ -0,0 +1,61 @@
/** 品牌队列类 Tab(巡店删除/取款/查 ASIN)共用的纯逻辑与存储口径。
* 这三个页面历史上各抄一份,改一处漏两处;这里只收**逐字同形**的部分。 */
export type BrandShopMatchRow = {
shopName?: string | null
shopId?: number | string | null
platform?: string | null
companyName?: string | null
matchStatus?: string | null
matchMessage?: string | null
matched?: boolean
}
const TRANSIENT_BACKEND_ERROR_PATTERNS = [
'network error',
'failed to fetch',
'timeout',
'503',
'502',
'504',
'500',
'load failed',
]
export function uidForStorage(): string {
return typeof window !== 'undefined' ? window.localStorage.getItem('uid') || '0' : '0'
}
export function isTransientBackendError(error: unknown): boolean {
const message = (error instanceof Error ? error.message : String(error || '')).toLowerCase()
return TRANSIENT_BACKEND_ERROR_PATTERNS.some((pattern) => message.includes(pattern))
}
export function formatMatchStatus(status?: string | null): string {
const value = (status || '').trim()
const map: Record<string, string> = {
MATCHED: '已匹配',
PENDING: '待匹配',
CONFLICT: '需人工确认',
INDEX_STALE: '匹配已过期',
}
return map[value] || value || '-'
}
export function formatMatchRemark(row: BrandShopMatchRow): string {
const message = (row.matchMessage || '').trim()
if (message) return message
if (row.matched && row.matchStatus === 'MATCHED') return '已匹配成功,可启动任务'
if (row.matched) return '已匹配成功,请查看状态确认'
if (row.matchStatus === 'CONFLICT') return '存在多个同名店铺,请人工确认'
if (row.matchStatus === 'PENDING') return '店铺尚未匹配完成,请稍后查看'
return '未匹配成功,请检查店铺名'
}
export function rowKeyForMatch(row: { shopName?: string | null; shopId?: number | string | null }): string {
return `${(row.shopName || '').trim()}::${row.shopId || ''}`
}
export function historyItemKey(item: { taskId?: number | null; resultId?: number | null }): string {
return `${item.taskId ?? 0}:${item.resultId ?? 0}`
}
@@ -0,0 +1,24 @@
<script setup lang="ts">
const visible = defineModel<boolean>('visible', { required: true })
defineProps<{
url: string
}>()
</script>
<template>
<el-dialog v-model="visible" title="图片预览" width="760px" class="image-preview-dialog" append-to-body>
<img v-if="url" :src="url" class="image-preview-dialog__image" alt="" />
</el-dialog>
</template>
<style scoped>
.image-preview-dialog__image {
display: block;
width: 100%;
max-height: 72vh;
object-fit: contain;
border-radius: 8px;
background: #101010;
}
</style>
@@ -0,0 +1,240 @@
<script setup lang="ts">
import AiSectionCard from '@/shared/components/ai-workflow/AiSectionCard.vue'
import { safeHttpUrl } from '@/shared/utils/safe-url'
import type { WorkspaceState, WorkspaceTab } from '@/pages/image-video/delivery-video-workspace-types'
defineProps<{
workspace: WorkspaceState
activeTab: WorkspaceTab
busy: boolean
downloading: boolean
polling: boolean
executeId: string
pollCount: number
videoUrl: string
debugUrl: string
resultText: string
primaryActionText: string
canReset: boolean
}>()
const emit = defineEmits<{
primary: []
reset: []
}>()
</script>
<template>
<AiSectionCard :step="activeTab === 'remake' ? '07' : '06'" title="视频结果" description="提交后在这里等待、预览和下载成片。"
class="delivery-card delivery-card--preview">
<el-tabs v-model="workspace.generationMode" class="generation-mode-tabs">
<el-tab-pane label="样片模式" name="draft">
<p>快速生成预览视频,用于验证场景结构、镜头调度、主体动作和提示词意图,消耗更少 token。</p>
</el-tab-pane>
<el-tab-pane label="正常生成" name="standard">
<p>关闭样片模式,按正常规格生成视频。</p>
</el-tab-pane>
</el-tabs>
<div class="preview-panel__meta">
<div class="preview-row">
<span class="preview-row__label">模式</span>
<span class="preview-row__value">{{ activeTab === 'remake' ? '视频复刻' : '图生视频' }}</span>
</div>
<div class="preview-row">
<span class="preview-row__label">规格</span>
<span class="preview-row__value">{{ workspace.ratio }} / {{ workspace.resolution }} / {{
workspace.durationSeconds }}秒</span>
</div>
<div class="preview-row">
<span class="preview-row__label">产品</span>
<span class="preview-row__value">{{ workspace.productName || '未设置' }}</span>
</div>
</div>
<div class="video-result-actions">
<el-button class="delivery-primary-btn" type="primary" :loading="busy || downloading"
:disabled="busy || downloading" @click="emit('primary')">
{{ primaryActionText }}
</el-button>
<el-button v-if="canReset" class="delivery-secondary-btn"
:disabled="busy || downloading" @click="emit('reset')">
重置内容
</el-button>
</div>
<div v-if="busy || executeId" class="assembly-waiting"
:class="{ 'assembly-waiting--done': !busy && executeId }">
<div class="assembly-waiting__spinner" aria-hidden="true"></div>
<div class="assembly-waiting__content">
<strong>{{ polling ? '正在生成视频,请保持页面打开' : '工作流已提交' }}</strong>
<span v-if="executeId">执行 ID:{{ executeId }}</span>
<span v-if="polling">已查询 {{ pollCount }} 次,系统会每 5 秒自动刷新结果。</span>
</div>
</div>
<div class="video-result-panel">
<div v-if="videoUrl" class="video-result-panel__player">
<video :src="videoUrl" controls playsinline preload="metadata"></video>
</div>
<div v-else class="video-result-panel__empty">
<span>{{ polling ? '视频生成中,完成后会在这里显示结果。' : '提交生成后,这里会显示生成的视频结果。' }}</span>
</div>
<div v-if="videoUrl" class="video-result-panel__link">
<span>视频地址</span>
<a :href="safeHttpUrl(videoUrl)" target="_blank" rel="noreferrer">{{ videoUrl }}</a>
</div>
<div v-if="debugUrl" class="video-result-panel__link">
<span>调试链接</span>
<a :href="safeHttpUrl(debugUrl)" target="_blank" rel="noreferrer">{{ debugUrl }}</a>
</div>
<details v-if="resultText" class="video-result-panel__debug">
<summary>查看原始返回</summary>
<el-input :model-value="resultText" type="textarea" :rows="8" resize="none" readonly />
</details>
</div>
</AiSectionCard>
</template>
<style scoped>
.generation-mode-tabs :deep(.el-tabs__header) {
margin-bottom: 10px;
}
.generation-mode-tabs :deep(.el-tabs__item) {
color: #9b9b9b;
font-size: 12px;
}
.generation-mode-tabs :deep(.el-tabs__active-bar) {
background: #c9a260;
}
.generation-mode-tabs :deep(.el-tabs__content) {
display: none;
}
.generation-mode-tabs p {
display: none;
}
.preview-panel__meta {
display: grid;
gap: 6px;
margin-bottom: 12px;
}
.preview-row {
display: flex;
justify-content: space-between;
gap: 12px;
color: #bdbdbd;
font-size: 12px;
}
.preview-row__value {
color: #f4f4f4;
text-align: right;
}
.video-result-actions {
display: grid;
gap: 8px;
margin-bottom: 12px;
}
.delivery-primary-btn {
width: 100%;
min-height: 40px;
margin-bottom: 12px;
border-color: transparent;
background: linear-gradient(135deg, #a57d45 0%, #c9a260 100%);
color: #fff;
font-weight: 800;
}
.delivery-secondary-btn {
width: 100%;
margin-left: 0 !important;
}
.assembly-waiting {
display: flex;
gap: 10px;
align-items: flex-start;
padding: 10px 12px;
margin-bottom: 12px;
border: 1px solid #3b3224;
border-radius: 8px;
background: rgba(181, 140, 81, 0.1);
}
.assembly-waiting--done {
border-color: #2f4234;
background: rgba(74, 170, 118, 0.08);
}
.assembly-waiting__spinner {
width: 14px;
height: 14px;
margin-top: 2px;
border: 2px solid rgba(201, 162, 96, 0.3);
border-top-color: #c9a260;
border-radius: 50%;
animation: assembly-spin 0.9s linear infinite;
}
.assembly-waiting--done .assembly-waiting__spinner {
display: none;
}
.assembly-waiting__content {
display: grid;
gap: 3px;
}
.assembly-waiting__content strong {
color: #f4d392;
font-size: 12px;
}
.assembly-waiting__content span {
color: #a8a8a8;
font-size: 11px;
word-break: break-all;
}
.video-result-panel {
display: grid;
gap: 10px;
}
.video-result-panel__player,
.video-result-panel__empty {
display: flex;
align-items: center;
justify-content: center;
min-height: 180px;
border: 1px solid #303030;
border-radius: 10px;
background: #101010;
overflow: hidden;
}
.video-result-panel__player video {
width: 100%;
max-height: 360px;
}
.video-result-panel__empty {
padding: 20px;
color: #9b9b9b;
font-size: 12px;
text-align: center;
}
.video-result-panel__link {
display: grid;
gap: 3px;
color: #bdbdbd;
font-size: 11px;
word-break: break-all;
}
.video-result-panel__link span {
color: #9b9b9b;
}
.video-result-panel__link a {
color: #c9a260;
}
.video-result-panel__debug {
color: #bdbdbd;
font-size: 12px;
}
.video-result-panel__debug summary {
cursor: pointer;
}
.video-result-panel__debug :deep(.el-textarea__inner) {
margin-top: 8px;
font-family: Consolas, 'Courier New', monospace;
font-size: 11px;
}
@keyframes assembly-spin {
to {
transform: rotate(360deg);
}
}
</style>
@@ -0,0 +1,93 @@
<script setup lang="ts">
import type { SecretForm, SecretStatus } from '@/pages/image-video/delivery-video-workspace-types'
const visible = defineModel<boolean>('visible', { required: true })
defineProps<{
status: SecretStatus | null
statusText: string
expireText: string
saving: boolean
form: SecretForm
}>()
const emit = defineEmits<{
save: []
}>()
</script>
<template>
<el-dialog v-model="visible" title="视频密钥设置" width="560px" class="image-video-secret-dialog"
append-to-body destroy-on-close>
<div class="secret-status" :class="{ 'secret-status--valid': status?.valid }">
<span>{{ statusText }}</span>
<span v-if="expireText">{{ expireText }}</span>
</div>
<el-form label-position="top" class="secret-form">
<el-form-item label="爬虫密钥">
<el-input v-model="form.copyApiKey" type="password" show-password placeholder="不填写则保留当前有效值" />
<div v-if="status?.copyApiKeyMasked" class="secret-form__hint">当前:{{ status.copyApiKeyMasked }}</div>
</el-form-item>
<el-form-item label="T8密钥(海外)">
<el-input v-model="form.t8Key" type="password" show-password placeholder="不填写则保留当前有效值" />
<div v-if="status?.t8KeyMasked" class="secret-form__hint">当前:{{ status.t8KeyMasked }}</div>
</el-form-item>
<el-form-item label="T8密钥(国内)">
<el-input v-model="form.t8VideoKey" type="password" show-password placeholder="不填写则保留当前有效值" />
<div v-if="status?.t8VideoKeyMasked" class="secret-form__hint">当前:{{ status.t8VideoKeyMasked }}</div>
</el-form-item>
<el-form-item label="音频密钥">
<el-input v-model="form.voiceApiKey" type="password" show-password placeholder="不填写则保留当前有效值" />
<div v-if="status?.voiceApiKeyMasked" class="secret-form__hint">当前:{{ status.voiceApiKeyMasked }}</div>
</el-form-item>
<el-form-item label="音频团队ID">
<el-input v-model="form.voiceGroupId" type="password" show-password placeholder="不填写则保留当前有效值" />
<div v-if="status?.voiceGroupIdMasked" class="secret-form__hint">当前:{{ status.voiceGroupIdMasked }}</div>
</el-form-item>
<el-form-item label="有效期">
<el-select v-model="form.expireDays" class="delivery-select">
<el-option label="1 天" :value="1" />
<el-option label="7 天" :value="7" />
<el-option label="30 天" :value="30" />
<el-option label="永久" :value="0" />
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" :loading="saving" @click="emit('save')">保存</el-button>
</template>
</el-dialog>
</template>
<style scoped>
.secret-status {
display: flex;
justify-content: space-between;
gap: 12px;
margin-bottom: 16px;
padding: 10px 12px;
border: 1px solid #4a3620;
border-radius: 8px;
background: rgba(181, 140, 81, 0.12);
color: #f4d392;
font-size: 13px;
}
.secret-status--valid {
border-color: rgba(74, 170, 118, 0.45);
background: rgba(74, 170, 118, 0.12);
color: #b8f0cf;
}
.secret-form {
max-height: 56vh;
overflow-y: auto;
padding-right: 4px;
}
.secret-form__hint {
margin-top: 6px;
color: #a8a8a8;
font-size: 12px;
}
</style>
@@ -0,0 +1,202 @@
<script setup lang="ts">
import AiAssetDropzone from '@/shared/components/ai-workflow/AiAssetDropzone.vue'
import type { AssetState, VoiceListItem } from '@/pages/image-video/delivery-video-workspace-types'
const visible = defineModel<boolean>('visible', { required: true })
const tab = defineModel<'list' | 'clone'>('tab', { required: true })
const keyword = defineModel<string>('keyword', { required: true })
const cloneName = defineModel<string>('cloneName', { required: true })
defineProps<{
items: VoiceListItem[]
filteredItems: VoiceListItem[]
loading: boolean
cloneAsset: AssetState
}>()
const emit = defineEmits<{
list: []
use: [VoiceListItem]
delete: [VoiceListItem]
clone: []
selectCloneAsset: [File]
urlCloneAsset: [string]
clearCloneAsset: []
}>()
</script>
<template>
<el-dialog v-model="visible" title="音色管理" width="920px" class="image-video-secret-dialog voice-dialog"
append-to-body>
<el-tabs v-model="tab" class="voice-dialog__tabs">
<el-tab-pane label="音色列表" name="list">
<div class="voice-dialog__toolbar voice-dialog__toolbar--list">
<div class="voice-list-summary">
<strong>{{ filteredItems.length }}</strong>
<span>/ {{ items.length }} 个音色</span>
</div>
<el-input v-model="keyword" class="voice-search-input" clearable placeholder="搜索音色名称或 voice_id"
@keyup.enter="emit('list')" @clear="emit('list')" />
<button type="button" class="script-primary-action-btn" :disabled="loading" @click="emit('list')">
刷新音色
</button>
</div>
<div v-if="filteredItems.length" class="voice-list">
<div v-for="item in filteredItems" :key="item.voiceId" class="voice-list__item">
<div class="voice-list__meta">
<strong>{{ item.name || item.voiceId }}</strong>
<span>{{ item.voiceId }}</span>
<em v-if="item.description">{{ item.description }}</em>
</div>
<span class="voice-list__source">{{ item.sourceLabel }}</span>
<button type="button" class="script-action-btn" @click="emit('use', item)">使用此音色</button>
<button v-if="item.sourceKey !== 'system_voice'" type="button"
class="script-action-btn script-action-btn--danger" :disabled="loading"
@click="emit('delete', item)">删除音色</button>
</div>
</div>
<el-empty v-else description="暂无可展示音色,请确认接口已返回音色数据" />
</el-tab-pane>
<el-tab-pane label="克隆音色" name="clone">
<div class="delivery-field">
<span class="delivery-field__label">音色名称</span>
<el-input v-model="cloneName" clearable placeholder="输入克隆后的音色名称" />
</div>
<AiAssetDropzone title="克隆素材" description="仅用于音色克隆,不会写入 text_info.file_url。" placeholder="上传音频或视频"
helper="支持 MP3 / WAV / MP4,或粘贴素材链接" accept="audio/*,video/*" :file-name="cloneAsset.fileName"
:preview-url="cloneAsset.previewUrl" :preview-kind="cloneAsset.previewKind"
:source-url="cloneAsset.sourceUrl" :loading="cloneAsset.uploading" allow-url compact
action-label="上传克隆素材" selected-label="克隆素材" url-label="克隆素材链接"
@select="(file) => emit('selectCloneAsset', file)"
@url-change="(url) => emit('urlCloneAsset', url)"
@clear="emit('clearCloneAsset')" />
<div class="voice-dialog__toolbar">
<button type="button" class="script-primary-action-btn" :disabled="loading" @click="emit('clone')">
开始克隆
</button>
</div>
</el-tab-pane>
</el-tabs>
</el-dialog>
</template>
<style scoped>
.voice-dialog__tabs {
gap: 10px;
}
.voice-dialog__tabs :deep(.el-tabs__item:not(.is-active)) {
color: #9b9b9b;
}
.voice-dialog__toolbar {
display: flex;
justify-content: flex-end;
margin-top: 12px;
}
.voice-dialog__toolbar--list {
align-items: center;
justify-content: flex-start;
gap: 10px;
margin-top: 0;
margin-bottom: 12px;
}
.voice-list-summary {
display: flex;
align-items: baseline;
gap: 4px;
color: #9b9b9b;
font-size: 12px;
white-space: nowrap;
}
.voice-list-summary strong {
color: #f4f4f4;
font-size: 16px;
}
.voice-search-input {
max-width: 280px;
}
.voice-list {
display: grid;
gap: 8px;
max-height: 52vh;
overflow-y: auto;
}
.voice-list__item {
display: grid;
grid-template-columns: minmax(0, 1fr) auto auto auto;
gap: 10px;
align-items: center;
padding: 10px 12px;
border: 1px solid #303030;
border-radius: 8px;
background: #111;
}
.voice-list__meta {
display: grid;
gap: 2px;
min-width: 0;
}
.voice-list__meta strong {
color: #f4f4f4;
font-size: 13px;
}
.voice-list__meta span {
color: #9b9b9b;
font-size: 11px;
word-break: break-all;
}
.voice-list__meta em {
color: #c8c8c8;
font-size: 12px;
font-style: normal;
}
.voice-list__source {
color: #b99455;
font-size: 11px;
white-space: nowrap;
}
.delivery-field {
display: grid;
gap: 6px;
margin-bottom: 12px;
}
.delivery-field__label {
color: #bdbdbd;
font-size: 12px;
}
.script-action-btn,
.script-primary-action-btn {
min-height: 36px;
border: 1px solid #484848;
border-radius: 8px;
background: #171717;
color: #f7f7ff;
font: inherit;
font-size: 13px;
font-weight: 700;
cursor: pointer;
white-space: nowrap;
}
.script-primary-action-btn {
background: linear-gradient(135deg, #a57d45 0%, #c9a260 100%);
border-color: transparent;
color: #fff;
}
.script-action-btn--danger {
color: #ff9f9f;
}
.script-action-btn:disabled,
.script-primary-action-btn:disabled {
opacity: 0.55;
cursor: not-allowed;
}
@media (max-width: 980px) {
.voice-list__item {
grid-template-columns: 1fr;
}
.voice-dialog__toolbar--list {
align-items: stretch;
flex-direction: column;
}
}
</style>
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,83 @@
import type { ImageVideoSecretStatusVo } from '@/shared/api/java-modules'
export type WorkspaceTab = 'remake' | 'imageToVideo'
export type PreviewKind = 'image' | 'video' | 'file'
export type MediaType = 'image' | 'video' | 'audio' | 'file'
export type AssetKey = 'referenceAsset' | 'sceneAsset' | 'modelAsset' | 'speechAsset'
export type VoiceMode = 'textOnly' | 'uploadAudio' | 'synthesize'
export type VoiceStatusType = 'info' | 'success' | 'error'
export type AssetState = {
/** v-for 稳定 key(审查 C6):产品图可删中间行,用 index 当 key 会让上传槽组件实例错位复用 */
id: string
fileName: string
previewUrl: string
previewKind: PreviewKind
sourceUrl: string
mediaType: MediaType
uploading: boolean
}
export type AssemblyState = {
loading: boolean
resultText: string
executeId: string
polling: boolean
pollCount: number
videoUrl: string
debugUrl: string
downloading: boolean
pollTimer: number
}
export type WorkspaceState = {
referenceAsset: AssetState
productAssets: AssetState[]
sceneAsset: AssetState
modelAsset: AssetState
speechAsset: AssetState
ratio: string
resolution: string
model: string
generationMode: 'draft' | 'standard'
duration: string
durationSeconds: number
videoPrompt: string
sceneMode: string
scenePrompt: string
faceInputType: string
gender: string
modelFigure: string
language: string
audioType: string
voiceMode: VoiceMode
voiceId: string
voiceName: string
scriptText: string
scriptSourceUrl: string
categoryName: string
productName: string
productFocus: string
assembly: AssemblyState
}
export type VoiceListItem = {
voiceId: string
name: string
groupId: string
description: string
sourceKey: string
sourceLabel: string
raw: unknown
}
export type SecretForm = {
copyApiKey: string
t8Key: string
t8VideoKey: string
voiceApiKey: string
voiceGroupId: string
expireDays: number
}
export type SecretStatus = ImageVideoSecretStatusVo