完成菜单权限添加和软件菜单改造

This commit is contained in:
super
2026-04-12 17:15:15 +08:00
parent 365050b890
commit d0d3c6ee67
28 changed files with 983 additions and 465 deletions

View File

@@ -54,6 +54,10 @@
<button type="button" class="btn-run" :disabled="running" @click="submitRun">
{{ running ? '解析中...' : '开始解析' }}
</button>
<button type="button" class="btn-run btn-queue" :disabled="pushing || !queueRunnableItems.length"
@click="pushToPythonQueue">
{{ pushing ? '推送中...' : '推送到 Python 队列' }}
</button>
<span class="loading-msg">
{{ running ? '正在读取删除品牌数据,请稍候…' : '解析后会在右侧展示按国家分组的去重结果' }}
</span>
@@ -133,9 +137,6 @@
<span class="status" :class="getTaskStatusInfo(item).className">
{{ getTaskStatusInfo(item).text }}
</span>
<button v-if="item.openStoreUrl" type="button" class="download" @click="triggerItemRun(item)">
打开紫鸟
</button>
<button v-if="canDownloadTaskResult(item)" type="button" class="download"
@click="downloadTaskResult(item)">
下载
@@ -254,9 +255,11 @@ const queuePayloadText = ref('')
const taskDetails = ref<Record<number, DeleteBrandTaskDetailVo>>({})
const pollTimer = ref<number | null>(null)
const pollingInFlight = ref(false)
const pushing = ref(false)
const chainStarted = ref(false)
const activeItemKey = ref('')
const autoAdvancing = ref(false)
const autoRetryTimer = ref<number | null>(null)
const displayPaths = computed(() => selectedPaths.value.slice(0, 10))
const currentSectionItems = computed(() => {
@@ -375,10 +378,14 @@ const historySectionItems = computed(() =>
),
);
const hasVisibleItems = computed(() => currentSectionItems.value.length > 0 || historySectionItems.value.length > 0)
const queueRunnableItems = computed(() =>
currentSectionItems.value.filter((item) => canPushToQueue(item) && getQueueStatus(item) === '未入队'),
)
function persistSessionTasks() {
if (typeof window !== 'undefined') {
window.localStorage.setItem(getStorageKey(), JSON.stringify(sessionTasks.value))
if (sessionTasks.value.length === 0) window.localStorage.removeItem(getStorageKey())
else window.localStorage.setItem(getStorageKey(), JSON.stringify(sessionTasks.value))
}
}
@@ -490,7 +497,7 @@ function shouldShowProgress(item: DeleteBrandResultItem) {
return true
}
return false
return { success: false, retryable: true }
}
// 单文件任务:完成/终态后隐藏。
@@ -773,7 +780,7 @@ function canDownloadTaskResult(item: DeleteBrandResultItem) {
if (item.downloadUrl) return true
const taskId = item.taskId
if (!taskId) return false
if (!taskId) return { success: false, retryable: false }
const status = taskDetails.value[taskId]?.task?.status
return status === 'SUCCESS'
}
@@ -782,7 +789,7 @@ function mergeTaskDetailItemsIntoSession(detail: DeleteBrandTaskDetailVo) {
const taskId = detail?.task?.id
if (!taskId) return false
const sessionTask = sessionTasks.value.find(t => t.taskId === taskId)
if (!sessionTask) return false
if (!sessionTask) return { success: false, retryable: false }
const detailItems = detail?.items || []
let changed = false
@@ -953,6 +960,7 @@ function stopPolling() {
window.clearTimeout(pollTimer.value)
pollTimer.value = null
}
clearAutoRetryTimer()
}
async function uploadPathsToJava(paths: Array<string | BrandExpandFolderItem>) {
@@ -1031,7 +1039,9 @@ async function submitRun() {
const hasMatchedItems = normalizedItems.some((item) => item.matchStatus === 'MATCHED')
const hasPendingItems = normalizedItems.some((item) => item.matchStatus && item.matchStatus !== 'MATCHED')
queuePushResult.value = '解析完成,等待手动点击打开紫鸟进行单任务处理'
queuePushResult.value = hasMatchedItems
? '解析完成,可在左侧点击“推送到 Python 队列”开始串行处理'
: '解析完成,当前没有可推送的已匹配文件'
queuePayloadText.value = ''
if (normalizedItems.length && normalizedItems[0].taskId) {
@@ -1042,7 +1052,7 @@ async function submitRun() {
if (hasPendingItems) {
ElMessage.warning('部分文件尚未命中可用店铺索引,已保留状态信息,请等待后台刷新后重试。')
} else if (hasMatchedItems) {
ElMessage.success('删除品牌解析完成,请手动推送')
ElMessage.success('删除品牌解析完成,请在左侧推送到 Python 队列')
} else {
ElMessage.warning('当前没有可推送的已匹配文件,请先等待店铺索引刷新。')
}
@@ -1143,6 +1153,26 @@ function debugAutoAdvance(step: string, payload?: Record<string, unknown>) {
console.log(`[DeleteBrandAutoAdvance] ${step}`, payload || {})
}
function clearAutoRetryTimer() {
if (autoRetryTimer.value) {
window.clearTimeout(autoRetryTimer.value)
autoRetryTimer.value = null
}
}
function scheduleAutoAdvanceRetry(delayMs = 3000) {
clearAutoRetryTimer()
autoRetryTimer.value = window.setTimeout(() => {
autoRetryTimer.value = null
maybeAutoAdvance().catch(() => undefined)
}, delayMs)
}
function isQueueBusyError(message?: string) {
if (!message) return false
return message.includes('当前店铺正在执行中')
}
function isPythonQueueBusy() {
for (const task of sessionTasks.value) {
for (const item of task.items) {
@@ -1160,9 +1190,13 @@ function getItemKey(item: DeleteBrandResultItem) {
return `task:${item.taskId || 0}:${item.sourceFilename || ''}`
}
function canPushToQueue(item: DeleteBrandResultItem) {
return Boolean(item.taskId && (item.matchStatus === 'MATCHED' || item.matched))
}
function findNextAutoRunnableItem() {
return currentSectionItems.value.find((item) => {
if (!item.openStoreUrl) return false
if (!canPushToQueue(item)) return false
if (getItemKey(item) === activeItemKey.value) return false
const sessionItem = findSessionItem(item.taskId, item)
if (sessionItem?._completed) return false
@@ -1177,20 +1211,20 @@ async function runItem(item: DeleteBrandResultItem, options?: { auto?: boolean }
taskId: item.taskId,
sourceFilename: item.sourceFilename,
})
return false
return { success: false, retryable: true }
}
const api = getPywebviewApi()
const taskId = item.taskId
if (!taskId) return false
if (!taskId) return { success: false, retryable: false }
const sessionTask = sessionTasks.value.find(t => t.taskId === taskId)
if (!sessionTask) return false
if (!sessionTask) return { success: false, retryable: false }
if (!api?.enqueue_json) {
ElMessage.error('当前环境未启用 pywebview enqueue_json浏览器环境不会推送')
return false
return { success: false, retryable: false }
}
const payload = {
@@ -1216,11 +1250,39 @@ async function runItem(item: DeleteBrandResultItem, options?: { auto?: boolean }
activeItemKey.value = getItemKey(item)
saveSessionTask(taskId, sessionTask.items, qpr, queuePayloadText.value)
ensurePolling(true)
queuePushResult.value = qpr
return { success: true, retryable: false }
} else {
qpr = `推送到 Python 队列失败:${pushResult?.error || '未知错误'}`
const message = pushResult?.error || '未知错误'
qpr = `推送到 Python 队列失败:${message}`
queuePushResult.value = qpr
saveSessionTask(taskId, sessionTask.items, qpr, queuePayloadText.value)
if (options?.auto && isQueueBusyError(message)) {
return { success: false, retryable: true }
}
}
queuePushResult.value = qpr
return Boolean(pushResult?.success)
return { success: false, retryable: false }
}
async function pushToPythonQueue() {
const nextItem = findNextAutoRunnableItem()
if (!nextItem) {
ElMessage.warning('当前没有可推送的已匹配文件')
return
}
pushing.value = true
chainStarted.value = true
clearAutoRetryTimer()
const started = await runItem(nextItem)
pushing.value = false
if (!started.success) {
chainStarted.value = false
activeItemKey.value = ''
return
}
ElMessage.success('已开始按顺序推送到 Python 队列')
}
async function maybeAutoAdvance() {
@@ -1294,7 +1356,15 @@ async function maybeAutoAdvance() {
nextKey: getItemKey(nextItem),
})
const started = await runItem(nextItem, { auto: true })
if (!started) {
if (!started.success) {
if (started.retryable) {
debugAutoAdvance('delay retry next item', {
taskId: nextItem.taskId,
sourceFilename: nextItem.sourceFilename,
})
scheduleAutoAdvanceRetry()
return
}
debugAutoAdvance('stop chain: runItem returned false', {
taskId: nextItem.taskId,
sourceFilename: nextItem.sourceFilename,
@@ -1306,15 +1376,6 @@ async function maybeAutoAdvance() {
}
}
async function triggerItemRun(item: DeleteBrandResultItem) {
chainStarted.value = true
const started = await runItem(item)
if (!started) {
chainStarted.value = false
activeItemKey.value = ''
}
}
onMounted(() => {
loadSessionTasksFromStorage()
const taskIds = getPollingTaskIds()

View File

@@ -59,7 +59,7 @@
<p class="hint listing-filter-hint">推送到 Python 队列一并下发 Python 区分处理场景</p>
<div class="listing-filter-row">
<el-select v-model="productRiskListingFilter" class="listing-filter-select" teleported placeholder="选择筛选类型">
<el-option v-for="opt in PRODUCT_RISK_LISTING_FILTER_OPTIONS" :key="opt.value" :label="opt.label"
<el-option v-for="opt in LISTING_FILTER_OPTIONS" :key="opt.value" :label="opt.label"
:value="opt.value" />
</el-select>
</div>
@@ -196,6 +196,7 @@
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import BrandTopBar from '@/pages/brand/components/BrandTopBar.vue'
import { LISTING_FILTER_OPTIONS, type ListingFilterValue } from '@/pages/brand/components/listingFilters'
import {
addProductRiskCandidate,
createProductRiskTask,
@@ -238,17 +239,8 @@ const COUNTRY_OPTIONS = [
{ code: 'ES', label: '西班牙' },
] as const
/** 与 Python 约定:队列 payload.data.risk_listing_filter */
const PRODUCT_RISK_LISTING_FILTER_OPTIONS = [
{ value: 'SearchSuppressed', label: '在搜索结果中禁止显示' },
{ value: 'ApprovalRequired', label: '需要批准' },
{ value: 'Active', label: '在售' },
] as const
type ProductRiskListingFilter = (typeof PRODUCT_RISK_LISTING_FILTER_OPTIONS)[number]['value']
const orderedCountryCodes = ref<string[]>(['DE', 'UK', 'FR', 'IT', 'ES'])
const productRiskListingFilter = ref<ProductRiskListingFilter>('SearchSuppressed')
const productRiskListingFilter = ref<ListingFilterValue>('SearchSuppressed')
const dragCountryIndex = ref<number | null>(null)
const countryPrefSaving = ref(false)
/** 用户已改过顺序/勾选后,忽略晚到的 GET避免把界面打回全选 */
@@ -399,6 +391,19 @@ function matchedItemsStorageKey() {
return `product-risk:matched-items:${uidForStorage()}`
}
function setStorageJson(key: string, value: unknown, shouldRemove: boolean) {
if (typeof window === 'undefined') return
try {
if (shouldRemove) {
window.localStorage.removeItem(key)
} else {
window.localStorage.setItem(key, JSON.stringify(value))
}
} catch {
/* quota */
}
}
function loadTaskDetailsFromStorage() {
try {
const raw = typeof window !== 'undefined' ? window.localStorage.getItem(taskStatusStorageKey()) : null
@@ -416,12 +421,7 @@ function loadTaskDetailsFromStorage() {
}
function saveTaskDetailsToStorage() {
if (typeof window === 'undefined') return
try {
window.localStorage.setItem(taskStatusStorageKey(), JSON.stringify(taskDetails.value))
} catch {
/* quota */
}
setStorageJson(taskStatusStorageKey(), taskDetails.value, Object.keys(taskDetails.value).length === 0)
}
function loadTaskSnapshotsFromStorage() {
@@ -441,12 +441,7 @@ function loadTaskSnapshotsFromStorage() {
}
function saveTaskSnapshotsToStorage() {
if (typeof window === 'undefined') return
try {
window.localStorage.setItem(taskSnapshotsStorageKey(), JSON.stringify(taskSnapshots.value))
} catch {
/* quota */
}
setStorageJson(taskSnapshotsStorageKey(), taskSnapshots.value, Object.keys(taskSnapshots.value).length === 0)
}
function loadMatchedItemsFromStorage() {
@@ -461,21 +456,16 @@ function loadMatchedItemsFromStorage() {
}
function saveMatchedItemsToStorage() {
if (typeof window === 'undefined') return
try {
window.localStorage.setItem(matchedItemsStorageKey(), JSON.stringify(matchedItems.value))
} catch {
/* quota */
}
setStorageJson(matchedItemsStorageKey(), matchedItems.value, matchedItems.value.length === 0)
}
function rowKeyForMatch(row: ProductRiskShopQueueItem) {
function rowKeyForMatch(row: { shopName?: string; shopId?: number | string | null }) {
const name = (row.shopName || '').trim()
const id = row.shopId ?? ''
return `${name}\u0001${id}`
}
function removeMatchedRowsLocally(rows: ProductRiskShopQueueItem[]) {
function removeMatchedRowsLocally(rows: Array<{ shopName?: string; shopId?: number | string | null }>) {
if (!rows.length) return
const keys = new Set(rows.map((row) => rowKeyForMatch(row)))
matchedItems.value = matchedItems.value.filter((row) => !keys.has(rowKeyForMatch(row)))
@@ -527,6 +517,10 @@ async function deleteTaskRecord(item: ProductRiskHistoryItem) {
ElMessage.warning('无法删除:缺少记录标识')
return
}
if (item.taskId != null && item.taskId > 0) {
removePollingTask(item.taskId)
}
removeMatchedRowsLocally([item])
await loadHistory()
await loadDashboard()
syncPollingIdsWithHistory()
@@ -551,9 +545,7 @@ function loadPollingIdsFromStorage() {
}
function savePollingIds() {
if (typeof window !== 'undefined') {
window.localStorage.setItem(sessionKey(), JSON.stringify(pollingTaskIds.value))
}
setStorageJson(sessionKey(), pollingTaskIds.value, pollingTaskIds.value.length === 0)
}
function addPollingTask(taskId: number) {

View File

@@ -38,6 +38,13 @@
</div>
</div>
<div v-if="countryPrefSaving" class="country-pref-status">保存中...</div>
<div class="section-title">商品列表筛选</div>
<p class="hint listing-filter-hint">推送到 Python 队列一并下发 Python 区分处理场景</p>
<div class="listing-filter-row">
<el-select v-model="shopMatchListingFilter" class="listing-filter-select" teleported placeholder="选择筛选类型">
<el-option v-for="opt in LISTING_FILTER_OPTIONS" :key="opt.value" :label="opt.label" :value="opt.value" />
</el-select>
</div>
<div class="section-title">定时执行</div>
<label class="schedule-switch"><input v-model="scheduleEnabled" type="checkbox" :disabled="pushing" @change="onScheduleToggle" /><span>启用多时间点调度</span></label>
<div v-if="scheduleEnabled" class="schedule-config">
@@ -100,6 +107,7 @@
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { ElMessage } from 'element-plus'
import BrandTopBar from '@/pages/brand/components/BrandTopBar.vue'
import { LISTING_FILTER_OPTIONS, type ListingFilterValue } from '@/pages/brand/components/listingFilters'
import { activateShopMatchTask, addShopMatchCandidate, createShopMatchTask, deleteShopMatchCandidate, deleteShopMatchHistory, deleteShopMatchTask, getShopMatchCountryPreference, getShopMatchDashboard, getShopMatchHistory, getShopMatchResultDownloadUrl, getShopMatchTasksBatch, listShopMatchCandidates, matchShopMatchShops, putShopMatchCountryPreference, type ShopMatchCandidateVo, type ShopMatchDashboardVo, type ShopMatchHistoryItem, type ShopMatchShopQueueItem, type ShopMatchTaskDetailVo } from '@/shared/api/java-modules'
import { getPywebviewApi } from '@/shared/bridges/pywebview'
@@ -108,6 +116,7 @@ const shopInput = ref('')
const candidates = ref<ShopMatchCandidateVo[]>([])
const selectedCandidates = ref<ShopMatchCandidateVo[]>([])
const matchedItems = ref<ShopMatchShopQueueItem[]>([])
const shopMatchListingFilter = ref<ListingFilterValue>('Active')
const adding = ref(false)
const matching = ref(false)
const pushing = ref(false)
@@ -144,6 +153,7 @@ function sessionKey() { return `shop-match:tasks:${uidForStorage()}` }
function taskStatusStorageKey() { return `shop-match:task-status:${uidForStorage()}` }
function taskSnapshotsStorageKey() { return `shop-match:task-snapshots:${uidForStorage()}` }
function matchedItemsStorageKey() { return `shop-match:matched-items:${uidForStorage()}` }
function setStorageJson(key: string, value: unknown, shouldRemove: boolean) { if (shouldRemove) window.localStorage.removeItem(key); else window.localStorage.setItem(key, JSON.stringify(value)) }
function rowKeyForMatch(row: ShopMatchShopQueueItem) { return `${(row.shopName || '').trim()}::${row.shopId || ''}` }
function taskRowKey(item: ShopMatchHistoryItem) { return `${normalizeTaskId(item.taskId)}-${item.resultId || 0}-${item.shopName || ''}` }
function countryLabel(code: string) { return COUNTRY_OPTIONS.find((item) => item.code === code)?.label || code }
@@ -164,13 +174,13 @@ function formatDateTime(value?: string) { return value ? value.replace('T', ' ')
function formatTimeOnly(value?: string) { return value ? value.slice(11, 16) : '-' }
function uniqueTaskRows(rows: ShopMatchHistoryItem[], snapshots: Record<number, ShopMatchTaskDetailVo>, section: 'current' | 'history') { const map = new Map<string, ShopMatchHistoryItem>(); for (const row of rows) map.set(taskRowKey(row), row); for (const [taskIdText, snapshot] of Object.entries(snapshots)) { const taskId = normalizeTaskId(taskIdText); const first = snapshot.items?.[0]; if (!first || !taskId) continue; const terminal = isTaskTerminalById(taskId); if ((section === 'current' && terminal) || (section === 'history' && !terminal)) continue; const key = taskRowKey({ ...first, taskId }); if (!map.has(key)) map.set(key, { ...first, taskId }) } return Array.from(map.values()) }
function loadPollingIdsFromStorage() { try { const raw = window.localStorage.getItem(sessionKey()); const parsed = raw ? JSON.parse(raw) : []; pollingTaskIds.value = Array.isArray(parsed) ? parsed.filter((item): item is number => typeof item === 'number' && item > 0) : [] } catch { pollingTaskIds.value = [] } }
function savePollingIds() { window.localStorage.setItem(sessionKey(), JSON.stringify(pollingTaskIds.value)) }
function savePollingIds() { setStorageJson(sessionKey(), pollingTaskIds.value, pollingTaskIds.value.length === 0) }
function loadTaskDetailsFromStorage() { try { const raw = window.localStorage.getItem(taskStatusStorageKey()); taskDetails.value = raw ? JSON.parse(raw) : {} } catch { taskDetails.value = {} } }
function saveTaskDetailsToStorage() { window.localStorage.setItem(taskStatusStorageKey(), JSON.stringify(taskDetails.value)) }
function saveTaskDetailsToStorage() { setStorageJson(taskStatusStorageKey(), taskDetails.value, Object.keys(taskDetails.value).length === 0) }
function loadTaskSnapshotsFromStorage() { try { const raw = window.localStorage.getItem(taskSnapshotsStorageKey()); taskSnapshots.value = raw ? JSON.parse(raw) : {} } catch { taskSnapshots.value = {} } }
function saveTaskSnapshotsToStorage() { window.localStorage.setItem(taskSnapshotsStorageKey(), JSON.stringify(taskSnapshots.value)) }
function saveTaskSnapshotsToStorage() { setStorageJson(taskSnapshotsStorageKey(), taskSnapshots.value, Object.keys(taskSnapshots.value).length === 0) }
function loadMatchedItemsFromStorage() { try { const raw = window.localStorage.getItem(matchedItemsStorageKey()); matchedItems.value = raw ? JSON.parse(raw) : [] } catch { matchedItems.value = [] } }
function saveMatchedItemsToStorage() { window.localStorage.setItem(matchedItemsStorageKey(), JSON.stringify(matchedItems.value)) }
function saveMatchedItemsToStorage() { setStorageJson(matchedItemsStorageKey(), matchedItems.value, matchedItems.value.length === 0) }
function syncPollingIdsWithTaskState() { const nextIds = pollingTaskIds.value.filter((taskId) => (taskDetails.value[taskId] || taskSnapshots.value[taskId]?.task?.status) === 'RUNNING'); if (nextIds.length === pollingTaskIds.value.length) return; pollingTaskIds.value = nextIds; savePollingIds() }
function addPollingTask(taskId: number) { if (!pollingTaskIds.value.includes(taskId)) { pollingTaskIds.value = [...pollingTaskIds.value, taskId]; savePollingIds() } }
function clearDispatchTimer(taskId: number) { const timer = dispatchTimers.get(taskId); if (timer) { window.clearTimeout(timer); dispatchTimers.delete(taskId) } }
@@ -209,7 +219,7 @@ async function runMatch() { const names = selectedCandidates.value.map((item) =>
function removeMatchedRow(row: ShopMatchShopQueueItem) { matchedItems.value = matchedItems.value.filter((item) => rowKeyForMatch(item) !== rowKeyForMatch(row)); saveMatchedItemsToStorage() }
function removeMatchedRowsLocally(rows: ShopMatchHistoryItem[] | ShopMatchShopQueueItem[]) { const keys = new Set(rows.map((row) => rowKeyForMatch(row as ShopMatchShopQueueItem))); matchedItems.value = matchedItems.value.filter((item) => !keys.has(rowKeyForMatch(item))); saveMatchedItemsToStorage() }
function parseScheduleValues() { if (!scheduleEnabled.value) return undefined; const values = schedulePickerValues.value.map((item) => item.trim()).filter(Boolean); if (!values.length) throw new Error('请至少选择一个执行时间'); const withTime = values.map((value) => { const normalized = normalizeScheduleValue(value); const date = resolveScheduleDateTime(normalized); if (!date) throw new Error(`时间格式无效: ${value}`); return { raw: formatScheduleDateTime(date), time: date.getTime() } }).sort((a, b) => a.time - b.time); for (let i = 1; i < withTime.length; i += 1) if (withTime[i].time === withTime[i - 1].time) throw new Error('执行时间不能重复'); return withTime.map((item) => item.raw) }
function buildQueuePayload(taskId: number, item: Pick<ShopMatchHistoryItem, 'shopName' | 'shopId' | 'platform' | 'companyName' | 'matchStatus' | 'matchMessage'>, countryCodes: string[], stageIndex?: number, finalStage = true) { return { type: 'shop-match-run', ts: Date.now(), data: { taskId, user_id: currentUserId(), items: [{ shopName: item.shopName, shopId: item.shopId, platform: item.platform, companyName: item.companyName, matched: true, matchStatus: item.matchStatus, matchMessage: item.matchMessage }], country_codes: [...countryCodes], stage_index: stageIndex, final_stage: finalStage } } }
function buildQueuePayload(taskId: number, item: Pick<ShopMatchHistoryItem, 'shopName' | 'shopId' | 'platform' | 'companyName' | 'matchStatus' | 'matchMessage'>, countryCodes: string[], stageIndex?: number, finalStage = true) { return { type: 'shop-match-run', ts: Date.now(), data: { taskId, user_id: currentUserId(), items: [{ shopName: item.shopName, shopId: item.shopId, platform: item.platform, companyName: item.companyName, matched: true, matchStatus: item.matchStatus, matchMessage: item.matchMessage }], country_codes: [...countryCodes], risk_listing_filter: shopMatchListingFilter.value, stage_index: stageIndex, final_stage: finalStage } } }
function nextScheduleStage(taskId: number) { const task = taskSnapshots.value[taskId]?.task; const stages = task?.scheduleStages || []; const currentStageIndex = task?.currentStageIndex; if (typeof currentStageIndex !== 'number') return null; const stage = stages.find((item) => item.stageIndex === currentStageIndex); if (!stage?.scheduledAt) return null; return { stageIndex: currentStageIndex, scheduledAt: stage.scheduledAt, finalStage: currentStageIndex === stages.length - 1 } }
async function dispatchScheduledTask(taskId: number, item: ShopMatchHistoryItem) { const api = getPywebviewApi(); if (!api?.enqueue_json) throw new Error('当前客户端未提供 enqueue_json'); const stage = nextScheduleStage(taskId); const snapshot = taskSnapshots.value[taskId]; const countryCodes = snapshot?.task?.countryCodes || orderedCountryCodes.value; if (!stage) throw new Error(`任务 ${taskId} 缺少待执行阶段`); clearDispatchTimer(taskId); await activateShopMatchTask(taskId, stage.stageIndex); taskDetails.value = { ...taskDetails.value, [taskId]: 'RUNNING' }; if (snapshot?.task) taskSnapshots.value = { ...taskSnapshots.value, [taskId]: { ...snapshot, task: { ...snapshot.task, status: 'RUNNING', activeStageIndex: stage.stageIndex } } }; saveTaskSnapshotsToStorage(); saveTaskDetailsToStorage(); const payload = buildQueuePayload(taskId, item, countryCodes, stage.stageIndex, stage.finalStage); queuePayloadText.value = JSON.stringify(payload, null, 2); const result = await api.enqueue_json(payload); if (!result?.success) throw new Error(result?.error || `任务 ${taskId} 推送失败`); addPollingTask(taskId); queuePushResult.value = `任务 ${taskId} 已推送第 ${stage.stageIndex + 1}`; ensurePolling(true) }
function hasRunningTask() { return Object.values(taskDetails.value).some((status) => status === 'RUNNING') || Object.values(taskSnapshots.value).some((detail) => detail.task?.status === 'RUNNING') }
@@ -247,6 +257,7 @@ async function deleteTaskRecord(item: ShopMatchHistoryItem) {
} else if (resultId > 0) {
await deleteShopMatchHistory(resultId)
historyItems.value = historyItems.value.filter((row) => Number(row.resultId || 0) !== resultId)
removeMatchedRowsLocally([item])
} else {
throw new Error('缺少可删除的任务标识')
}

View File

@@ -5,22 +5,33 @@
<a href="/home" class="btn-home">返回首页</a>
</div>
<nav class="nav-tabs">
<div class="nav-tab-group">
<div v-for="group in navGroups" :key="group.label" class="nav-dropdown"
:class="{ active: group.items.some(item => item.key === active) }">
<button type="button" class="nav-dropdown-trigger">
<span>{{ group.label }}</span>
<span class="nav-dropdown-arrow"></span>
</button>
<div class="nav-dropdown-menu">
<a v-for="item in group.items" :key="item.key" :href="item.href" class="nav-dropdown-item"
:class="{ active: active === item.key }">
<nav class="nav-sections" aria-label="顶部功能导航">
<section
v-for="group in navGroups"
:key="group.label"
class="nav-section"
>
<div class="nav-section-title">{{ group.label }}</div>
<div class="nav-section-items">
<template v-for="item in group.items" :key="item.key">
<a
v-if="item.href"
:href="item.href"
class="nav-item"
:class="{ active: active === item.key }"
>
{{ item.label }}
</a>
</div>
<span
v-else
class="nav-item disabled"
:class="{ active: active === item.key }"
>
{{ item.label }}
</span>
</template>
</div>
</div>
</section>
</nav>
<div class="top-right"></div>
@@ -28,16 +39,33 @@
</template>
<script setup lang="ts">
type ActiveNavKey =
| 'brand'
| 'dedupe'
| 'convert'
| 'split'
| 'delete-brand'
| 'product-risk'
| 'shop-match'
type NavItem = {
key: string
label: string
href?: string
}
const props = defineProps<{
active: 'brand' | 'dedupe' | 'convert' | 'split' | 'delete-brand' | 'product-risk' | 'shop-match'
active: ActiveNavKey
}>()
const active = props.active
const navGroups = [
const navGroups: ReadonlyArray<{ label: string; items: ReadonlyArray<NavItem> }> = [
{
label: '前端工具',
items: [
{ key: 'collect', label: '采集数据' },
{ key: 'variant', label: '变体分析' },
{ key: 'brand', label: '品牌检测', href: '/brand' },
{ key: 'dedupe', label: '数据去重', href: '/new_web_source/dedupe.html' },
{ key: 'split', label: '数据拆分', href: '/new_web_source/split.html' },
@@ -47,22 +75,33 @@ const navGroups = [
{
label: '运营工具',
items: [
{ key: 'delete-brand', label: '删除指定ASIN和品牌', href: '/new_web_source/delete-brand.html' },
{ key: 'delete-brand', label: '删除ASIN', href: '/new_web_source/delete-brand.html' },
{ key: 'product-risk', label: '商品风险解决', href: '/new_web_source/product-risk.html' },
{ key: 'shop-match', label: '定时跟价匹配', href: '/new_web_source/shop-match.html' },
{ key: 'shop-match', label: '定时匹配', href: '/new_web_source/shop-match.html' },
{ key: 'pricing', label: '跟价' },
{ key: 'patrol-delete', label: '巡店删除' },
{ key: 'withdraw', label: '取款' },
{ key: 'shop-status', label: '店铺状态查询' },
],
},
] as const
{
label: '后勤工具',
items: [
{ key: 'purchase', label: '采购' },
{ key: 'erp', label: 'ERP' },
],
},
]
</script>
<style scoped>
.top-bar {
height: 56px;
min-height: 88px;
display: flex;
align-items: center;
align-items: flex-start;
justify-content: space-between;
gap: 24px;
padding: 0 20px;
gap: 20px;
padding: 10px 24px 12px;
background: #111;
border-bottom: 1px solid #2a2a2a;
}
@@ -72,12 +111,14 @@ const navGroups = [
align-items: center;
gap: 16px;
min-width: 0;
padding-top: 10px;
}
.app-name {
color: #fff;
font-size: 16px;
font-weight: 700;
font-size: 18px;
font-weight: 800;
letter-spacing: 0.02em;
white-space: nowrap;
}
@@ -92,129 +133,107 @@ const navGroups = [
color: #fff;
}
.nav-tabs {
.nav-sections {
flex: 1;
display: flex;
justify-content: center;
min-width: 0;
}
.nav-tab-group {
display: flex;
align-items: center;
gap: 12px;
flex-wrap: wrap;
align-items: stretch;
justify-content: center;
gap: 0;
}
.nav-dropdown {
.nav-section {
flex: 1;
min-width: 0;
padding: 0 18px;
position: relative;
}
.nav-dropdown-trigger {
.nav-section + .nav-section::before {
content: '';
position: absolute;
left: 0;
top: 14px;
bottom: 8px;
width: 1px;
background: rgba(255, 255, 255, 0.14);
}
.nav-section-title {
margin-bottom: 10px;
text-align: center;
color: #e8dfcf;
font-size: 16px;
font-weight: 800;
letter-spacing: 0.08em;
}
.nav-section-items {
display: flex;
flex-wrap: wrap;
gap: 8px;
justify-content: center;
padding: 10px 14px;
border-radius: 14px;
background: linear-gradient(180deg, rgba(83, 74, 67, 0.92) 0%, rgba(72, 65, 59, 0.96) 100%);
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.nav-item {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
min-width: 112px;
height: 38px;
padding: 0 16px;
border-radius: 10px;
border: 1px solid transparent;
color: #8d8d8d;
background: transparent;
font-size: 13px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s ease;
}
.nav-dropdown:hover .nav-dropdown-trigger,
.nav-dropdown.active .nav-dropdown-trigger {
color: #b9d6ff;
background: rgba(77, 126, 189, 0.14);
}
.nav-dropdown.active .nav-dropdown-trigger {
background: rgba(77, 126, 189, 0.24);
border-color: rgba(91, 148, 219, 0.35);
color: #6caeff;
}
.nav-dropdown-arrow {
font-size: 11px;
line-height: 1;
}
.nav-dropdown-menu {
position: absolute;
top: 100%;
left: 0;
min-width: 220px;
padding: 8px;
border: 1px solid #2a2a2a;
border-radius: 12px;
background: #171717;
box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
display: none;
z-index: 20;
}
.nav-dropdown:hover .nav-dropdown-menu {
display: flex;
flex-direction: column;
gap: 4px;
}
.nav-dropdown-item {
display: flex;
align-items: center;
min-height: 38px;
padding: 0 12px;
border-radius: 8px;
color: #b8b8b8;
font-size: 13px;
font-weight: 600;
min-height: 28px;
padding: 0 2px;
color: #f3eee4;
font-size: 14px;
font-weight: 700;
text-decoration: none;
transition: all 0.2s ease;
border-bottom: 2px solid transparent;
transition: color 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}
.nav-dropdown-item:hover {
color: #e8f2ff;
background: rgba(77, 126, 189, 0.14);
.nav-item:hover {
color: #fff;
border-bottom-color: rgba(255, 255, 255, 0.68);
}
.nav-dropdown-item.active {
color: #6caeff;
background: rgba(77, 126, 189, 0.24);
.nav-item.active {
color: #fff;
border-bottom-color: #8dc4ff;
}
.nav-item.disabled {
color: rgba(255, 255, 255, 0.78);
opacity: 0.82;
cursor: default;
}
.top-right {
width: 120px;
width: 60px;
flex-shrink: 0;
}
@media (max-width: 1100px) {
@media (max-width: 1200px) {
.top-bar {
height: auto;
align-items: flex-start;
flex-direction: column;
padding: 16px 20px;
align-items: stretch;
}
.nav-tabs {
width: 100%;
justify-content: flex-start;
.logo-area {
padding-top: 0;
}
.nav-tab-group {
width: 100%;
justify-content: flex-start;
.nav-sections {
flex-direction: column;
}
.nav-dropdown-menu {
left: 0;
right: auto;
.nav-section {
padding: 0;
}
.nav-section + .nav-section::before {
display: none;
}
.top-right {

View File

@@ -0,0 +1,7 @@
export const LISTING_FILTER_OPTIONS = [
{ value: 'SearchSuppressed', label: '在搜索结果中禁止显示' },
{ value: 'ApprovalRequired', label: '需要批准' },
{ value: 'Active', label: '在售' },
] as const
export type ListingFilterValue = (typeof LISTING_FILTER_OPTIONS)[number]['value']