Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 813bed66a3 | |||
| 445a7dfbd5 | |||
| 37919ae786 | |||
| 987b967237 | |||
| 8881f63839 | |||
| f93e7d95fc | |||
| bb4cf3cdd2 | |||
| 969f86c612 | |||
| a7682bffef |
@@ -7,11 +7,12 @@ import { computed, onMounted, onUnmounted, reactive, ref, watch } from 'vue'
|
|||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
import { userNotice } from '@/api/user-notice'
|
import { userNotice } from '@/api/user-notice'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import OldPagination from '@/components/OldPagination.vue'
|
|
||||||
import { useCompanyTabStore } from '@/stores/company-tab'
|
import { useCompanyTabStore } from '@/stores/company-tab'
|
||||||
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
import { formatDateTime, orderedPair } from '@/utils/datetime'
|
||||||
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
import { showAdminFeedback } from '@/components/admin-feedback-ui'
|
||||||
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
import LoadFailureBar from '@/components/LoadFailureBar.vue'
|
||||||
|
import TaskCenterTaskTable from './TaskCenterTaskTable.vue'
|
||||||
|
import TaskCenterVariantTable from './TaskCenterVariantTable.vue'
|
||||||
import {
|
import {
|
||||||
fetchTaskCenterOverview,
|
fetchTaskCenterOverview,
|
||||||
fetchTaskCenterShopOptions,
|
fetchTaskCenterShopOptions,
|
||||||
@@ -30,19 +31,14 @@ import {
|
|||||||
VARIANT_STATUS_OPTIONS,
|
VARIANT_STATUS_OPTIONS,
|
||||||
buildTaskQuery,
|
buildTaskQuery,
|
||||||
buildVariantQuery,
|
buildVariantQuery,
|
||||||
countryLabel,
|
|
||||||
createTaskFilter,
|
createTaskFilter,
|
||||||
createVariantFilter,
|
createVariantFilter,
|
||||||
deviceDisplayName,
|
deviceDisplayName,
|
||||||
progressPercent,
|
|
||||||
progressText,
|
progressText,
|
||||||
shopDisplayName,
|
shopDisplayName,
|
||||||
tabCount,
|
tabCount,
|
||||||
taskStatusLabel,
|
taskStatusLabel,
|
||||||
taskStatusType,
|
taskStatusType,
|
||||||
variantAccountText,
|
|
||||||
variantStatusLabel,
|
|
||||||
variantStatusType,
|
|
||||||
type TaskCenterTaskFilter,
|
type TaskCenterTaskFilter,
|
||||||
type TaskCenterVariantFilter,
|
type TaskCenterVariantFilter,
|
||||||
} from './task-center-model'
|
} from './task-center-model'
|
||||||
@@ -216,6 +212,10 @@ function resetFilter() {
|
|||||||
void loadTasks()
|
void loadTasks()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function retryTasks() {
|
||||||
|
void loadTasks()
|
||||||
|
}
|
||||||
|
|
||||||
function changeTaskPage(next: number) {
|
function changeTaskPage(next: number) {
|
||||||
if (next < 1 || next > taskTotalPages.value) return
|
if (next < 1 || next > taskTotalPages.value) return
|
||||||
taskPage.value = next
|
taskPage.value = next
|
||||||
@@ -423,78 +423,16 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<LoadFailureBar v-if="tasksFailure" :message="tasksFailure" @retry="loadTasks" />
|
<LoadFailureBar v-if="tasksFailure" :message="tasksFailure" @retry="retryTasks" />
|
||||||
<div class="table-scroll">
|
<TaskCenterTaskTable
|
||||||
<table>
|
:rows="tasks"
|
||||||
<thead>
|
:loading="tasksLoading"
|
||||||
<tr>
|
|
||||||
<th style="width: 120px">账号</th>
|
|
||||||
<th style="width: 160px">店铺</th>
|
|
||||||
<th style="width: 90px">国家</th>
|
|
||||||
<th style="width: 120px">业务</th>
|
|
||||||
<th style="width: 120px">状态</th>
|
|
||||||
<th style="width: 170px">任务ID</th>
|
|
||||||
<th style="width: 165px">开始时间</th>
|
|
||||||
<th style="width: 165px">最近上报</th>
|
|
||||||
<th style="width: 165px">结束时间</th>
|
|
||||||
<th style="width: 190px">进度</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<template v-if="tasks.length">
|
|
||||||
<tr v-for="row in tasks" :key="row.taskNo">
|
|
||||||
<td>
|
|
||||||
<span class="strong">{{ accountOf(row) }}</span>
|
|
||||||
</td>
|
|
||||||
<td>{{ shopDisplayName(row.shopName, row.shopCount) }}</td>
|
|
||||||
<td>{{ countryLabel(row.country) }}</td>
|
|
||||||
<td>{{ row.moduleLabel || row.moduleType }}</td>
|
|
||||||
<td>
|
|
||||||
<span class="st-pill" :class="`is-${taskStatusType(row.status)}`">{{ taskStatusLabel(row.status) }}</span>
|
|
||||||
<span v-if="row.stuck" class="badge warn">疑似卡住</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<button class="cell-link mono" type="button" @click="openDetail(row)">{{ row.id }}</button>
|
|
||||||
</td>
|
|
||||||
<td>{{ formatDateTime(row.createdAt) }}</td>
|
|
||||||
<td>
|
|
||||||
<span :class="{ 'is-warn-text': row.stuck }">
|
|
||||||
{{ row.lastReportAt ? formatDateTime(row.lastReportAt) : '—' }}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>{{ row.finishedAt ? formatDateTime(row.finishedAt) : '—' }}</td>
|
|
||||||
<td>
|
|
||||||
<template v-if="taskStatusType(row.status) === 'failed'">
|
|
||||||
<span v-if="row.progressFailed > 0" class="badge danger">失败 {{ row.progressFailed }}</span>
|
|
||||||
<span v-else>—</span>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<div class="progress-line">
|
|
||||||
<span>{{ progressText(row) }}</span>
|
|
||||||
<span v-if="row.progressFailed > 0" class="badge danger">失败 {{ row.progressFailed }}</span>
|
|
||||||
</div>
|
|
||||||
<div class="p-track" v-if="row.progressTotal > 0">
|
|
||||||
<div class="p-fill" :style="{ width: progressPercent(row) + '%' }"></div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</template>
|
|
||||||
<tr v-else-if="tasksLoading">
|
|
||||||
<td colspan="10" class="empty-tip">加载中...</td>
|
|
||||||
</tr>
|
|
||||||
<tr v-else>
|
|
||||||
<td colspan="10" class="empty-tip">暂无符合条件的任务</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<OldPagination
|
|
||||||
:total="taskTotal"
|
:total="taskTotal"
|
||||||
:page="taskPage"
|
:page="taskPage"
|
||||||
:page-size="taskPageSize"
|
:page-size="taskPageSize"
|
||||||
@change="changeTaskPage"
|
@page="changeTaskPage"
|
||||||
@size-change="changeTaskSize"
|
@size="changeTaskSize"
|
||||||
|
@open="openDetail"
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
@@ -522,55 +460,14 @@ onUnmounted(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="table-scroll">
|
<TaskCenterVariantTable
|
||||||
<table>
|
:rows="variantRows"
|
||||||
<thead>
|
:loading="variantLoading"
|
||||||
<tr>
|
|
||||||
<th style="width: 150px">账号</th>
|
|
||||||
<th style="width: 200px">任务号</th>
|
|
||||||
<th style="width: 110px">状态</th>
|
|
||||||
<th style="width: 165px">开始时间</th>
|
|
||||||
<th style="width: 165px">更新时间</th>
|
|
||||||
<th>结果信息</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<template v-if="variantRows.length">
|
|
||||||
<tr v-for="row in variantRows" :key="row.taskId">
|
|
||||||
<td>
|
|
||||||
<span class="strong">{{ variantAccountText(row) }}</span>
|
|
||||||
<span v-if="!row.username && row.uid" class="sub" :title="row.uid">{{ row.uid }}</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span class="mono">{{ row.taskId }}</span>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<span class="st-pill" :class="`is-${variantStatusType(row.status)}`">
|
|
||||||
{{ row.statusLabel || variantStatusLabel(row.status) }}
|
|
||||||
</span>
|
|
||||||
</td>
|
|
||||||
<td>{{ formatDateTime(row.createTime) }}</td>
|
|
||||||
<td>{{ formatDateTime(row.updateTime) }}</td>
|
|
||||||
<td>
|
|
||||||
<span class="res-mes" :title="row.resMes || ''">{{ row.resMes || '—' }}</span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</template>
|
|
||||||
<tr v-else-if="variantLoading">
|
|
||||||
<td colspan="6" class="empty-tip">加载中...</td>
|
|
||||||
</tr>
|
|
||||||
<tr v-else>
|
|
||||||
<td colspan="6" class="empty-tip">暂无变体采集任务</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<OldPagination
|
|
||||||
:total="variantTotal ?? 0"
|
:total="variantTotal ?? 0"
|
||||||
:page="variantPage"
|
:page="variantPage"
|
||||||
:page-size="variantPageSize"
|
:page-size="variantPageSize"
|
||||||
@change="changeVariantPage"
|
@page="changeVariantPage"
|
||||||
@size-change="changeVariantSize"
|
@size="changeVariantSize"
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
@@ -763,10 +660,6 @@ h3 {
|
|||||||
color: #8598ab;
|
color: #8598ab;
|
||||||
font-size: 12.5px;
|
font-size: 12.5px;
|
||||||
}
|
}
|
||||||
.is-warn-text {
|
|
||||||
color: #b3803a;
|
|
||||||
font-weight: 650;
|
|
||||||
}
|
|
||||||
.shop-filter {
|
.shop-filter {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
@@ -854,60 +747,6 @@ h3 {
|
|||||||
border-color: #95b1cb;
|
border-color: #95b1cb;
|
||||||
color: #2f5d8b;
|
color: #2f5d8b;
|
||||||
}
|
}
|
||||||
.table-scroll {
|
|
||||||
width: 100%;
|
|
||||||
overflow-x: auto;
|
|
||||||
}
|
|
||||||
table {
|
|
||||||
width: 100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
th {
|
|
||||||
padding: 10px 12px;
|
|
||||||
text-align: left;
|
|
||||||
color: #5b6f83;
|
|
||||||
font-weight: 650;
|
|
||||||
font-size: 12.5px;
|
|
||||||
border-bottom: 1px solid #dbe6f0;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
td {
|
|
||||||
padding: 10px 12px;
|
|
||||||
border-bottom: 1px solid #eaf1f7;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
.strong {
|
|
||||||
display: block;
|
|
||||||
font-weight: 600;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
.sub {
|
|
||||||
display: block;
|
|
||||||
color: #8598ab;
|
|
||||||
font-size: 11.5px;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
.mono {
|
|
||||||
font-family: Consolas, 'Courier New', monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
/* 任务 ID 单元格:「操作」列删除后,它是详情抽屉唯一的入口。 */
|
|
||||||
.cell-link {
|
|
||||||
padding: 0;
|
|
||||||
border: none;
|
|
||||||
background: none;
|
|
||||||
color: #2f5d8b;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
.cell-link:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
.res-mes {
|
|
||||||
display: block;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
.st-pill {
|
.st-pill {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -959,24 +798,6 @@ td {
|
|||||||
background: #f8ebeb;
|
background: #f8ebeb;
|
||||||
color: #91474f;
|
color: #91474f;
|
||||||
}
|
}
|
||||||
.progress-line {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
margin-bottom: 5px;
|
|
||||||
}
|
|
||||||
.p-track {
|
|
||||||
height: 6px;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: #eaf1f7;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.p-fill {
|
|
||||||
height: 100%;
|
|
||||||
border-radius: 999px;
|
|
||||||
background: linear-gradient(90deg, #6f97bd, #4f78a5);
|
|
||||||
}
|
|
||||||
.empty-tip {
|
.empty-tip {
|
||||||
padding: 30px 24px;
|
padding: 30px 24px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|||||||
@@ -0,0 +1,223 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
|
import { formatDateTime } from '@/utils/datetime'
|
||||||
|
import type { TaskCenterTaskRow } from '@/api/task-center'
|
||||||
|
import {
|
||||||
|
countryLabel,
|
||||||
|
progressPercent,
|
||||||
|
progressText,
|
||||||
|
shopDisplayName,
|
||||||
|
taskStatusLabel,
|
||||||
|
taskStatusType,
|
||||||
|
} from './task-center-model'
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
rows: TaskCenterTaskRow[]
|
||||||
|
loading: boolean
|
||||||
|
total: number
|
||||||
|
page: number
|
||||||
|
pageSize: number
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
page: [number]
|
||||||
|
size: [number]
|
||||||
|
open: [TaskCenterTaskRow]
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="table-scroll">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 120px">账号</th>
|
||||||
|
<th style="width: 160px">店铺</th>
|
||||||
|
<th style="width: 90px">国家</th>
|
||||||
|
<th style="width: 120px">业务</th>
|
||||||
|
<th style="width: 120px">状态</th>
|
||||||
|
<th style="width: 170px">任务ID</th>
|
||||||
|
<th style="width: 165px">开始时间</th>
|
||||||
|
<th style="width: 165px">最近上报</th>
|
||||||
|
<th style="width: 165px">结束时间</th>
|
||||||
|
<th style="width: 190px">进度</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<template v-if="rows.length">
|
||||||
|
<tr v-for="row in rows" :key="row.taskNo">
|
||||||
|
<td>
|
||||||
|
<span class="strong">{{ row.username || (row.userId != null ? `UID ${row.userId}` : '—') }}</span>
|
||||||
|
</td>
|
||||||
|
<td>{{ shopDisplayName(row.shopName, row.shopCount) }}</td>
|
||||||
|
<td>{{ countryLabel(row.country) }}</td>
|
||||||
|
<td>{{ row.moduleLabel || row.moduleType }}</td>
|
||||||
|
<td>
|
||||||
|
<span class="st-pill" :class="`is-${taskStatusType(row.status)}`">{{ taskStatusLabel(row.status) }}</span>
|
||||||
|
<span v-if="row.stuck" class="badge warn">疑似卡住</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button class="cell-link mono" type="button" @click="emit('open', row)">{{ row.id }}</button>
|
||||||
|
</td>
|
||||||
|
<td>{{ formatDateTime(row.createdAt) }}</td>
|
||||||
|
<td>
|
||||||
|
<span :class="{ 'is-warn-text': row.stuck }">
|
||||||
|
{{ row.lastReportAt ? formatDateTime(row.lastReportAt) : '—' }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>{{ row.finishedAt ? formatDateTime(row.finishedAt) : '—' }}</td>
|
||||||
|
<td>
|
||||||
|
<template v-if="taskStatusType(row.status) === 'failed'">
|
||||||
|
<span v-if="row.progressFailed > 0" class="badge danger">失败 {{ row.progressFailed }}</span>
|
||||||
|
<span v-else>—</span>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<div class="progress-line">
|
||||||
|
<span>{{ progressText(row) }}</span>
|
||||||
|
<span v-if="row.progressFailed > 0" class="badge danger">失败 {{ row.progressFailed }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="p-track" v-if="row.progressTotal > 0">
|
||||||
|
<div class="p-fill" :style="{ width: progressPercent(row) + '%' }"></div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
|
<tr v-else-if="loading">
|
||||||
|
<td colspan="10" class="empty-tip">加载中...</td>
|
||||||
|
</tr>
|
||||||
|
<tr v-else>
|
||||||
|
<td colspan="10" class="empty-tip">暂无符合条件的任务</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<OldPagination
|
||||||
|
:total="total"
|
||||||
|
:page="page"
|
||||||
|
:page-size="pageSize"
|
||||||
|
@change="emit('page', $event)"
|
||||||
|
@size-change="emit('size', $event)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.table-scroll {
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
padding: 10px 12px;
|
||||||
|
text-align: left;
|
||||||
|
color: #5b6f83;
|
||||||
|
font-weight: 650;
|
||||||
|
font-size: 12.5px;
|
||||||
|
border-bottom: 1px solid #dbe6f0;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-bottom: 1px solid #eaf1f7;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
.strong {
|
||||||
|
display: block;
|
||||||
|
font-weight: 600;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
.mono {
|
||||||
|
font-family: Consolas, 'Courier New', monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
.cell-link {
|
||||||
|
padding: 0;
|
||||||
|
border: none;
|
||||||
|
background: none;
|
||||||
|
color: #2f5d8b;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.cell-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.is-warn-text {
|
||||||
|
color: #b3803a;
|
||||||
|
font-weight: 650;
|
||||||
|
}
|
||||||
|
.st-pill {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 2px 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.7;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.st-pill.is-success {
|
||||||
|
color: #3d7158;
|
||||||
|
background: #e8f2eb;
|
||||||
|
border-color: #bdd7c5;
|
||||||
|
}
|
||||||
|
.st-pill.is-failed {
|
||||||
|
color: #91474f;
|
||||||
|
background: #f8ebeb;
|
||||||
|
border-color: #e4c2c5;
|
||||||
|
}
|
||||||
|
.st-pill.is-pending {
|
||||||
|
color: #8a6d3b;
|
||||||
|
background: #fbf4ea;
|
||||||
|
border-color: #e7d3ae;
|
||||||
|
}
|
||||||
|
.st-pill.is-running {
|
||||||
|
color: #37618f;
|
||||||
|
background: #e8f1fb;
|
||||||
|
border-color: #c3d8ef;
|
||||||
|
}
|
||||||
|
.badge {
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 6px;
|
||||||
|
padding: 1px 7px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.badge.danger {
|
||||||
|
background: #f8ebeb;
|
||||||
|
color: #91474f;
|
||||||
|
}
|
||||||
|
.badge.warn {
|
||||||
|
background: #fbf4ea;
|
||||||
|
color: #8a6d3b;
|
||||||
|
}
|
||||||
|
.progress-line {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
.p-track {
|
||||||
|
height: 6px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #eaf1f7;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.p-fill {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: linear-gradient(90deg, #6f97bd, #4f78a5);
|
||||||
|
}
|
||||||
|
.empty-tip {
|
||||||
|
padding: 30px 24px;
|
||||||
|
text-align: center;
|
||||||
|
color: #8293a5;
|
||||||
|
font-size: 13.5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import OldPagination from '@/components/OldPagination.vue'
|
||||||
|
import { formatDateTime } from '@/utils/datetime'
|
||||||
|
import type { TaskCenterVariantTaskRow } from '@/api/task-center'
|
||||||
|
import {
|
||||||
|
variantAccountText,
|
||||||
|
variantStatusLabel,
|
||||||
|
variantStatusType,
|
||||||
|
} from './task-center-model'
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
rows: TaskCenterVariantTaskRow[]
|
||||||
|
loading: boolean
|
||||||
|
total: number
|
||||||
|
page: number
|
||||||
|
pageSize: number
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
page: [number]
|
||||||
|
size: [number]
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="table-scroll">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 150px">账号</th>
|
||||||
|
<th style="width: 200px">任务号</th>
|
||||||
|
<th style="width: 110px">状态</th>
|
||||||
|
<th style="width: 165px">开始时间</th>
|
||||||
|
<th style="width: 165px">更新时间</th>
|
||||||
|
<th>结果信息</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<template v-if="rows.length">
|
||||||
|
<tr v-for="row in rows" :key="row.taskId">
|
||||||
|
<td>
|
||||||
|
<span class="strong">{{ variantAccountText(row) }}</span>
|
||||||
|
<span v-if="!row.username && row.uid" class="sub" :title="row.uid">{{ row.uid }}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="mono">{{ row.taskId }}</span>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<span class="st-pill" :class="`is-${variantStatusType(row.status)}`">
|
||||||
|
{{ row.statusLabel || variantStatusLabel(row.status) }}
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td>{{ formatDateTime(row.createTime) }}</td>
|
||||||
|
<td>{{ formatDateTime(row.updateTime) }}</td>
|
||||||
|
<td>
|
||||||
|
<span class="res-mes" :title="row.resMes || ''">{{ row.resMes || '—' }}</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</template>
|
||||||
|
<tr v-else-if="loading">
|
||||||
|
<td colspan="6" class="empty-tip">加载中...</td>
|
||||||
|
</tr>
|
||||||
|
<tr v-else>
|
||||||
|
<td colspan="6" class="empty-tip">暂无变体采集任务</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<OldPagination
|
||||||
|
:total="total"
|
||||||
|
:page="page"
|
||||||
|
:page-size="pageSize"
|
||||||
|
@change="emit('page', $event)"
|
||||||
|
@size-change="emit('size', $event)"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.table-scroll {
|
||||||
|
width: 100%;
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
padding: 10px 12px;
|
||||||
|
text-align: left;
|
||||||
|
color: #5b6f83;
|
||||||
|
font-weight: 650;
|
||||||
|
font-size: 12.5px;
|
||||||
|
border-bottom: 1px solid #dbe6f0;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
padding: 10px 12px;
|
||||||
|
border-bottom: 1px solid #eaf1f7;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
.strong {
|
||||||
|
display: block;
|
||||||
|
font-weight: 600;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
.sub {
|
||||||
|
display: block;
|
||||||
|
color: #8598ab;
|
||||||
|
font-size: 11.5px;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
.mono {
|
||||||
|
font-family: Consolas, 'Courier New', monospace;
|
||||||
|
font-size: 12px;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
.res-mes {
|
||||||
|
display: block;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
.st-pill {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 2px 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.7;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.st-pill.is-success {
|
||||||
|
color: #3d7158;
|
||||||
|
background: #e8f2eb;
|
||||||
|
border-color: #bdd7c5;
|
||||||
|
}
|
||||||
|
.st-pill.is-failed {
|
||||||
|
color: #91474f;
|
||||||
|
background: #f8ebeb;
|
||||||
|
border-color: #e4c2c5;
|
||||||
|
}
|
||||||
|
.st-pill.is-pending {
|
||||||
|
color: #8a6d3b;
|
||||||
|
background: #fbf4ea;
|
||||||
|
border-color: #e7d3ae;
|
||||||
|
}
|
||||||
|
.st-pill.is-running {
|
||||||
|
color: #37618f;
|
||||||
|
background: #e8f1fb;
|
||||||
|
border-color: #c3d8ef;
|
||||||
|
}
|
||||||
|
.empty-tip {
|
||||||
|
padding: 30px 24px;
|
||||||
|
text-align: center;
|
||||||
|
color: #8293a5;
|
||||||
|
font-size: 13.5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -28,6 +28,8 @@ import {
|
|||||||
// 客户端任务管理看板(后台):路由注册 / guides 对齐 / 接口层 / 纯逻辑映射。
|
// 客户端任务管理看板(后台):路由注册 / guides 对齐 / 接口层 / 纯逻辑映射。
|
||||||
|
|
||||||
const PAGE = 'src/pages/task-center/TaskCenterBoardPage.vue'
|
const PAGE = 'src/pages/task-center/TaskCenterBoardPage.vue'
|
||||||
|
const TASK_TABLE = 'src/pages/task-center/TaskCenterTaskTable.vue'
|
||||||
|
const VARIANT_TABLE = 'src/pages/task-center/TaskCenterVariantTable.vue'
|
||||||
const API = 'src/api/task-center.ts'
|
const API = 'src/api/task-center.ts'
|
||||||
|
|
||||||
test('task_center_route_registered_with_menu_key', () => {
|
test('task_center_route_registered_with_menu_key', () => {
|
||||||
@@ -222,8 +224,8 @@ test('task_center_collect_data_progress_wording_matches_the_client', () => {
|
|||||||
* 留一条 0% 空进度轨会被读成「进度 0%」,和「这里没有进度可看」是两件事。
|
* 留一条 0% 空进度轨会被读成「进度 0%」,和「这里没有进度可看」是两件事。
|
||||||
*/
|
*/
|
||||||
test('task_center_progress_bar_is_dropped_when_there_is_no_progress', () => {
|
test('task_center_progress_bar_is_dropped_when_there_is_no_progress', () => {
|
||||||
const page = readSource(PAGE)
|
const table = readSource(TASK_TABLE)
|
||||||
assert.match(page, /<div class="p-track" v-if="row\.progressTotal > 0">/, '无进度时不画进度轨')
|
assert.match(table, /<div class="p-track" v-if="row\.progressTotal > 0">/, '无进度时不画进度轨')
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -232,11 +234,11 @@ test('task_center_progress_bar_is_dropped_when_there_is_no_progress', () => {
|
|||||||
* 失败行(含详情抽屉)只给失败徽标,不给进度条也不说「已完成」。
|
* 失败行(含详情抽屉)只给失败徽标,不给进度条也不说「已完成」。
|
||||||
*/
|
*/
|
||||||
test('task_center_failed_rows_never_render_a_progress_bar', () => {
|
test('task_center_failed_rows_never_render_a_progress_bar', () => {
|
||||||
const page = readSource(PAGE)
|
const sources = { row: readSource(TASK_TABLE), detail: readSource(PAGE) }
|
||||||
for (const scope of ['row', 'detail']) {
|
for (const scope of ['row', 'detail']) {
|
||||||
const branch = new RegExp(
|
const branch = new RegExp(
|
||||||
`<template v-if="taskStatusType\\(${scope}\\.status\\) === 'failed'">[\\s\\S]{0,400}?</template>`,
|
`<template v-if="taskStatusType\\(${scope}\\.status\\) === 'failed'">[\\s\\S]{0,400}?</template>`,
|
||||||
).exec(page)
|
).exec(sources[scope as keyof typeof sources])
|
||||||
assert.ok(branch, `${scope} 的失败分支存在`)
|
assert.ok(branch, `${scope} 的失败分支存在`)
|
||||||
assert.equal(branch[0].includes('p-track'), false, '失败分支不画进度轨')
|
assert.equal(branch[0].includes('p-track'), false, '失败分支不画进度轨')
|
||||||
assert.equal(branch[0].includes('progressText'), false, '失败分支不说「已完成 X / 总 Y」')
|
assert.equal(branch[0].includes('progressText'), false, '失败分支不说「已完成 X / 总 Y」')
|
||||||
@@ -287,12 +289,12 @@ test('task_center_filter_reset_clears_every_field', () => {
|
|||||||
|
|
||||||
test('task_center_page_handles_empty_and_error_states', () => {
|
test('task_center_page_handles_empty_and_error_states', () => {
|
||||||
const page = readSource(PAGE)
|
const page = readSource(PAGE)
|
||||||
assert.match(page, /暂无符合条件的任务/, '任务空态')
|
assert.match(readSource(TASK_TABLE), /暂无符合条件的任务/, '任务空态')
|
||||||
assert.match(page, /暂无变体采集任务/, '变体空态:四态口径下不再限定「在跑」')
|
assert.match(readSource(VARIANT_TABLE), /暂无变体采集任务/, '变体空态:四态口径下不再限定「在跑」')
|
||||||
assert.match(page, /showAdminFeedback\([^\n]*, 'error'\)/, '接口失败提示走统一出口')
|
assert.match(page, /showAdminFeedback\([^\n]*, 'error'\)/, '接口失败提示走统一出口')
|
||||||
assert.match(page, /resetFilter/, '筛选重置接线')
|
assert.match(page, /resetFilter/, '筛选重置接线')
|
||||||
assert.match(page, /@size-change="changeTaskSize"/, '分页每页条数切换')
|
assert.match(page, /@size="changeTaskSize"/, '分页每页条数切换')
|
||||||
assert.match(page, /@size-change="changeVariantSize"/, '变体分页每页条数切换')
|
assert.match(page, /@size="changeVariantSize"/, '变体分页每页条数切换')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('task_center_has_no_shop_panel_anymore', () => {
|
test('task_center_has_no_shop_panel_anymore', () => {
|
||||||
@@ -303,7 +305,7 @@ test('task_center_has_no_shop_panel_anymore', () => {
|
|||||||
assert.equal(readSource(API).includes('/api/admin/task-center/shops'), false, '接口层不留 /shops')
|
assert.equal(readSource(API).includes('/api/admin/task-center/shops'), false, '接口层不留 /shops')
|
||||||
assert.match(page, /fetchTaskCenterShopOptions/, '店铺筛选候选仍要取数')
|
assert.match(page, /fetchTaskCenterShopOptions/, '店铺筛选候选仍要取数')
|
||||||
assert.match(page, /v-for="shop in shopOptions"/, '下拉候选就是店铺库本身,不再并入面板出现的店铺')
|
assert.match(page, /v-for="shop in shopOptions"/, '下拉候选就是店铺库本身,不再并入面板出现的店铺')
|
||||||
assert.match(page, /最近上报/, '任务表仍带最近上报')
|
assert.match(readSource(TASK_TABLE), /最近上报/, '任务表仍带最近上报')
|
||||||
assert.equal(page.includes('device-strip'), false, '设备卡条已删除')
|
assert.equal(page.includes('device-strip'), false, '设备卡条已删除')
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -318,18 +320,20 @@ test('task_center_has_no_shop_panel_anymore', () => {
|
|||||||
*/
|
*/
|
||||||
test('task_center_task_list_columns_are_trimmed_to_the_data_that_exists', () => {
|
test('task_center_task_list_columns_are_trimmed_to_the_data_that_exists', () => {
|
||||||
const page = readSource(PAGE)
|
const page = readSource(PAGE)
|
||||||
|
const table = readSource(TASK_TABLE)
|
||||||
const style = page.slice(page.indexOf('<style scoped>'))
|
const style = page.slice(page.indexOf('<style scoped>'))
|
||||||
|
|
||||||
assert.match(page, /<th style="width: 170px">任务ID<\/th>/, '「当前处理」列改名任务ID')
|
assert.match(table, /<th style="width: 170px">任务ID<\/th>/, '「当前处理」列改名任务ID')
|
||||||
assert.equal(/<th[^>]*>当前处理<\/th>/.test(page), false, '列表不再有全「—」的当前处理列')
|
assert.equal(/<th[^>]*>当前处理<\/th>/.test(table), false, '列表不再有全「—」的当前处理列')
|
||||||
assert.match(page, /<td>\s*<button class="cell-link mono" type="button" @click="openDetail\(row\)">\{\{ row\.id \}\}<\/button>/, 'ID 单元格点开详情')
|
assert.match(table, /<td>\s*<button class="cell-link mono" type="button" @click="emit\('open', row\)">\{\{ row\.id \}\}<\/button>/, 'ID 单元格点开详情')
|
||||||
assert.match(page, /:key="row\.taskNo"/, ':key 仍是唯一任务号(biz 与 brand 两张表的自增 id 会撞)')
|
assert.match(table, /:key="row\.taskNo"/, ':key 仍是唯一任务号(biz 与 brand 两张表的自增 id 会撞)')
|
||||||
|
assert.match(page, /@open="openDetail"/, '页面把表格行点击接到详情抽屉')
|
||||||
|
|
||||||
assert.equal(/<span class="sub">\{\{ row\.taskNo \}\}<\/span>/.test(page), false, '账号下方不再重复任务号')
|
assert.equal(/<span class="sub">\{\{ row\.taskNo \}\}<\/span>/.test(table), false, '账号下方不再重复任务号')
|
||||||
assert.equal(/<th[^>]*>操作<\/th>/.test(page), false, '操作列已删')
|
assert.equal(/<th[^>]*>操作<\/th>/.test(table), false, '操作列已删')
|
||||||
assert.equal(page.includes('btn-sm'), false, '没有别的按钮后 btn-sm 样式一并撤掉')
|
assert.equal(table.includes('btn-sm'), false, '没有别的按钮后 btn-sm 样式一并撤掉')
|
||||||
assert.equal(page.match(/colspan="10"/g)?.length, 2, '加载中/空态两处 = 任务表 10 列(含国家)')
|
assert.equal(table.match(/colspan="10"/g)?.length, 2, '加载中/空态两处 = 任务表 10 列(含国家)')
|
||||||
assert.equal(/colspan="9"/.test(page), false, '加国家列后空态不该还写 9 列')
|
assert.equal(/colspan="9"/.test(table), false, '加国家列后空态不该还写 9 列')
|
||||||
|
|
||||||
assert.match(style, /\.shop-filter\s*\{[^}]*position: relative/, '店铺组是提示的定位父元素')
|
assert.match(style, /\.shop-filter\s*\{[^}]*position: relative/, '店铺组是提示的定位父元素')
|
||||||
assert.match(style, /\.filter-tip\s*\{[^}]*position: absolute/, '提示绝对定位,不再撑高该组把 label 顶上去')
|
assert.match(style, /\.filter-tip\s*\{[^}]*position: absolute/, '提示绝对定位,不再撑高该组把 label 顶上去')
|
||||||
@@ -343,9 +347,10 @@ test('task_center_task_list_columns_are_trimmed_to_the_data_that_exists', () =>
|
|||||||
|
|
||||||
test('task_center_country_column_is_display_only', () => {
|
test('task_center_country_column_is_display_only', () => {
|
||||||
const page = readSource(PAGE)
|
const page = readSource(PAGE)
|
||||||
|
const table = readSource(TASK_TABLE)
|
||||||
|
|
||||||
assert.match(page, /<th style="width: 90px">国家<\/th>/, '国家列在店铺与业务之间')
|
assert.match(table, /<th style="width: 90px">国家<\/th>/, '国家列在店铺与业务之间')
|
||||||
assert.match(page, /<td>\{\{ countryLabel\(row\.country\) \}\}<\/td>/,
|
assert.match(table, /<td>\{\{ countryLabel\(row\.country\) \}\}<\/td>/,
|
||||||
'国家码转中文展示(UK→英国),空值由 countryLabel 画「—」')
|
'国家码转中文展示(UK→英国),空值由 countryLabel 画「—」')
|
||||||
assert.equal(readSource(API).includes('country: string | null'), true, '接口类型带 country 且可为 null')
|
assert.equal(readSource(API).includes('country: string | null'), true, '接口类型带 country 且可为 null')
|
||||||
|
|
||||||
@@ -413,7 +418,17 @@ test('task_center_page_wires_tabs_filters_and_polling', () => {
|
|||||||
assert.match(page, /变体采集/, '页签二文案')
|
assert.match(page, /变体采集/, '页签二文案')
|
||||||
assert.match(page, /panel-box/, '复用全局 panel-box 样式')
|
assert.match(page, /panel-box/, '复用全局 panel-box 样式')
|
||||||
assert.match(page, /form-row/, '复用全局筛选行样式')
|
assert.match(page, /form-row/, '复用全局筛选行样式')
|
||||||
assert.match(page, /OldPagination/, '旧版分页组件')
|
// 2026-10-24 拆分:两个表格子组件各自持有分页器,页面负责传 total/page/pageSize 并接事件。
|
||||||
|
for (const table of [
|
||||||
|
'src/pages/task-center/TaskCenterTaskTable.vue',
|
||||||
|
'src/pages/task-center/TaskCenterVariantTable.vue',
|
||||||
|
]) {
|
||||||
|
const src = readSource(table)
|
||||||
|
assert.match(src, /OldPagination/, `${table} 用旧版分页组件`)
|
||||||
|
assert.match(src, /@size-change="emit\('size', \$event\)"/, `${table} 分页事件上抛`)
|
||||||
|
}
|
||||||
|
assert.match(page, /TaskCenterTaskTable/, '页面接入客户端任务表格')
|
||||||
|
assert.match(page, /TaskCenterVariantTable/, '页面接入变体采集表格')
|
||||||
assert.match(page, /formatDateTime/, '统一时间格式')
|
assert.match(page, /formatDateTime/, '统一时间格式')
|
||||||
assert.match(page, /el-drawer/, '任务详情抽屉')
|
assert.match(page, /el-drawer/, '任务详情抽屉')
|
||||||
assert.match(page, /疑似卡住/, 'stuck 徽标文案')
|
assert.match(page, /疑似卡住/, 'stuck 徽标文案')
|
||||||
@@ -422,7 +437,7 @@ test('task_center_page_wires_tabs_filters_and_polling', () => {
|
|||||||
assert.match(page, /document\.visibilityState/, '隐藏时跳过轮询')
|
assert.match(page, /document\.visibilityState/, '隐藏时跳过轮询')
|
||||||
assert.match(page, /POLL_INTERVAL_MS/, '30s 轮询常量')
|
assert.match(page, /POLL_INTERVAL_MS/, '30s 轮询常量')
|
||||||
assert.match(page, /clearInterval/, '卸载清理定时器')
|
assert.match(page, /clearInterval/, '卸载清理定时器')
|
||||||
assert.match(page, /resMes/, '变体表展示麦象 res_mes')
|
assert.match(readSource(VARIANT_TABLE), /resMes/, '变体表展示麦象 res_mes')
|
||||||
assert.equal(/shopName/.test(readSource(PAGE)), true)
|
assert.equal(/shopName/.test(readSource(PAGE)), true)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -433,8 +448,8 @@ test('task_center_page_wires_tabs_filters_and_polling', () => {
|
|||||||
* (task-center.ts 的类型保持如实),只是页面不渲染。
|
* (task-center.ts 的类型保持如实),只是页面不渲染。
|
||||||
*/
|
*/
|
||||||
test('task_center_variant_result_column_dumps_no_raw_task_data', () => {
|
test('task_center_variant_result_column_dumps_no_raw_task_data', () => {
|
||||||
const page = readSource(PAGE)
|
assert.doesNotMatch(readSource(VARIANT_TABLE), /taskData/, '变体表不再渲染 task_data 原始 JSON')
|
||||||
assert.doesNotMatch(page, /taskData/, '变体表不再渲染 task_data 原始 JSON')
|
assert.doesNotMatch(readSource(PAGE), /taskData/, '页面不把 task_data 透传给表格')
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ export default defineConfig({
|
|||||||
output: {
|
output: {
|
||||||
manualChunks: {
|
manualChunks: {
|
||||||
vue: ['vue', 'vue-router', 'pinia'],
|
vue: ['vue', 'vue-router', 'pinia'],
|
||||||
|
'element-plus': ['element-plus'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -19,7 +19,6 @@
|
|||||||
<java.version>21</java.version>
|
<java.version>21</java.version>
|
||||||
<knife4j.version>4.5.0</knife4j.version>
|
<knife4j.version>4.5.0</knife4j.version>
|
||||||
<mybatis-plus.version>3.5.7</mybatis-plus.version>
|
<mybatis-plus.version>3.5.7</mybatis-plus.version>
|
||||||
<easyexcel.version>4.0.3</easyexcel.version>
|
|
||||||
<hutool.version>5.8.36</hutool.version>
|
<hutool.version>5.8.36</hutool.version>
|
||||||
<rocketmq-spring.version>2.3.5</rocketmq-spring.version>
|
<rocketmq-spring.version>2.3.5</rocketmq-spring.version>
|
||||||
<minio.version>8.6.0</minio.version>
|
<minio.version>8.6.0</minio.version>
|
||||||
@@ -83,11 +82,6 @@
|
|||||||
<groupId>org.flywaydb</groupId>
|
<groupId>org.flywaydb</groupId>
|
||||||
<artifactId>flyway-mysql</artifactId>
|
<artifactId>flyway-mysql</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.alibaba</groupId>
|
|
||||||
<artifactId>easyexcel</artifactId>
|
|
||||||
<version>${easyexcel.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
|
|||||||
@@ -1,16 +1,43 @@
|
|||||||
package com.nanri.aiimage.common.excel;
|
package com.nanri.aiimage.common.excel;
|
||||||
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||||
import com.alibaba.excel.context.AnalysisContext;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
import com.alibaba.excel.event.AnalysisEventListener;
|
import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
|
||||||
|
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||||
|
import org.apache.poi.ss.usermodel.DataFormatter;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.ss.util.CellReference;
|
||||||
|
import org.apache.poi.util.XMLHelper;
|
||||||
|
import org.apache.poi.xssf.eventusermodel.XSSFReader;
|
||||||
|
import org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler;
|
||||||
|
import org.apache.poi.xssf.model.SharedStrings;
|
||||||
|
import org.apache.poi.xssf.model.StylesTable;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFComment;
|
||||||
|
import org.xml.sax.Attributes;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import org.xml.sax.XMLReader;
|
||||||
|
import org.xml.sax.helpers.XMLFilterImpl;
|
||||||
|
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.io.SequenceInputStream;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Excel 流式读取:xlsx 走 POI 事件模型(不把整表读成 DOM),xls 走 HSSF
|
||||||
|
* (BIFF8 单表上限 65,536 行,DOM 占用有界)。
|
||||||
|
*
|
||||||
|
* <p>历史上这里用 EasyExcel;它与 poi-ooxml 各带一套 POI 版本,收口到 POI 后
|
||||||
|
* 只保留一个 Excel 栈。对外契约不变:首 sheet / 全 sheet、表头与数据行回调、
|
||||||
|
* 行处理异常原样透传、解析异常统一收成 IOException。
|
||||||
|
*/
|
||||||
public final class ExcelStreamReader {
|
public final class ExcelStreamReader {
|
||||||
|
|
||||||
private ExcelStreamReader() {
|
private ExcelStreamReader() {
|
||||||
@@ -36,22 +63,147 @@ public final class ExcelStreamReader {
|
|||||||
runRead(inputStream, true, handler);
|
runRead(inputStream, true, handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void runRead(InputStream inputStream, boolean readAllSheets, SheetRowHandler handler) throws IOException {
|
private static void runRead(InputStream inputStream, boolean readAllSheets, SheetRowHandler handler)
|
||||||
StreamingListener listener = new StreamingListener(handler);
|
throws IOException {
|
||||||
try {
|
byte[] prefix = inputStream.readNBytes(8);
|
||||||
if (readAllSheets) {
|
InputStream replay = new SequenceInputStream(new ByteArrayInputStream(prefix), inputStream);
|
||||||
EasyExcel.read(inputStream, listener).headRowNumber(1).doReadAll();
|
if (isOoxml(prefix)) {
|
||||||
|
readOoxml(replay, readAllSheets, handler);
|
||||||
} else {
|
} else {
|
||||||
EasyExcel.read(inputStream, listener).sheet(0).headRowNumber(1).doRead();
|
readHssf(replay, readAllSheets, handler);
|
||||||
}
|
|
||||||
} catch (RuntimeException ex) {
|
|
||||||
// EasyExcel/POI 的解析异常是 RuntimeException,原样冒到接口层会变成 HTTP 500;
|
|
||||||
// 本工具的契约是 IOException,调用方已按 IOException 给用户回 400。
|
|
||||||
throw toContractException(listener.handlerFailure(), ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IOException toContractException(Exception handlerFailure, RuntimeException readFailure) throws IOException {
|
private static boolean isOoxml(byte[] prefix) {
|
||||||
|
// OOXML 是 zip(PK\x03\x04),xls 是 OLE2(D0 CF 11 E0 A1 B1 1A E1)
|
||||||
|
return prefix.length >= 4
|
||||||
|
&& prefix[0] == 'P' && prefix[1] == 'K' && prefix[2] == 3 && prefix[3] == 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void readOoxml(InputStream inputStream, boolean readAllSheets, SheetRowHandler handler)
|
||||||
|
throws IOException {
|
||||||
|
FailureRecorder recorder = new FailureRecorder();
|
||||||
|
try (OPCPackage pkg = OPCPackage.open(inputStream)) {
|
||||||
|
XSSFReader reader = new XSSFReader(pkg);
|
||||||
|
StylesTable styles = reader.getStylesTable();
|
||||||
|
SharedStrings sharedStrings = reader.getSharedStringsTable();
|
||||||
|
DataFormatter formatter = new DataFormatter();
|
||||||
|
Iterator<InputStream> sheets = reader.getSheetsData();
|
||||||
|
XSSFReader.SheetIterator sheetIterator = (XSSFReader.SheetIterator) sheets;
|
||||||
|
int sheetNo = 0;
|
||||||
|
while (sheetIterator.hasNext()) {
|
||||||
|
try (InputStream sheet = sheetIterator.next()) {
|
||||||
|
String sheetName = sheetIterator.getSheetName();
|
||||||
|
parseOoxmlSheet(sheet, sheetName, sheetNo, styles, sharedStrings, formatter, handler, recorder);
|
||||||
|
}
|
||||||
|
sheetNo++;
|
||||||
|
if (!readAllSheets) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (OpenXML4JException ex) {
|
||||||
|
throw toContractException(recorder.failure(), ex);
|
||||||
|
} catch (SAXException ex) {
|
||||||
|
if (ex.getCause() instanceof RuntimeException runtimeException) {
|
||||||
|
throw toContractException(recorder.failure(), runtimeException);
|
||||||
|
}
|
||||||
|
throw toContractException(recorder.failure(), ex);
|
||||||
|
} catch (RuntimeException ex) {
|
||||||
|
throw toContractException(recorder.failure(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void parseOoxmlSheet(InputStream sheet, String sheetName, int sheetNo,
|
||||||
|
StylesTable styles, SharedStrings sharedStrings,
|
||||||
|
DataFormatter formatter, SheetRowHandler handler,
|
||||||
|
FailureRecorder recorder) throws IOException, SAXException {
|
||||||
|
XMLReader parser;
|
||||||
|
try {
|
||||||
|
parser = XMLHelper.newXMLReader();
|
||||||
|
} catch (ParserConfigurationException ex) {
|
||||||
|
throw new IOException("Excel 解析器初始化失败:" + describe(ex), ex);
|
||||||
|
}
|
||||||
|
SheetCollector collector = new SheetCollector(sheetName, sheetNo, handler, recorder);
|
||||||
|
XSSFSheetXMLHandler sheetHandler =
|
||||||
|
new XSSFSheetXMLHandler(styles, sharedStrings, collector, formatter, false);
|
||||||
|
DimensionFilter filter = new DimensionFilter(parser, maxRows -> {
|
||||||
|
try {
|
||||||
|
handler.onSheetTotal(sheetName, sheetNo, maxRows);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw recorder.record(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
filter.setContentHandler(sheetHandler);
|
||||||
|
parser.setContentHandler(filter);
|
||||||
|
parser.parse(new InputSource(sheet));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void readHssf(InputStream inputStream, boolean readAllSheets, SheetRowHandler handler)
|
||||||
|
throws IOException {
|
||||||
|
FailureRecorder recorder = new FailureRecorder();
|
||||||
|
DataFormatter formatter = new DataFormatter();
|
||||||
|
try (HSSFWorkbook workbook = new HSSFWorkbook(inputStream)) {
|
||||||
|
int sheetCount = workbook.getNumberOfSheets();
|
||||||
|
for (int sheetNo = 0; sheetNo < sheetCount; sheetNo++) {
|
||||||
|
if (!readAllSheets && sheetNo > 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
HSSFSheet sheet = workbook.getSheetAt(sheetNo);
|
||||||
|
final String sheetName = sheet.getSheetName();
|
||||||
|
final int currentSheetNo = sheetNo;
|
||||||
|
final int lastRow = sheet.getLastRowNum();
|
||||||
|
callRecorder(recorder, () -> handler.onSheetTotal(sheetName, currentSheetNo, lastRow + 1));
|
||||||
|
final Map<Integer, String> header = rowToMap(sheet.getRow(0), formatter);
|
||||||
|
if (!header.isEmpty()) {
|
||||||
|
callRecorder(recorder, () -> handler.onHeader(sheetName, currentSheetNo, header));
|
||||||
|
}
|
||||||
|
for (int rowIndex = 1; rowIndex <= lastRow; rowIndex++) {
|
||||||
|
Row row = sheet.getRow(rowIndex);
|
||||||
|
if (row == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final Map<Integer, String> values = rowToMap(row, formatter);
|
||||||
|
if (values.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
final int finalRowIndex = rowIndex;
|
||||||
|
callRecorder(recorder,
|
||||||
|
() -> handler.onRow(sheetName, currentSheetNo, finalRowIndex, header, values));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (RuntimeException ex) {
|
||||||
|
throw toContractException(recorder.failure(), ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void callRecorder(FailureRecorder recorder, ThrowingRunnable action) {
|
||||||
|
try {
|
||||||
|
action.run();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
throw recorder.record(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<Integer, String> rowToMap(Row row, DataFormatter formatter) {
|
||||||
|
Map<Integer, String> values = new LinkedHashMap<>();
|
||||||
|
if (row == null) {
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
short first = row.getFirstCellNum();
|
||||||
|
short last = row.getLastCellNum();
|
||||||
|
if (first < 0 || last < 0) {
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
for (int column = first; column < last; column++) {
|
||||||
|
if (row.getCell(column) == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
values.put(column, formatter.formatCellValue(row.getCell(column)));
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IOException toContractException(Exception handlerFailure, Exception readFailure) throws IOException {
|
||||||
if (handlerFailure != null) {
|
if (handlerFailure != null) {
|
||||||
// 调用方自己抛的不算"文件坏了":运行时异常原样透传,保住 BusinessException 的 400 语义。
|
// 调用方自己抛的不算"文件坏了":运行时异常原样透传,保住 BusinessException 的 400 语义。
|
||||||
if (handlerFailure instanceof IOException ioException) {
|
if (handlerFailure instanceof IOException ioException) {
|
||||||
@@ -83,33 +235,26 @@ public final class ExcelStreamReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表头之后回调本次 sheet 的近似总行数(EasyExcel 基于 sheet 尺寸,可能为 null)。
|
* 表头之后回调本次 sheet 的近似总行数(POI 维度口径,含表头;维度缺失时为 null)。
|
||||||
* 流式解析无法在读完前得到精确行数,需要展示进度/做前置上限校验的调用方可用它近似。
|
* 流式解析无法在读完前得到精确行数,需要展示进度/做前置上限校验的调用方可用它近似。
|
||||||
*/
|
*/
|
||||||
default void onSheetTotal(String sheetName, Integer sheetNo, Integer approximateTotalRows) throws Exception {
|
default void onSheetTotal(String sheetName, Integer sheetNo, Integer approximateTotalRows) throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
void onRow(String sheetName, Integer sheetNo, int rowIndex, Map<Integer, String> headerMap, Map<Integer, String> rowMap) throws Exception;
|
void onRow(String sheetName, Integer sheetNo, int rowIndex, Map<Integer, String> headerMap,
|
||||||
|
Map<Integer, String> rowMap) throws Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class StreamingListener extends AnalysisEventListener<Map<Integer, String>> {
|
private interface ThrowingRunnable {
|
||||||
|
void run() throws Exception;
|
||||||
private final SheetRowHandler handler;
|
|
||||||
private Map<Integer, String> currentHeaderMap = Map.of();
|
|
||||||
private Exception handlerFailure;
|
|
||||||
|
|
||||||
private StreamingListener(SheetRowHandler handler) {
|
|
||||||
this.handler = handler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Exception handlerFailure() {
|
private static final class FailureRecorder {
|
||||||
return handlerFailure;
|
private Exception failure;
|
||||||
}
|
|
||||||
|
|
||||||
/** 记下调用方抛出的异常,好让 runRead 分得清「文件解析坏了」和「行处理被调用方拒了」。 */
|
private RuntimeException record(Exception ex) {
|
||||||
private RuntimeException recordHandlerFailure(Exception ex) {
|
if (failure == null) {
|
||||||
if (handlerFailure == null) {
|
failure = ex;
|
||||||
handlerFailure = ex;
|
|
||||||
}
|
}
|
||||||
if (ex instanceof RuntimeException runtimeException) {
|
if (ex instanceof RuntimeException runtimeException) {
|
||||||
return runtimeException;
|
return runtimeException;
|
||||||
@@ -117,59 +262,93 @@ public final class ExcelStreamReader {
|
|||||||
return new WrappedRuntimeException(ex);
|
return new WrappedRuntimeException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private Exception failure() {
|
||||||
public void invokeHeadMap(Map<Integer, String> headMap, AnalysisContext context) {
|
return failure;
|
||||||
Map<Integer, String> normalizedHeadMap = new LinkedHashMap<>();
|
|
||||||
for (Map.Entry<Integer, String> entry : headMap.entrySet()) {
|
|
||||||
normalizedHeadMap.put(entry.getKey(), entry.getValue());
|
|
||||||
}
|
}
|
||||||
currentHeaderMap = normalizedHeadMap;
|
}
|
||||||
try {
|
|
||||||
handler.onHeader(sheetName(context), sheetNo(context), currentHeaderMap);
|
private static final class SheetCollector implements XSSFSheetXMLHandler.SheetContentsHandler {
|
||||||
handler.onSheetTotal(sheetName(context), sheetNo(context), approximateTotalRows(context));
|
private final String sheetName;
|
||||||
} catch (Exception ex) {
|
private final int sheetNo;
|
||||||
throw recordHandlerFailure(ex);
|
private final SheetRowHandler handler;
|
||||||
|
private final FailureRecorder recorder;
|
||||||
|
private Map<Integer, String> header = Map.of();
|
||||||
|
private Map<Integer, String> row = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
private SheetCollector(String sheetName, int sheetNo, SheetRowHandler handler, FailureRecorder recorder) {
|
||||||
|
this.sheetName = sheetName;
|
||||||
|
this.sheetNo = sheetNo;
|
||||||
|
this.handler = handler;
|
||||||
|
this.recorder = recorder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startRow(int rowNum) {
|
||||||
|
row = new LinkedHashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void endRow(int rowNum) {
|
||||||
|
if (row.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (rowNum == 0) {
|
||||||
|
header = new LinkedHashMap<>(row);
|
||||||
|
callRecorder(recorder, () -> handler.onHeader(sheetName, sheetNo, header));
|
||||||
|
} else {
|
||||||
|
Map<Integer, String> values = new LinkedHashMap<>(row);
|
||||||
|
int rowIndex = rowNum;
|
||||||
|
callRecorder(recorder, () -> handler.onRow(sheetName, sheetNo, rowIndex, header, values));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invoke(Map<Integer, String> data, AnalysisContext context) {
|
public void cell(String cellReference, String formattedValue, XSSFComment comment) {
|
||||||
Map<Integer, String> normalizedRow = new LinkedHashMap<>();
|
if (cellReference == null) {
|
||||||
for (Map.Entry<Integer, String> entry : data.entrySet()) {
|
return;
|
||||||
normalizedRow.put(entry.getKey(), entry.getValue());
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
handler.onRow(
|
|
||||||
sheetName(context),
|
|
||||||
sheetNo(context),
|
|
||||||
context.readRowHolder().getRowIndex(),
|
|
||||||
currentHeaderMap,
|
|
||||||
normalizedRow
|
|
||||||
);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw recordHandlerFailure(ex);
|
|
||||||
}
|
}
|
||||||
|
int column = new CellReference(cellReference).getCol();
|
||||||
|
row.put(column, formattedValue == null ? "" : formattedValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
public void headerFooter(String text, boolean isHeader, String tagName) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer approximateTotalRows(AnalysisContext context) {
|
/** 在 sheetData 之前截获 dimension,给 onSheetTotal 一个近似总行数(含表头)。 */
|
||||||
try {
|
private static final class DimensionFilter extends XMLFilterImpl {
|
||||||
return context.readSheetHolder() == null ? null
|
private final java.util.function.IntConsumer onDimension;
|
||||||
: context.readSheetHolder().getApproximateTotalRowNumber();
|
private boolean captured;
|
||||||
} catch (Exception ex) {
|
|
||||||
|
private DimensionFilter(XMLReader parent, java.util.function.IntConsumer onDimension) {
|
||||||
|
super(parent);
|
||||||
|
this.onDimension = onDimension;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void startElement(String uri, String localName, String qName, Attributes attributes)
|
||||||
|
throws SAXException {
|
||||||
|
if (!captured && ("dimension".equals(localName) || "dimension".equals(qName))) {
|
||||||
|
captured = true;
|
||||||
|
Integer maxRows = maxRows(attributes.getValue("ref"));
|
||||||
|
if (maxRows != null) {
|
||||||
|
onDimension.accept(maxRows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.startElement(uri, localName, qName, attributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer maxRows(String ref) {
|
||||||
|
if (ref == null || ref.isBlank()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
String last = ref.contains(":") ? ref.substring(ref.indexOf(':') + 1) : ref;
|
||||||
|
try {
|
||||||
|
return new CellReference(last).getRow() + 1;
|
||||||
|
} catch (RuntimeException ex) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String sheetName(AnalysisContext context) {
|
|
||||||
return context.readSheetHolder() == null ? "" : context.readSheetHolder().getSheetName();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Integer sheetNo(AnalysisContext context) {
|
|
||||||
return context.readSheetHolder() == null ? null : context.readSheetHolder().getSheetNo();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -122,6 +122,14 @@ public class AuthService {
|
|||||||
loginUserMapper.update(null, new LambdaUpdateWrapper<LoginUserEntity>()
|
loginUserMapper.update(null, new LambdaUpdateWrapper<LoginUserEntity>()
|
||||||
.eq(LoginUserEntity::getId, user.getId())
|
.eq(LoginUserEntity::getId, user.getId())
|
||||||
.set(LoginUserEntity::getMachine, deviceId));
|
.set(LoginUserEntity::getMachine, deviceId));
|
||||||
|
} else if (DeviceSessionPolicy.isRevoked(user.getMachine())) {
|
||||||
|
// 开关关掉后登录不再写 machine,登出留下的吊销标记就没人清:此后每次登录都会先成功、
|
||||||
|
// 再被 requireUser 的 assertNotRevoked 判成「登录已过期」,账号永久锁死。
|
||||||
|
// 登录成功即视为新会话,清空标记(空=未绑定,放行语义);仍不写设备号。
|
||||||
|
log.warn("[auth] 登录清除登出吊销标记 userId={} username={}", user.getId(), user.getUsername());
|
||||||
|
loginUserMapper.update(null, new LambdaUpdateWrapper<LoginUserEntity>()
|
||||||
|
.eq(LoginUserEntity::getId, user.getId())
|
||||||
|
.set(LoginUserEntity::getMachine, ""));
|
||||||
}
|
}
|
||||||
log.info("[auth] login userId={} isAdmin={} device={}", user.getId(), isAdmin, deviceId);
|
log.info("[auth] login userId={} isAdmin={} device={}", user.getId(), isAdmin, deviceId);
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -153,7 +153,9 @@ public class BrandCheckClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BrandCheckResponse postCheck(String brand, String strategy, Long userId, String proxyUrl) {
|
private BrandCheckResponse postCheck(String brand, String strategy, Long userId, String proxyUrl) {
|
||||||
String normalizedBrand = normalize(brand);
|
// B5 #8:WIPO 查询词同样要剥 `Brand:` 前缀。此前这里只 trim(),
|
||||||
|
// 带前缀的词原样打到上游,现网 19,247 次 `undefined field Brand` 就是这么来的。
|
||||||
|
String normalizedBrand = com.nanri.aiimage.common.text.BrandLabel.strip(normalize(brand));
|
||||||
if (normalizedBrand.isBlank()) {
|
if (normalizedBrand.isBlank()) {
|
||||||
return BrandCheckResponse.empty();
|
return BrandCheckResponse.empty();
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -695,7 +695,8 @@ public class DedupeTotalDataService {
|
|||||||
progress.setStatus("failed");
|
progress.setStatus("failed");
|
||||||
progress.setErrorMessage(UserMessages.orFallback(e.getMessage(), "导入 Excel 失败"));
|
progress.setErrorMessage(UserMessages.orFallback(e.getMessage(), "导入 Excel 失败"));
|
||||||
// 此前该 catch 既不记日志也不带 cause,线上只有一句「导入 Excel 失败」,无栈无定位线索
|
// 此前该 catch 既不记日志也不带 cause,线上只有一句「导入 Excel 失败」,无栈无定位线索
|
||||||
log.error("[dedupe-total-data] 异步导入失败 filename={} userId={}", filename, uploaderUserId, e);
|
log.error("[dedupe-total-data] 异步导入失败 filename={} userId={} errorType={} msg={}",
|
||||||
|
filename, uploaderUserId, e.getClass().getSimpleName(), e.getMessage(), e);
|
||||||
} finally {
|
} finally {
|
||||||
deleteQuietly(tempFile);
|
deleteQuietly(tempFile);
|
||||||
importCompletedAtMap.put(importId, System.currentTimeMillis());
|
importCompletedAtMap.put(importId, System.currentTimeMillis());
|
||||||
@@ -795,8 +796,8 @@ public class DedupeTotalDataService {
|
|||||||
} catch (BusinessException e) {
|
} catch (BusinessException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("[dedupe-total-data] 导入 Excel 失败 filename={} processedRows={}",
|
log.error("[dedupe-total-data] 导入 Excel 失败 filename={} processedRows={} errorType={} msg={}",
|
||||||
filename, session.processedRows(), e);
|
filename, session.processedRows(), e.getClass().getSimpleName(), e.getMessage(), e);
|
||||||
throw new BusinessException("导入 Excel 失败", e);
|
throw new BusinessException("导入 Excel 失败", e);
|
||||||
}
|
}
|
||||||
return session.finish();
|
return session.finish();
|
||||||
|
|||||||
+8
@@ -3,7 +3,15 @@ package com.nanri.aiimage.modules.task.mapper;
|
|||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.nanri.aiimage.modules.task.model.entity.TaskFileJobEntity;
|
import com.nanri.aiimage.modules.task.model.entity.TaskFileJobEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TaskFileJobMapper extends BaseMapper<TaskFileJobEntity> {
|
public interface TaskFileJobMapper extends BaseMapper<TaskFileJobEntity> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 只读父任务状态:结果作业的 taskId 落在 12 个客户端模块共用的 {@code biz_file_task}。
|
||||||
|
* 品牌任务的 job 查不到行(返回 null),调用方按"非终态"处理,行为不变。
|
||||||
|
* 语句在 {@code mapper/TaskFileJobMapper.xml}(本仓约定:自定义 SQL 一律进 XML)。
|
||||||
|
*/
|
||||||
|
String selectFileTaskStatus(@Param("taskId") Long taskId);
|
||||||
}
|
}
|
||||||
|
|||||||
+15
@@ -324,6 +324,21 @@ public class TaskDistributedLockService {
|
|||||||
this.heldLock = heldLock;
|
this.heldLock = heldLock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止看门狗续期,但**不释放**锁:父任务已终态时,本节点不该再给这把锁续命;
|
||||||
|
* 仍由 {@link #close()} 那次带 token 的 RELEASE 收尾,避免把接管者的锁误删。
|
||||||
|
*/
|
||||||
|
public void stopRenewal(String reason) {
|
||||||
|
if (heldLock.closed.compareAndSet(false, true)) {
|
||||||
|
cancelRenewal(heldLock);
|
||||||
|
activeLocks.markRenewalLost(heldLock.lockName);
|
||||||
|
log.warn("[task-lock] 停止续期 lockName={} heldMs={} reason={}",
|
||||||
|
heldLock.lockName,
|
||||||
|
System.currentTimeMillis() - heldLock.acquiredAtMillis,
|
||||||
|
reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
if (closed) {
|
if (closed) {
|
||||||
|
|||||||
+32
@@ -221,6 +221,26 @@ public class TaskFileJobService {
|
|||||||
return claimCandidates(candidates);
|
return claimCandidates(candidates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父任务是否已终态。终态任务的作业不得再被领取、锁不得再续期(B28):
|
||||||
|
* 现网 FAILED 任务 32217/32220/32226/32229 的合批 job 仍在逐行申领,锁续到 86 分钟。
|
||||||
|
*/
|
||||||
|
public boolean isOwningTaskTerminal(Long taskId) {
|
||||||
|
if (taskId == null || taskId <= 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String status = taskFileJobMapper.selectFileTaskStatus(taskId);
|
||||||
|
return status != null && TaskStatuses.FileTask.TERMINAL.contains(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 终态父任务的 job 直接拉满重试并打终态回调:不执行、不再被下一轮扫到。 */
|
||||||
|
private void skipJobOfTerminalTask(TaskFileJobEntity job, String stage) {
|
||||||
|
String message = "父任务已终态,结果作业不再执行";
|
||||||
|
markFailedPermanent(job, message);
|
||||||
|
log.info("[task-file-job] skipped because parent task is terminal jobId={} taskId={} moduleType={} stage={}",
|
||||||
|
job.getId(), job.getTaskId(), job.getModuleType(), stage);
|
||||||
|
}
|
||||||
|
|
||||||
private List<TaskFileJobEntity> claimCandidates(List<TaskFileJobEntity> candidates) {
|
private List<TaskFileJobEntity> claimCandidates(List<TaskFileJobEntity> candidates) {
|
||||||
if (candidates == null || candidates.isEmpty()) {
|
if (candidates == null || candidates.isEmpty()) {
|
||||||
return List.of();
|
return List.of();
|
||||||
@@ -230,6 +250,10 @@ public class TaskFileJobService {
|
|||||||
if (candidate == null || candidate.getId() == null) {
|
if (candidate == null || candidate.getId() == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (isOwningTaskTerminal(candidate.getTaskId())) {
|
||||||
|
skipJobOfTerminalTask(candidate, "CLAIM");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (markRunning(candidate.getId())) {
|
if (markRunning(candidate.getId())) {
|
||||||
claimedIds.add(candidate.getId());
|
claimedIds.add(candidate.getId());
|
||||||
}
|
}
|
||||||
@@ -547,6 +571,14 @@ public class TaskFileJobService {
|
|||||||
|
|
||||||
/** Returns the persisted RUNNING row so queued execution can later fence itself with updatedAt. */
|
/** Returns the persisted RUNNING row so queued execution can later fence itself with updatedAt. */
|
||||||
public TaskFileJobEntity claimRunning(Long jobId) {
|
public TaskFileJobEntity claimRunning(Long jobId) {
|
||||||
|
if (jobId == null || jobId <= 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
TaskFileJobEntity existing = taskFileJobMapper.selectById(jobId);
|
||||||
|
if (existing != null && isOwningTaskTerminal(existing.getTaskId())) {
|
||||||
|
skipJobOfTerminalTask(existing, "CLAIM_RUNNING");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (!markRunning(jobId)) {
|
if (!markRunning(jobId)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
+29
@@ -65,6 +65,10 @@ public class TaskResultFileJobWorker {
|
|||||||
return thread;
|
return thread;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/** 本进程正在执行的 job → 它持有的任务锁;心跳发现父任务终态时用它停续期(B28)。 */
|
||||||
|
private final java.util.concurrent.ConcurrentHashMap<Long, TaskDistributedLockService.LockHandle> activeLockHandles =
|
||||||
|
new java.util.concurrent.ConcurrentHashMap<>();
|
||||||
|
|
||||||
@Scheduled(fixedDelayString = "${aiimage.result-file-job.local-worker-delay-ms:15000}")
|
@Scheduled(fixedDelayString = "${aiimage.result-file-job.local-worker-delay-ms:15000}")
|
||||||
public void runPendingJobs() {
|
public void runPendingJobs() {
|
||||||
if (!localWorkerEnabled) {
|
if (!localWorkerEnabled) {
|
||||||
@@ -197,6 +201,14 @@ public class TaskResultFileJobWorker {
|
|||||||
long interval = Math.max(1000L, heartbeatIntervalMillis);
|
long interval = Math.max(1000L, heartbeatIntervalMillis);
|
||||||
return jobHeartbeatExecutor.scheduleWithFixedDelay(() -> {
|
return jobHeartbeatExecutor.scheduleWithFixedDelay(() -> {
|
||||||
try {
|
try {
|
||||||
|
if (taskFileJobService.isOwningTaskTerminal(job.getTaskId())) {
|
||||||
|
TaskDistributedLockService.LockHandle handle = activeLockHandles.get(job.getId());
|
||||||
|
if (handle != null) {
|
||||||
|
handle.stopRenewal("parent-task-terminal");
|
||||||
|
log.info("[task-file-job] stopped lock renewal because parent task is terminal jobId={} taskId={} moduleType={} stage=TERMINAL_STOP_RENEW",
|
||||||
|
job.getId(), job.getTaskId(), job.getModuleType());
|
||||||
|
}
|
||||||
|
}
|
||||||
taskFileJobService.touchRunning(job.getId());
|
taskFileJobService.touchRunning(job.getId());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.warn("[task-file-job] heartbeat failed jobId={} taskId={} moduleType={} msg={} stage=HEARTBEAT",
|
log.warn("[task-file-job] heartbeat failed jobId={} taskId={} moduleType={} msg={} stage=HEARTBEAT",
|
||||||
@@ -206,6 +218,12 @@ public class TaskResultFileJobWorker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processClaimedWithHeartbeat(TaskFileJobEntity job, TaskFileJobEntity claim) {
|
private void processClaimedWithHeartbeat(TaskFileJobEntity job, TaskFileJobEntity claim) {
|
||||||
|
if (taskFileJobService.isOwningTaskTerminal(job.getTaskId())) {
|
||||||
|
taskFileJobService.markFailedPermanent(job, "父任务已终态,结果作业不再执行");
|
||||||
|
log.info("[task-file-job] skipped because parent task is terminal jobId={} taskId={} moduleType={} stage=TERMINAL_SKIP",
|
||||||
|
job.getId(), job.getTaskId(), job.getModuleType());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!taskFileJobService.activateRunningClaim(claim)) {
|
if (!taskFileJobService.activateRunningClaim(claim)) {
|
||||||
log.info("[task-file-job] queued claim expired before execution jobId={} taskId={} moduleType={} claimUpdatedAt={}",
|
log.info("[task-file-job] queued claim expired before execution jobId={} taskId={} moduleType={} claimUpdatedAt={}",
|
||||||
job.getId(), job.getTaskId(), job.getModuleType(), claim.getUpdatedAt());
|
job.getId(), job.getTaskId(), job.getModuleType(), claim.getUpdatedAt());
|
||||||
@@ -247,6 +265,15 @@ public class TaskResultFileJobWorker {
|
|||||||
job.getId(), job.getTaskId(), job.getModuleType(), job.getResultId());
|
job.getId(), job.getTaskId(), job.getModuleType(), job.getResultId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (taskFileJobService.isOwningTaskTerminal(job.getTaskId())) {
|
||||||
|
try (lockHandle) {
|
||||||
|
taskFileJobService.markFailedPermanent(job, "父任务已终态,结果作业不再执行");
|
||||||
|
}
|
||||||
|
log.info("[task-file-job] skipped after acquiring lock because parent task is terminal jobId={} taskId={} moduleType={} stage=TERMINAL_AFTER_LOCK",
|
||||||
|
job.getId(), job.getTaskId(), job.getModuleType());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeLockHandles.put(job.getId(), lockHandle);
|
||||||
try (lockHandle) {
|
try (lockHandle) {
|
||||||
latest = taskFileJobService.findById(job.getId());
|
latest = taskFileJobService.findById(job.getId());
|
||||||
if (latest != null && "SUCCESS".equals(latest.getStatus())) {
|
if (latest != null && "SUCCESS".equals(latest.getStatus())) {
|
||||||
@@ -283,6 +310,8 @@ public class TaskResultFileJobWorker {
|
|||||||
job.getId(), job.getTaskId(), job.getModuleType(), job.getResultId(),
|
job.getId(), job.getTaskId(), job.getModuleType(), job.getResultId(),
|
||||||
System.currentTimeMillis() - startedAt, resultFileUrl);
|
System.currentTimeMillis() - startedAt, resultFileUrl);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
activeLockHandles.remove(job.getId(), lockHandle);
|
||||||
}
|
}
|
||||||
// 成功后回调解耦(原 WITHDRAW 特判):时机与历史一致——锁已释放、markSuccess 之后;
|
// 成功后回调解耦(原 WITHDRAW 特判):时机与历史一致——锁已释放、markSuccess 之后;
|
||||||
// 各模块需要"任务收尾"时实现 ResultFileJobHandler.onSuccess,task 侧不再 import 业务模块
|
// 各模块需要"任务收尾"时实现 ResultFileJobHandler.onSuccess,task 侧不再 import 业务模块
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.nanri.aiimage.modules.task.mapper.TaskFileJobMapper">
|
||||||
|
|
||||||
|
<!-- B28:终态父任务的 job 不得再被领取;只读一列,按主键点查。 -->
|
||||||
|
<select id="selectFileTaskStatus" resultType="java.lang.String">
|
||||||
|
SELECT status FROM biz_file_task WHERE id = #{taskId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -61,7 +61,9 @@ class MigratedSqlEquivalenceTest {
|
|||||||
// (与 SqlLayeringConventionTest.XML_STATEMENT_TOTAL 同轮 99 → 115 → 124)。
|
// (与 SqlLayeringConventionTest.XML_STATEMENT_TOTAL 同轮 99 → 115 → 124)。
|
||||||
// 86 → 88:损耗监控在 UserSecretUsageMapper 新写 2 条聚合 select,逐条点入
|
// 86 → 88:损耗监控在 UserSecretUsageMapper 新写 2 条聚合 select,逐条点入
|
||||||
// (SqlLayeringConventionTest.XML_STATEMENT_TOTAL 同轮 124 → 126)。
|
// (SqlLayeringConventionTest.XML_STATEMENT_TOTAL 同轮 124 → 126)。
|
||||||
private static final int XML_SELECT_TOTAL = 88;
|
// 88 → 89:B28 新增 TaskFileJobMapper#selectFileTaskStatus(按主键读父任务状态),逐条点入
|
||||||
|
// (SqlLayeringConventionTest.XML_STATEMENT_TOTAL 同轮 128 → 129)。
|
||||||
|
private static final int XML_SELECT_TOTAL = 89;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 不是「从注解搬过来」的语句:注解时代没有原文可对撞,等价性这支只能跳过它们。
|
* 不是「从注解搬过来」的语句:注解时代没有原文可对撞,等价性这支只能跳过它们。
|
||||||
@@ -97,7 +99,9 @@ class MigratedSqlEquivalenceTest {
|
|||||||
"BrandGatingMapper#countGroupBySource",
|
"BrandGatingMapper#countGroupBySource",
|
||||||
// 损耗监控(2026-10-24)新写的 2 条聚合 select:当日全量扫描 + 单用户读数。
|
// 损耗监控(2026-10-24)新写的 2 条聚合 select:当日全量扫描 + 单用户读数。
|
||||||
"UserSecretUsageMapper#sumByUserAndModule",
|
"UserSecretUsageMapper#sumByUserAndModule",
|
||||||
"UserSecretUsageMapper#sumForUser");
|
"UserSecretUsageMapper#sumForUser",
|
||||||
|
// B28(2026-10-25)新写的 1 条主键点查:父任务是否已终态。
|
||||||
|
"TaskFileJobMapper#selectFileTaskStatus");
|
||||||
|
|
||||||
/** 账本 5 列:接口 / 方法 / @Select 种类 / 是否含常量插值 / 注解原文(Java 反转义后那条串)。 */
|
/** 账本 5 列:接口 / 方法 / @Select 种类 / 是否含常量插值 / 注解原文(Java 反转义后那条串)。 */
|
||||||
private static final int LEDGER_COLUMNS = 5;
|
private static final int LEDGER_COLUMNS = 5;
|
||||||
|
|||||||
@@ -78,7 +78,9 @@ class SqlLayeringConventionTest {
|
|||||||
// 124 → 126:损耗监控在 {@code UserSecretUsageMapper} 新写 2 条聚合 select
|
// 124 → 126:损耗监控在 {@code UserSecretUsageMapper} 新写 2 条聚合 select
|
||||||
// (当日全量扫描 + 单用户读数),同样逐条登记进 NOT_MIGRATED(86 → 88)。
|
// (当日全量扫描 + 单用户读数),同样逐条登记进 NOT_MIGRATED(86 → 88)。
|
||||||
// 126 → 128:同轮 {@code UserTaskGuardMapper} 的 pause/resume 两条写侧语句从注解迁进 XML。
|
// 126 → 128:同轮 {@code UserTaskGuardMapper} 的 pause/resume 两条写侧语句从注解迁进 XML。
|
||||||
private static final int XML_STATEMENT_TOTAL = 128;
|
// 128 → 129:B28 新增 {@code TaskFileJobMapper#selectFileTaskStatus}(按主键读父任务状态),
|
||||||
|
// 新写语句按约定直接进 XML,同轮登记进 MigratedSqlEquivalenceTest.NOT_MIGRATED(88 → 89)。
|
||||||
|
private static final int XML_STATEMENT_TOTAL = 129;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* wrapper 里夹带函数级 SQL 的现状("这不是简单单表"的证据),文件名 → 条数:
|
* wrapper 里夹带函数级 SQL 的现状("这不是简单单表"的证据),文件名 → 条数:
|
||||||
|
|||||||
+63
-14
@@ -1,16 +1,23 @@
|
|||||||
package com.nanri.aiimage.common.excel;
|
package com.nanri.aiimage.common.excel;
|
||||||
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
|
||||||
import com.nanri.aiimage.common.exception.BusinessException;
|
import com.nanri.aiimage.common.exception.BusinessException;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.openxml4j.opc.OPCPackage;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
import org.apache.poi.xssf.eventusermodel.XSSFReader;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.io.TempDir;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
@@ -97,11 +104,42 @@ class ExcelStreamReaderParseFailureTest {
|
|||||||
assertEquals("Nike", seen.toString());
|
assertEquals("Nike", seen.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path writeWorkbook() {
|
/** xls 分支单独钉:BIFF8 走 HSSFWorkbook,不能因为 xlsx 改事件模型就把旧格式丢了。 */
|
||||||
|
@Test
|
||||||
|
void hssfWorkbookStillReadsRows() throws Exception {
|
||||||
|
Path file = tempDir.resolve("ok.xls");
|
||||||
|
try (HSSFWorkbook workbook = new HSSFWorkbook()) {
|
||||||
|
Sheet sheet = workbook.createSheet("Sheet1");
|
||||||
|
Row header = sheet.createRow(0);
|
||||||
|
header.createCell(0).setCellValue("品牌");
|
||||||
|
header.createCell(1).setCellValue("ASIN");
|
||||||
|
Row data = sheet.createRow(1);
|
||||||
|
data.createCell(0).setCellValue("Nike");
|
||||||
|
data.createCell(1).setCellValue("B01ABC");
|
||||||
|
try (OutputStream out = Files.newOutputStream(file)) {
|
||||||
|
workbook.write(out);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuilder seen = new StringBuilder();
|
||||||
|
ExcelStreamReader.readFirstSheet(file.toFile(), (sheetName, sheetNo, rowIndex, headerMap, rowMap) ->
|
||||||
|
seen.append(rowMap.get(0)));
|
||||||
|
assertEquals("Nike", seen.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Path writeWorkbook() throws IOException {
|
||||||
Path file = tempDir.resolve("ok.xlsx");
|
Path file = tempDir.resolve("ok.xlsx");
|
||||||
List<List<String>> head = List.of(List.of("品牌"), List.of("ASIN"));
|
try (XSSFWorkbook workbook = new XSSFWorkbook()) {
|
||||||
List<List<String>> data = List.of(List.of("Nike", "B01ABC"));
|
Sheet sheet = workbook.createSheet("Sheet1");
|
||||||
EasyExcel.write(file.toFile()).head(head).sheet("Sheet1").doWrite(data);
|
Row header = sheet.createRow(0);
|
||||||
|
header.createCell(0).setCellValue("品牌");
|
||||||
|
header.createCell(1).setCellValue("ASIN");
|
||||||
|
Row data = sheet.createRow(1);
|
||||||
|
data.createCell(0).setCellValue("Nike");
|
||||||
|
data.createCell(1).setCellValue("B01ABC");
|
||||||
|
try (OutputStream out = Files.newOutputStream(file)) {
|
||||||
|
workbook.write(out);
|
||||||
|
}
|
||||||
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,17 +164,28 @@ class ExcelStreamReaderParseFailureTest {
|
|||||||
|
|
||||||
/** 直接喂同一个坏包,取 POI 自己报出来的真因文本,用来断言它没被收口吞掉。 */
|
/** 直接喂同一个坏包,取 POI 自己报出来的真因文本,用来断言它没被收口吞掉。 */
|
||||||
private String rawParseFailureMessageOf(Path badFile) throws IOException {
|
private String rawParseFailureMessageOf(Path badFile) throws IOException {
|
||||||
String message = null;
|
Throwable failure = null;
|
||||||
try (var input = Files.newInputStream(badFile)) {
|
try (InputStream input = Files.newInputStream(badFile);
|
||||||
EasyExcel.read(input).sheet(0).headRowNumber(1).doRead();
|
OPCPackage pkg = OPCPackage.open(input)) {
|
||||||
throw new AssertionError("构造的坏包必须让 EasyExcel 抛异常,否则这条用例证明不了收口");
|
XSSFReader reader = new XSSFReader(pkg);
|
||||||
} catch (RuntimeException ex) {
|
reader.getSharedStringsTable();
|
||||||
Throwable deepest = ex;
|
Iterator<InputStream> sheets = reader.getSheetsData();
|
||||||
|
if (sheets.hasNext()) {
|
||||||
|
try (InputStream sheet = sheets.next()) {
|
||||||
|
sheet.transferTo(OutputStream.nullOutputStream());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new AssertionError("构造的坏包必须让 POI 抛异常,否则这条用例证明不了收口");
|
||||||
|
} catch (AssertionError error) {
|
||||||
|
throw error;
|
||||||
|
} catch (Exception ex) {
|
||||||
|
failure = ex;
|
||||||
|
}
|
||||||
|
Throwable deepest = failure;
|
||||||
while (deepest.getCause() != null) {
|
while (deepest.getCause() != null) {
|
||||||
deepest = deepest.getCause();
|
deepest = deepest.getCause();
|
||||||
}
|
}
|
||||||
message = deepest.getMessage();
|
String message = deepest.getMessage();
|
||||||
}
|
|
||||||
assertTrue(message != null && message.length() > 20,
|
assertTrue(message != null && message.length() > 20,
|
||||||
"底层真因文本应当有信息量,实际=" + message);
|
"底层真因文本应当有信息量,实际=" + message);
|
||||||
return message;
|
return message;
|
||||||
|
|||||||
@@ -94,8 +94,18 @@ class CatchSilenceRatchetTest {
|
|||||||
* {@code ba20f5ed feat(workbench-client)} 那枚新增 catch,不属本批、也未由本批记名**,
|
* {@code ba20f5ed feat(workbench-client)} 那枚新增 catch,不属本批、也未由本批记名**,
|
||||||
* 该由那一笔自己把出处补进这份 diff。每一处本批的新增都在这里点名。
|
* 该由那一笔自己把出处补进这份 diff。每一处本批的新增都在这里点名。
|
||||||
* 不重抛/只 log/空体三格上限一个字没动。
|
* 不重抛/只 log/空体三格上限一个字没动。
|
||||||
|
*
|
||||||
|
* <p>10-24 Phase 7 EasyExcel→POI 收口再 +4,逐处点名(全部是 RETHROW 形状,气味三格未动):
|
||||||
|
* <ul>
|
||||||
|
* <li>{@code ExcelStreamReader.readOoxml} 三枚:{@code OpenXML4JException}(坏包)、
|
||||||
|
* {@code SAXException}(sheet XML 坏了)、{@code RuntimeException}(POI 解析期异常)
|
||||||
|
* 全部经 {@code toContractException} 转成 IOException 或原样重抛,不吞;</li>
|
||||||
|
* <li>{@code ExcelStreamReader.readHssf} 一枚:{@code RuntimeException} 同上收口。</li>
|
||||||
|
* </ul>
|
||||||
|
* 这 4 处是替换 EasyExcel 监听器后的等价出口(原实现的 catch 只在 {@code runRead} 一处,
|
||||||
|
* 但监听器内部另有 POI 的异常分诊);实测 total 1008。
|
||||||
*/
|
*/
|
||||||
static final int STRICT_TOTAL = 1004;
|
static final int STRICT_TOTAL = 1008;
|
||||||
/**
|
/**
|
||||||
* 重抛型 catch 的**下限**(不是上限):本轮把两处吞异常改成重抛之后实测 388。
|
* 重抛型 catch 的**下限**(不是上限):本轮把两处吞异常改成重抛之后实测 388。
|
||||||
* 这一格只能涨不能跌——它是"异常会往外走"的总量,把它钉成"只许减"就等于拦着别人修吞异常。
|
* 这一格只能涨不能跌——它是"异常会往外走"的总量,把它钉成"只许减"就等于拦着别人修吞异常。
|
||||||
|
|||||||
+3
-1
@@ -100,8 +100,10 @@ class TaskResultFileJobWorkerLogAuditTest {
|
|||||||
}
|
}
|
||||||
// 阶段字面量来自允许集合(防新增阶段拼写漂移)
|
// 阶段字面量来自允许集合(防新增阶段拼写漂移)
|
||||||
// SUCCESS_LOST:结果文件已生成但作业行不在本次执行手里(2026-10-09 任务 30456 的静默丢失)
|
// SUCCESS_LOST:结果文件已生成但作业行不在本次执行手里(2026-10-09 任务 30456 的静默丢失)
|
||||||
|
// 2026-10-24 B28:父任务终态后不再领取/执行/续期,三条出口各有一个阶段字面量。
|
||||||
List<String> allowed = List.of("SKIP_OWNER", "REQUEUE", "WAIT_LLM", "DEFER", "SUCCESS",
|
List<String> allowed = List.of("SKIP_OWNER", "REQUEUE", "WAIT_LLM", "DEFER", "SUCCESS",
|
||||||
"SUCCESS_LOST", "ORPHAN", "FAILED", "FINALIZE", "HEARTBEAT", "FALLBACK");
|
"SUCCESS_LOST", "ORPHAN", "FAILED", "FINALIZE", "HEARTBEAT", "FALLBACK",
|
||||||
|
"TERMINAL_SKIP", "TERMINAL_AFTER_LOCK", "TERMINAL_STOP_RENEW");
|
||||||
for (String l : perJob) {
|
for (String l : perJob) {
|
||||||
if (l.contains("stage=")) {
|
if (l.contains("stage=")) {
|
||||||
int idx = l.indexOf("stage=");
|
int idx = l.indexOf("stage=");
|
||||||
|
|||||||
+24
-1
@@ -1,6 +1,7 @@
|
|||||||
package com.nanri.aiimage.modules.auth.service;
|
package com.nanri.aiimage.modules.auth.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
import com.nanri.aiimage.common.exception.BusinessException;
|
import com.nanri.aiimage.common.exception.BusinessException;
|
||||||
import com.nanri.aiimage.common.security.AccountExpiryService;
|
import com.nanri.aiimage.common.security.AccountExpiryService;
|
||||||
@@ -22,6 +23,7 @@ import static org.assertj.core.api.Assertions.assertThatCode;
|
|||||||
import static org.assertj.core.api.Assertions.catchThrowableOfType;
|
import static org.assertj.core.api.Assertions.catchThrowableOfType;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
import static org.mockito.ArgumentMatchers.argThat;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.never;
|
import static org.mockito.Mockito.never;
|
||||||
@@ -62,7 +64,7 @@ class AuthServiceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void loginSkipsBindingWhenSingleDeviceDisabled() {
|
void loginSkipsBindingWhenSingleDeviceDisabledAndNotRevoked() {
|
||||||
Fixture f = fixture(false);
|
Fixture f = fixture(false);
|
||||||
when(f.loginUserMapper.selectOne(any())).thenReturn(f.user("devA"));
|
when(f.loginUserMapper.selectOne(any())).thenReturn(f.user("devA"));
|
||||||
when(f.passwordEncoder.matches("pwd", "hash")).thenReturn(true);
|
when(f.passwordEncoder.matches("pwd", "hash")).thenReturn(true);
|
||||||
@@ -78,6 +80,27 @@ class AuthServiceTest {
|
|||||||
verify(f.loginUserMapper, never()).update(any(), any());
|
verify(f.loginUserMapper, never()).update(any(), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void loginClearsLogoutRevocationMarkerWhenSingleDeviceDisabled() {
|
||||||
|
// 开关关掉后登录不再写 machine,登出标记若不清掉,新 token 会被 assertNotRevoked
|
||||||
|
// 判成「登录已过期」——表现是登录成功后又弹登录页(2026-10-24 现网 admin 锁死)。
|
||||||
|
Fixture f = fixture(false);
|
||||||
|
when(f.loginUserMapper.selectOne(any())).thenReturn(f.user("revoked@7#20261024185618"));
|
||||||
|
when(f.passwordEncoder.matches("pwd", "hash")).thenReturn(true);
|
||||||
|
when(f.jwtService.issue(eq(7L), anyString(), anyString())).thenReturn("jwt-token");
|
||||||
|
|
||||||
|
LoginRequest request = new LoginRequest();
|
||||||
|
request.setUsername("u7");
|
||||||
|
request.setPassword("pwd");
|
||||||
|
request.setDeviceId("devB");
|
||||||
|
|
||||||
|
assertThatCode(() -> f.service.login(request)).doesNotThrowAnyException();
|
||||||
|
|
||||||
|
verify(f.loginUserMapper, times(1)).update(any(),
|
||||||
|
argThat(wrapper -> wrapper instanceof LambdaUpdateWrapper
|
||||||
|
&& ((LambdaUpdateWrapper<?>) wrapper).getSqlSet().contains("machine")));
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- check_login:被顶下线必须拦截且不续期 ----------
|
// ---------- check_login:被顶下线必须拦截且不续期 ----------
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
+14
@@ -376,6 +376,20 @@ class BrandCheckClientTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** 有真实 HTTP 断言的用例必须桩出非空代理,否则客户端零请求短路、阶梯与指标全测不到。 */
|
/** 有真实 HTTP 断言的用例必须桩出非空代理,否则客户端零请求短路、阶梯与指标全测不到。 */
|
||||||
|
@Test
|
||||||
|
void brandLabelPrefixIsStrippedBeforeQueryingUpstream() {
|
||||||
|
UserApiSecretService noProxy = mock(UserApiSecretService.class);
|
||||||
|
when(noProxy.findPlainValue(anyLong(), anyString())).thenReturn("");
|
||||||
|
BrandCheckClient client = new BrandCheckClient(
|
||||||
|
new BrandCheckProperties(), null, noProxy, new UnreachableCooldown());
|
||||||
|
|
||||||
|
BrandCheckClient.BrandCheckResponse response = client.check("Brand: NIKE", "Terms", 7L);
|
||||||
|
|
||||||
|
assertThat(response.getQueryFaildData())
|
||||||
|
.as("查询词必须先剥标签前缀,否则上游判 undefined field Brand")
|
||||||
|
.containsExactly("NIKE");
|
||||||
|
}
|
||||||
|
|
||||||
private UserApiSecretService stubbedUserSecrets() {
|
private UserApiSecretService stubbedUserSecrets() {
|
||||||
UserApiSecretService secrets = mock(UserApiSecretService.class);
|
UserApiSecretService secrets = mock(UserApiSecretService.class);
|
||||||
when(secrets.findPlainValue(anyLong(), anyString())).thenReturn("http://user:pass@127.0.0.1:9");
|
when(secrets.findPlainValue(anyLong(), anyString())).thenReturn("http://user:pass@127.0.0.1:9");
|
||||||
|
|||||||
+48
@@ -0,0 +1,48 @@
|
|||||||
|
package com.nanri.aiimage.modules.task.service;
|
||||||
|
|
||||||
|
import com.nanri.aiimage.common.service.DistributedJobLockService;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* B28:父任务终态后,心跳调用的 {@code stopRenewal} 必须真的让看门狗停下,
|
||||||
|
* 但**不释放**锁(释放仍由带 token 的 close 收尾,避免误删接管者的锁)。
|
||||||
|
*/
|
||||||
|
class TaskDistributedLockServiceStopRenewalTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void stopRenewalStopsTheWatchdogWithoutReleasingTheLock() throws Exception {
|
||||||
|
AtomicInteger renewCalls = new AtomicInteger();
|
||||||
|
DistributedJobLockService delegate = mock(DistributedJobLockService.class);
|
||||||
|
DistributedJobLockService.LockHandle inner = mock(DistributedJobLockService.LockHandle.class);
|
||||||
|
when(inner.renew(any(Duration.class))).thenAnswer(invocation -> {
|
||||||
|
renewCalls.incrementAndGet();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
when(delegate.tryLock(anyString(), any(Duration.class))).thenReturn(inner);
|
||||||
|
TaskDistributedLockService service = new TaskDistributedLockService(delegate);
|
||||||
|
|
||||||
|
TaskDistributedLockService.LockHandle handle =
|
||||||
|
service.acquire("appearance-patent", 32220L, Duration.ofSeconds(1), 0);
|
||||||
|
assertTrue(service.activeHeldMillis().containsKey("task:appearance-patent:32220"));
|
||||||
|
|
||||||
|
handle.stopRenewal("parent-task-terminal");
|
||||||
|
Thread.sleep(1_400L);
|
||||||
|
|
||||||
|
assertEquals(0, renewCalls.get(), "stopRenewal 之后看门狗不得再续期");
|
||||||
|
assertTrue(service.activeHeldMillis().containsKey("task:appearance-patent:32220"),
|
||||||
|
"停续期不等于释放:锁仍在持,由 close 收尾");
|
||||||
|
|
||||||
|
handle.close();
|
||||||
|
assertTrue(service.activeHeldMillis().isEmpty(), "close 仍要正常释放");
|
||||||
|
}
|
||||||
|
}
|
||||||
+138
@@ -0,0 +1,138 @@
|
|||||||
|
package com.nanri.aiimage.modules.task.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.MybatisConfiguration;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
|
||||||
|
import com.nanri.aiimage.modules.task.mapper.TaskFileJobMapper;
|
||||||
|
import com.nanri.aiimage.modules.task.model.entity.TaskFileJobEntity;
|
||||||
|
import org.apache.ibatis.builder.MapperBuilderAssistant;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.mockito.junit.jupiter.MockitoExtension;
|
||||||
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.isNull;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
|
import static org.mockito.Mockito.verify;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* B28:父任务进入终态后,其结果作业不得再被领取。
|
||||||
|
*
|
||||||
|
* <p>现网读数(2026-10-24):任务 32217/32220/32226/32229 已是 FAILED,
|
||||||
|
* 同刻仍在打「候选收集逐行申领」、锁续到 86 分钟。这里把两条 claim 入口
|
||||||
|
* (claimCandidates / claimRunning)都钉住:终态任务的行不再翻转成 RUNNING,
|
||||||
|
* 而是拉满重试并打终态回调,下一轮扫描不会再捞起来。
|
||||||
|
*/
|
||||||
|
@ExtendWith(MockitoExtension.class)
|
||||||
|
class TaskFileJobTerminalTaskGuardTest {
|
||||||
|
|
||||||
|
@Mock private TaskFileJobMapper taskFileJobMapper;
|
||||||
|
@Mock private ApplicationEventPublisher applicationEventPublisher;
|
||||||
|
|
||||||
|
private TaskFileJobService service;
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void initializeTableInfo() {
|
||||||
|
TableInfoHelper.initTableInfo(
|
||||||
|
new MapperBuilderAssistant(new MybatisConfiguration(), ""),
|
||||||
|
TaskFileJobEntity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void setUp() {
|
||||||
|
service = new TaskFileJobService(taskFileJobMapper, applicationEventPublisher);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static TaskFileJobEntity job(Long id, Long taskId) {
|
||||||
|
TaskFileJobEntity job = new TaskFileJobEntity();
|
||||||
|
job.setId(id);
|
||||||
|
job.setTaskId(taskId);
|
||||||
|
job.setResultId(2000L + id);
|
||||||
|
job.setModuleType("APPEARANCE_PATENT");
|
||||||
|
job.setJobType("ASSEMBLE_RESULT");
|
||||||
|
job.setStatus("PENDING");
|
||||||
|
job.setRetryCount(0);
|
||||||
|
job.setUpdatedAt(LocalDateTime.now());
|
||||||
|
return job;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean hasParam(LambdaUpdateWrapper<TaskFileJobEntity> wrapper, Object value) {
|
||||||
|
return wrapper.getParamNameValuePairs().containsValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void claimRunningRejectsJobWhoseTaskIsFailed() {
|
||||||
|
TaskFileJobEntity failedTaskJob = job(11L, 500L);
|
||||||
|
when(taskFileJobMapper.selectById(11L)).thenReturn(failedTaskJob);
|
||||||
|
when(taskFileJobMapper.selectFileTaskStatus(500L)).thenReturn("FAILED");
|
||||||
|
when(taskFileJobMapper.update(isNull(), any(LambdaUpdateWrapper.class))).thenReturn(1);
|
||||||
|
|
||||||
|
assertNull(service.claimRunning(11L), "终态任务的作业不得被 claim 成 RUNNING");
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
ArgumentCaptor<LambdaUpdateWrapper<TaskFileJobEntity>> captor =
|
||||||
|
ArgumentCaptor.forClass(LambdaUpdateWrapper.class);
|
||||||
|
verify(taskFileJobMapper, times(1)).update(isNull(), captor.capture());
|
||||||
|
LambdaUpdateWrapper<TaskFileJobEntity> wrapper = captor.getValue();
|
||||||
|
assertTrue(hasParam(wrapper, "FAILED"), "必须把作业拉成 FAILED,下一轮扫描才捞不到");
|
||||||
|
assertTrue(hasParam(wrapper, 5), "retry_count 必须一次拉满到上限");
|
||||||
|
assertFalse(hasParam(wrapper, "RUNNING"), "不得再翻转成 RUNNING");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void claimCandidatesSkipsTerminalTaskAndKeepsActiveOne() {
|
||||||
|
TaskFileJobEntity terminal = job(21L, 500L);
|
||||||
|
TaskFileJobEntity active = job(22L, 501L);
|
||||||
|
when(taskFileJobMapper.selectList(any(LambdaQueryWrapper.class)))
|
||||||
|
.thenReturn(List.of(terminal, active));
|
||||||
|
when(taskFileJobMapper.selectFileTaskStatus(500L)).thenReturn("FAILED");
|
||||||
|
when(taskFileJobMapper.selectFileTaskStatus(501L)).thenReturn("RUNNING");
|
||||||
|
when(taskFileJobMapper.update(isNull(), any(LambdaUpdateWrapper.class))).thenReturn(1, 1);
|
||||||
|
TaskFileJobEntity claimedActive = job(22L, 501L);
|
||||||
|
claimedActive.setStatus("RUNNING");
|
||||||
|
when(taskFileJobMapper.selectBatchIds(any())).thenReturn(List.of(claimedActive));
|
||||||
|
|
||||||
|
List<TaskFileJobEntity> claimed = service.claimRunnableJobs(10);
|
||||||
|
|
||||||
|
assertEquals(1, claimed.size(), "终态任务的 job 不入结果集");
|
||||||
|
assertEquals(22L, claimed.get(0).getId());
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
ArgumentCaptor<LambdaUpdateWrapper<TaskFileJobEntity>> captor =
|
||||||
|
ArgumentCaptor.forClass(LambdaUpdateWrapper.class);
|
||||||
|
verify(taskFileJobMapper, times(2)).update(isNull(), captor.capture());
|
||||||
|
assertTrue(hasParam(captor.getAllValues().get(0), "FAILED"), "第一笔是终态收尾");
|
||||||
|
assertTrue(hasParam(captor.getAllValues().get(1), "RUNNING"), "第二笔才是正常 claim");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void unknownTaskRowIsNotTreatedAsTerminal() {
|
||||||
|
// 品牌任务的 taskId 不在 biz_file_task(查询返回 null):按非终态走,行为不变。
|
||||||
|
when(taskFileJobMapper.selectFileTaskStatus(900L)).thenReturn(null);
|
||||||
|
|
||||||
|
assertFalse(service.isOwningTaskTerminal(900L));
|
||||||
|
verify(taskFileJobMapper, never()).update(isNull(), any(LambdaUpdateWrapper.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void nullAndNonPositiveTaskIdAreNotTerminal() {
|
||||||
|
assertFalse(service.isOwningTaskTerminal(null));
|
||||||
|
assertFalse(service.isOwningTaskTerminal(0L));
|
||||||
|
assertFalse(service.isOwningTaskTerminal(-1L));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -164,71 +164,16 @@
|
|||||||
>
|
>
|
||||||
<template #cards-extra>
|
<template #cards-extra>
|
||||||
<div class="subsection-title">匹配结果</div>
|
<div class="subsection-title">匹配结果</div>
|
||||||
<div v-if="!matchedItems.length" class="match-empty">
|
<BrandShopMatchTable
|
||||||
完成“匹配店铺”后,这里会展示匹配结果。
|
v-model:page="matchedPage"
|
||||||
</div>
|
:items="pagedMatchedItems"
|
||||||
<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"
|
|
||||||
:total="matchedTotal"
|
:total="matchedTotal"
|
||||||
:page-size="matchedPageSize"
|
:page-size="matchedPageSize"
|
||||||
v-model:current-page="matchedPage"
|
:row-key="rowKeyForMatch"
|
||||||
|
:status-text="formatMatchStatus"
|
||||||
|
:remark-text="formatMatchRemark"
|
||||||
|
empty-text="完成“匹配店铺”后,这里会展示匹配结果。"
|
||||||
|
@remove="removeMatchedRow"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #item-actions="{ item }">
|
<template #item-actions="{ item }">
|
||||||
@@ -252,6 +197,15 @@ import { userNotice } from '@/shared/utils/user-notice'
|
|||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
|
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
|
||||||
import TaskCenterPanel from "@/shared/components/tasks/TaskCenterPanel.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 type { TaskItemView, TaskStatCard } from "@/shared/components/tasks/types";
|
||||||
import {
|
import {
|
||||||
addPatrolDeleteCandidate,
|
addPatrolDeleteCandidate,
|
||||||
@@ -405,11 +359,6 @@ const hasQueueWork = computed(
|
|||||||
!!activeTaskId.value,
|
!!activeTaskId.value,
|
||||||
);
|
);
|
||||||
|
|
||||||
function uidForStorage() {
|
|
||||||
return typeof window !== "undefined"
|
|
||||||
? window.localStorage.getItem("uid") || "0"
|
|
||||||
: "0";
|
|
||||||
}
|
|
||||||
|
|
||||||
function matchedStorageKey() {
|
function matchedStorageKey() {
|
||||||
return `patrol-delete:matched:${uidForStorage()}`;
|
return `patrol-delete:matched:${uidForStorage()}`;
|
||||||
@@ -423,13 +372,7 @@ function countryCodesStorageKey() {
|
|||||||
return `patrol-delete:country-codes:${uidForStorage()}`;
|
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) {
|
function taskGroupKey(item: PatrolDeleteHistoryItem) {
|
||||||
return `task:${item.taskId ?? item.resultId ?? 0}`;
|
return `task:${item.taskId ?? item.resultId ?? 0}`;
|
||||||
@@ -453,20 +396,6 @@ function clearSleepTimers() {
|
|||||||
timers.clearCategory("queue-wait");
|
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>(
|
async function withTransientRetry<T>(
|
||||||
action: () => Promise<T>,
|
action: () => Promise<T>,
|
||||||
@@ -493,34 +422,7 @@ function createSubmissionId(taskId: number, shopName?: string) {
|
|||||||
return `patrol-delete:${taskId}:${shopName || "shop"}:${Date.now()}`;
|
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[] {
|
function buildTemplateCountrySections(): PatrolDeleteCountrySection[] {
|
||||||
return selectedCountryNames.value.map((country) => ({
|
return selectedCountryNames.value.map((country) => ({
|
||||||
|
|||||||
@@ -180,37 +180,21 @@
|
|||||||
>
|
>
|
||||||
<template #cards-extra>
|
<template #cards-extra>
|
||||||
<div class="subsection-title">匹配结果</div>
|
<div class="subsection-title">匹配结果</div>
|
||||||
<div v-if="!matchedItems.length" class="match-empty">完成「匹配店铺」后,在此展示匹配结果,确认无误后再启动任务。</div>
|
<BrandShopMatchTable
|
||||||
<el-table v-else :data="pagedMatchedItems" :row-key="rowKeyForMatch" :highlight-current-row="false"
|
v-model:page="matchedPage"
|
||||||
class="result-table match-table">
|
:items="pagedMatchedItems"
|
||||||
<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"
|
|
||||||
:total="matchedTotal"
|
:total="matchedTotal"
|
||||||
:page-size="matchedPageSize"
|
: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>
|
||||||
<template #item-actions="{ item }">
|
<template #item-actions="{ item }">
|
||||||
@@ -245,6 +229,7 @@ import {
|
|||||||
import ModuleTemplateDownload from '@/shared/components/ModuleTemplateDownload.vue'
|
import ModuleTemplateDownload from '@/shared/components/ModuleTemplateDownload.vue'
|
||||||
import FileUploadZone from '@/shared/components/FileUploadZone.vue'
|
import FileUploadZone from '@/shared/components/FileUploadZone.vue'
|
||||||
import TaskCenterPanel from '@/shared/components/tasks/TaskCenterPanel.vue'
|
import TaskCenterPanel from '@/shared/components/tasks/TaskCenterPanel.vue'
|
||||||
|
import BrandShopMatchTable from './BrandShopMatchTable.vue'
|
||||||
import type { TaskItemView, TaskStatCard } from '@/shared/components/tasks/types'
|
import type { TaskItemView, TaskStatCard } from '@/shared/components/tasks/types'
|
||||||
import { getPywebviewApi, type PywebviewApi } from '@/shared/bridges/pywebview'
|
import { getPywebviewApi, type PywebviewApi } from '@/shared/bridges/pywebview'
|
||||||
import { useExcelFileUpload } from '@/shared/composables/useExcelFileUpload'
|
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 s = (status || '').trim()
|
||||||
const map: Record<string, string> = { MATCHED: '已匹配', PENDING: '待匹配', CONFLICT: '需人工确认', INDEX_STALE: '匹配已过期' }
|
const map: Record<string, string> = { MATCHED: '已匹配', PENDING: '待匹配', CONFLICT: '需人工确认', INDEX_STALE: '匹配已过期' }
|
||||||
return map[s] || (s ? s : '—')
|
return map[s] || (s ? s : '—')
|
||||||
|
|||||||
@@ -99,37 +99,21 @@
|
|||||||
>
|
>
|
||||||
<template #cards-extra>
|
<template #cards-extra>
|
||||||
<div class="subsection-title">匹配结果</div>
|
<div class="subsection-title">匹配结果</div>
|
||||||
<div v-if="!matchedItems.length" class="match-empty">完成「匹配店铺」后,在此展示匹配结果,确认无误后再启动任务。</div>
|
<BrandShopMatchTable
|
||||||
<el-table v-else :data="pagedMatchedItems" :row-key="rowKeyForMatch" :highlight-current-row="false"
|
v-model:page="matchedPage"
|
||||||
class="result-table match-table">
|
:items="pagedMatchedItems"
|
||||||
<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"
|
|
||||||
:total="matchedTotal"
|
:total="matchedTotal"
|
||||||
:page-size="matchedPageSize"
|
: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>
|
||||||
<template #item-actions="{ item }">
|
<template #item-actions="{ item }">
|
||||||
@@ -155,6 +139,7 @@ import { userNotice } from '@/shared/utils/user-notice'
|
|||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
|
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
|
||||||
import TaskCenterPanel from '@/shared/components/tasks/TaskCenterPanel.vue'
|
import TaskCenterPanel from '@/shared/components/tasks/TaskCenterPanel.vue'
|
||||||
|
import BrandShopMatchTable from './BrandShopMatchTable.vue'
|
||||||
import type { TaskItemView, TaskStatCard } from '@/shared/components/tasks/types'
|
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 { LISTING_FILTER_OPTIONS, RISK_LISTING_FILTER_KEY, productRiskFilterIssues, type ListingFilterValue } from '@/pages/brand/components/listingFilters'
|
||||||
import {
|
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 s = (status || '').trim()
|
||||||
const map: Record<string, string> = {
|
const map: Record<string, string> = {
|
||||||
MATCHED: '已匹配',
|
MATCHED: '已匹配',
|
||||||
|
|||||||
@@ -116,71 +116,16 @@
|
|||||||
>
|
>
|
||||||
<template #cards-extra>
|
<template #cards-extra>
|
||||||
<div class="subsection-title">匹配结果</div>
|
<div class="subsection-title">匹配结果</div>
|
||||||
<div v-if="!matchedItems.length" class="match-empty">
|
<BrandShopMatchTable
|
||||||
完成“匹配店铺”后,这里会展示匹配结果。
|
v-model:page="matchedPage"
|
||||||
</div>
|
:items="pagedMatchedItems"
|
||||||
<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"
|
|
||||||
:total="matchedTotal"
|
:total="matchedTotal"
|
||||||
:page-size="matchedPageSize"
|
:page-size="matchedPageSize"
|
||||||
v-model:current-page="matchedPage"
|
:row-key="rowKeyForMatch"
|
||||||
|
:status-text="formatMatchStatus"
|
||||||
|
:remark-text="formatMatchRemark"
|
||||||
|
empty-text="完成“匹配店铺”后,这里会展示匹配结果。"
|
||||||
|
@remove="removeMatchedRow"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #item-actions="{ item }">
|
<template #item-actions="{ item }">
|
||||||
@@ -205,6 +150,15 @@ import { ElMessage } from "element-plus";
|
|||||||
import type { TableInstance } from "element-plus";
|
import type { TableInstance } from "element-plus";
|
||||||
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
|
import AmazonToolPageShell from '@/pages/amazon/components/AmazonToolPageShell.vue';
|
||||||
import TaskCenterPanel from "@/shared/components/tasks/TaskCenterPanel.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 type { TaskItemView, TaskStatCard } from "@/shared/components/tasks/types";
|
||||||
import {
|
import {
|
||||||
addQueryAsinCandidate,
|
addQueryAsinCandidate,
|
||||||
@@ -356,11 +310,6 @@ const hasQueuedTaskWork = computed(
|
|||||||
const hasQueueWork = computed(() => queueWorkerRunning.value || hasQueuedTaskWork.value);
|
const hasQueueWork = computed(() => queueWorkerRunning.value || hasQueuedTaskWork.value);
|
||||||
const isQueueBusy = 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() {
|
function matchedStorageKey() {
|
||||||
return `query-asin:matched:${uidForStorage()}`;
|
return `query-asin:matched:${uidForStorage()}`;
|
||||||
@@ -374,13 +323,7 @@ function taskStartTimeStorageKey() {
|
|||||||
return `query-asin:start-times:${uidForStorage()}`;
|
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;
|
let disposed = false;
|
||||||
|
|
||||||
@@ -400,20 +343,6 @@ function clearSleepTimers() {
|
|||||||
timers.clearCategory("queue-wait");
|
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>(
|
async function withTransientRetry<T>(
|
||||||
action: () => Promise<T>,
|
action: () => Promise<T>,
|
||||||
@@ -440,34 +369,7 @@ function createSubmissionId(taskId: number, shopName?: string) {
|
|||||||
return `query-asin:${taskId}:${shopName || "shop"}:${Date.now()}`;
|
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">) {
|
function flattenQueryAsinRows(record: Pick<QueryAsinHistoryItem, "shopName" | "queryAsins">) {
|
||||||
const sections = readQueryAsins(record);
|
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>
|
||||||
<div v-else class="match-zone-scroll">
|
<div v-else class="match-zone-scroll">
|
||||||
<el-table
|
<BrandShopMatchTable
|
||||||
:data="pagedMatchedItems"
|
v-model:page="matchedPage"
|
||||||
:row-key="rowKeyForMatch"
|
:items="pagedMatchedItems"
|
||||||
: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"
|
|
||||||
:total="matchedTotal"
|
:total="matchedTotal"
|
||||||
:page-size="matchedPageSize"
|
:page-size="matchedPageSize"
|
||||||
v-model:current-page="matchedPage"
|
:row-key="rowKeyForMatch"
|
||||||
|
:status-text="formatMatchStatus"
|
||||||
|
:remark-text="formatMatchRemark"
|
||||||
|
empty-text="完成“匹配店铺”后,这里会展示匹配结果。"
|
||||||
|
@remove="removeMatchedRow"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</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 { RUNNING_UNTIL_DONE_STATUS_OPTIONS, taskStatusClass, taskStatusText } from '@/shared/utils/task-status-text'
|
||||||
import { useHistoryPolling } from '@/shared/composables/useHistoryPolling'
|
import { useHistoryPolling } from '@/shared/composables/useHistoryPolling'
|
||||||
import { runBatchDelete } from '@/shared/utils/batch-delete'
|
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 { isRecordMissingError, parseTaskStartTimes, removeTaskStartTime, upsertTaskStartTime } from '@/shared/utils/task-queue-state.ts'
|
||||||
import { useTablePaging } from '@/shared/composables/useTablePaging.ts'
|
import { useTablePaging } from '@/shared/composables/useTablePaging.ts'
|
||||||
import { getModuleProgressLight } from '@/shared/api/progress-light.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() {
|
function matchedStorageKey() {
|
||||||
return `withdraw:matched:${uidForStorage()}`;
|
return `withdraw:matched:${uidForStorage()}`;
|
||||||
@@ -407,13 +360,7 @@ function taskStartTimeStorageKey() {
|
|||||||
return `withdraw:start-times:${uidForStorage()}`;
|
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[]) {
|
function batchKeyForItems(items: WithdrawShopQueueItem[]) {
|
||||||
return items.map((item) => rowKeyForMatch(item)).join("||");
|
return items.map((item) => rowKeyForMatch(item)).join("||");
|
||||||
@@ -513,20 +460,6 @@ function clearSleepTimers() {
|
|||||||
timers.clearCategory("queue-wait");
|
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>(
|
async function withTransientRetry<T>(
|
||||||
action: () => Promise<T>,
|
action: () => Promise<T>,
|
||||||
@@ -553,34 +486,7 @@ function createSubmissionId(taskId: number, shopName?: string) {
|
|||||||
return `withdraw:${taskId}:${shopName || "shop"}:${Date.now()}`;
|
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>(
|
function withWithdrawFallback<T extends WithdrawHistoryItem | WithdrawShopQueueItem>(
|
||||||
item: T,
|
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>
|
||||||
@@ -318,177 +318,53 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<AiSectionCard :step="activeTab === 'remake' ? '07' : '06'" title="视频结果" description="提交后在这里等待、预览和下载成片。"
|
<DeliveryVideoResultPanel
|
||||||
class="delivery-card delivery-card--preview">
|
:workspace="currentWorkspace"
|
||||||
<el-tabs v-model="currentWorkspace.generationMode" class="generation-mode-tabs">
|
:active-tab="activeTab"
|
||||||
<el-tab-pane label="样片模式" name="draft">
|
:busy="assemblyBusy"
|
||||||
<p>快速生成预览视频,用于验证场景结构、镜头调度、主体动作和提示词意图,消耗更少 token。</p>
|
:downloading="assemblyDownloading"
|
||||||
</el-tab-pane>
|
:polling="assemblyPolling"
|
||||||
<el-tab-pane label="正常生成" name="standard">
|
:execute-id="assemblyExecuteId"
|
||||||
<p>关闭样片模式,按正常规格生成视频。</p>
|
:poll-count="assemblyPollCount"
|
||||||
</el-tab-pane>
|
:video-url="assemblyVideoUrl"
|
||||||
</el-tabs>
|
:debug-url="assemblyDebugUrl"
|
||||||
<div class="preview-panel__meta">
|
:result-text="assemblyResultText"
|
||||||
<div class="preview-row">
|
:primary-action-text="assemblyPrimaryActionText"
|
||||||
<span class="preview-row__label">模式</span>
|
:can-reset="canResetWorkspace"
|
||||||
<span class="preview-row__value">{{ activeTab === 'remake' ? '视频复刻' : '图生视频' }}</span>
|
@primary="handleAssemblyPrimaryAction"
|
||||||
</div>
|
@reset="resetCurrentWorkspace"
|
||||||
<div class="preview-row">
|
/>
|
||||||
<span class="preview-row__label">规格</span>
|
|
||||||
<span class="preview-row__value">{{ currentWorkspace.ratio }} / {{ currentWorkspace.resolution }} / {{
|
|
||||||
currentWorkspace.durationSeconds }}秒</span>
|
|
||||||
</div>
|
|
||||||
<div class="preview-row">
|
|
||||||
<span class="preview-row__label">产品</span>
|
|
||||||
<span class="preview-row__value">{{ currentWorkspace.productName || '未设置' }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="video-result-actions">
|
|
||||||
<el-button class="delivery-primary-btn" type="primary" :loading="assemblyBusy || assemblyDownloading"
|
|
||||||
:disabled="assemblyBusy || assemblyDownloading" @click="handleAssemblyPrimaryAction">
|
|
||||||
{{ assemblyPrimaryActionText }}
|
|
||||||
</el-button>
|
|
||||||
<el-button v-if="canResetWorkspace" class="delivery-secondary-btn"
|
|
||||||
:disabled="assemblyBusy || assemblyDownloading" @click="resetCurrentWorkspace">
|
|
||||||
重置内容
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<div v-if="assemblyBusy || assemblyExecuteId" class="assembly-waiting"
|
|
||||||
:class="{ 'assembly-waiting--done': !assemblyBusy && assemblyExecuteId }">
|
|
||||||
<div class="assembly-waiting__spinner" aria-hidden="true"></div>
|
|
||||||
<div class="assembly-waiting__content">
|
|
||||||
<strong>{{ assemblyPolling ? '正在生成视频,请保持页面打开' : '工作流已提交' }}</strong>
|
|
||||||
<span v-if="assemblyExecuteId">执行 ID:{{ assemblyExecuteId }}</span>
|
|
||||||
<span v-if="assemblyPolling">已查询 {{ assemblyPollCount }} 次,系统会每 5 秒自动刷新结果。</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="video-result-panel">
|
|
||||||
<div v-if="assemblyVideoUrl" class="video-result-panel__player">
|
|
||||||
<video :src="assemblyVideoUrl" controls playsinline preload="metadata"></video>
|
|
||||||
</div>
|
|
||||||
<div v-else class="video-result-panel__empty">
|
|
||||||
<span>{{ assemblyPolling ? '视频生成中,完成后会在这里显示结果。' : '提交生成后,这里会显示生成的视频结果。' }}</span>
|
|
||||||
</div>
|
|
||||||
<div v-if="assemblyVideoUrl" class="video-result-panel__link">
|
|
||||||
<span>视频地址</span>
|
|
||||||
<a :href="safeHttpUrl(assemblyVideoUrl)" target="_blank" rel="noreferrer">{{ assemblyVideoUrl }}</a>
|
|
||||||
</div>
|
|
||||||
<div v-if="assemblyDebugUrl" class="video-result-panel__link">
|
|
||||||
<span>调试链接</span>
|
|
||||||
<a :href="safeHttpUrl(assemblyDebugUrl)" target="_blank" rel="noreferrer">{{ assemblyDebugUrl }}</a>
|
|
||||||
</div>
|
|
||||||
<details v-if="assemblyResultText" class="video-result-panel__debug">
|
|
||||||
<summary>查看原始返回</summary>
|
|
||||||
<el-input v-model="assemblyResultText" type="textarea" :rows="8" resize="none" readonly />
|
|
||||||
</details>
|
|
||||||
</div>
|
|
||||||
</AiSectionCard>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-dialog v-model="secretDialogVisible" title="视频密钥设置" width="560px" class="image-video-secret-dialog"
|
<DeliveryVideoSecretDialog
|
||||||
append-to-body destroy-on-close>
|
v-model:visible="secretDialogVisible"
|
||||||
<div class="secret-status" :class="{ 'secret-status--valid': secretStatus?.valid }">
|
:status="secretStatus"
|
||||||
<span>{{ secretStatusText }}</span>
|
:status-text="secretStatusText"
|
||||||
<span v-if="secretExpireText">{{ secretExpireText }}</span>
|
:expire-text="secretExpireText"
|
||||||
</div>
|
:saving="secretSaving"
|
||||||
|
:form="secretForm"
|
||||||
|
@save="saveSecretSettings"
|
||||||
|
/>
|
||||||
|
|
||||||
<el-form label-position="top" class="secret-form">
|
<DeliveryVideoVoiceDialog
|
||||||
<el-form-item label="爬虫密钥">
|
v-model:visible="voiceDialogVisible"
|
||||||
<el-input v-model="secretForm.copyApiKey" type="password" show-password placeholder="不填写则保留当前有效值" />
|
v-model:tab="voiceDialogTab"
|
||||||
<div v-if="secretStatus?.copyApiKeyMasked" class="secret-form__hint">当前:{{ secretStatus.copyApiKeyMasked }}
|
v-model:keyword="voiceSearchKeyword"
|
||||||
</div>
|
v-model:clone-name="voiceCloneName"
|
||||||
</el-form-item>
|
:items="voiceListItems"
|
||||||
<el-form-item label="T8密钥(海外)">
|
:filtered-items="filteredVoiceListItems"
|
||||||
<el-input v-model="secretForm.t8Key" type="password" show-password placeholder="不填写则保留当前有效值" />
|
:loading="voiceLoading"
|
||||||
<div v-if="secretStatus?.t8KeyMasked" class="secret-form__hint">当前:{{ secretStatus.t8KeyMasked }}</div>
|
:clone-asset="voiceCloneAsset"
|
||||||
</el-form-item>
|
@list="listVoices"
|
||||||
<el-form-item label="T8密钥(国内)">
|
@use="useVoice"
|
||||||
<el-input v-model="secretForm.t8VideoKey" type="password" show-password placeholder="不填写则保留当前有效值" />
|
@delete="deleteVoice"
|
||||||
<div v-if="secretStatus?.t8VideoKeyMasked" class="secret-form__hint">当前:{{ secretStatus.t8VideoKeyMasked }}
|
@clone="cloneVoice"
|
||||||
</div>
|
@select-clone-asset="setVoiceCloneAsset"
|
||||||
</el-form-item>
|
@url-clone-asset="setVoiceCloneUrl"
|
||||||
<el-form-item label="音频密钥">
|
@clear-clone-asset="clearVoiceCloneAsset"
|
||||||
<el-input v-model="secretForm.voiceApiKey" type="password" show-password placeholder="不填写则保留当前有效值" />
|
/>
|
||||||
<div v-if="secretStatus?.voiceApiKeyMasked" class="secret-form__hint">当前:{{ secretStatus.voiceApiKeyMasked }}
|
|
||||||
</div>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="音频团队ID">
|
|
||||||
<el-input v-model="secretForm.voiceGroupId" type="password" show-password placeholder="不填写则保留当前有效值" />
|
|
||||||
<div v-if="secretStatus?.voiceGroupIdMasked" class="secret-form__hint">当前:{{ secretStatus.voiceGroupIdMasked
|
|
||||||
}}</div>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="有效期">
|
|
||||||
<el-select v-model="secretForm.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>
|
<DeliveryImagePreviewDialog v-model:visible="imagePreviewVisible" :url="imagePreviewUrl" />
|
||||||
<el-button @click="secretDialogVisible = false">取消</el-button>
|
|
||||||
<el-button type="primary" :loading="secretSaving" @click="saveSecretSettings">保存</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
<el-dialog v-model="voiceDialogVisible" title="音色管理" width="920px" class="image-video-secret-dialog voice-dialog"
|
|
||||||
append-to-body>
|
|
||||||
<el-tabs v-model="voiceDialogTab" 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>{{ filteredVoiceListItems.length }}</strong>
|
|
||||||
<span>/ {{ voiceListItems.length }} 个音色</span>
|
|
||||||
</div>
|
|
||||||
<el-input v-model="voiceSearchKeyword" class="voice-search-input" clearable placeholder="搜索音色名称或 voice_id"
|
|
||||||
@keyup.enter="listVoices" @clear="listVoices" />
|
|
||||||
<button type="button" class="script-primary-action-btn" :disabled="voiceLoading" @click="listVoices">
|
|
||||||
刷新音色
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div v-if="filteredVoiceListItems.length" class="voice-list">
|
|
||||||
<div v-for="item in filteredVoiceListItems" :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="useVoice(item)">使用此音色</button>
|
|
||||||
<button v-if="item.sourceKey !== 'system_voice'" type="button"
|
|
||||||
class="script-action-btn script-action-btn--danger" :disabled="voiceLoading"
|
|
||||||
@click="deleteVoice(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="voiceCloneName" clearable placeholder="输入克隆后的音色名称" />
|
|
||||||
</div>
|
|
||||||
<AiAssetDropzone title="克隆素材" description="仅用于音色克隆,不会写入 text_info.file_url。" placeholder="上传音频或视频"
|
|
||||||
helper="支持 MP3 / WAV / MP4,或粘贴素材链接" accept="audio/*,video/*" :file-name="voiceCloneAsset.fileName"
|
|
||||||
:preview-url="voiceCloneAsset.previewUrl" :preview-kind="voiceCloneAsset.previewKind"
|
|
||||||
:source-url="voiceCloneAsset.sourceUrl" :loading="voiceCloneAsset.uploading" allow-url compact
|
|
||||||
action-label="上传克隆素材" selected-label="克隆素材" url-label="克隆素材链接" @select="setVoiceCloneAsset"
|
|
||||||
@url-change="setVoiceCloneUrl" @clear="clearVoiceCloneAsset" />
|
|
||||||
<div class="voice-dialog__toolbar">
|
|
||||||
<button type="button" class="script-primary-action-btn" :disabled="voiceLoading" @click="cloneVoice">
|
|
||||||
开始克隆
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</el-tab-pane>
|
|
||||||
|
|
||||||
</el-tabs>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
<el-dialog v-model="imagePreviewVisible" title="图片预览" width="760px" class="image-preview-dialog" append-to-body>
|
|
||||||
<img v-if="imagePreviewUrl" :src="imagePreviewUrl" class="image-preview-dialog__image" alt="" />
|
|
||||||
</el-dialog>
|
|
||||||
</section>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -500,6 +376,21 @@ import { ElMessage, ElMessageBox } from 'element-plus'
|
|||||||
import AiAssetDropzone from '@/shared/components/ai-workflow/AiAssetDropzone.vue'
|
import AiAssetDropzone from '@/shared/components/ai-workflow/AiAssetDropzone.vue'
|
||||||
import AiChoicePills from '@/shared/components/ai-workflow/AiChoicePills.vue'
|
import AiChoicePills from '@/shared/components/ai-workflow/AiChoicePills.vue'
|
||||||
import AiSectionCard from '@/shared/components/ai-workflow/AiSectionCard.vue'
|
import AiSectionCard from '@/shared/components/ai-workflow/AiSectionCard.vue'
|
||||||
|
import DeliveryVideoSecretDialog from './DeliveryVideoSecretDialog.vue'
|
||||||
|
import DeliveryVideoVoiceDialog from './DeliveryVideoVoiceDialog.vue'
|
||||||
|
import DeliveryVideoResultPanel from './DeliveryVideoResultPanel.vue'
|
||||||
|
import DeliveryImagePreviewDialog from './DeliveryImagePreviewDialog.vue'
|
||||||
|
import type {
|
||||||
|
AssetKey,
|
||||||
|
AssetState,
|
||||||
|
AssemblyState,
|
||||||
|
MediaType,
|
||||||
|
PreviewKind,
|
||||||
|
VoiceListItem,
|
||||||
|
VoiceStatusType,
|
||||||
|
WorkspaceState,
|
||||||
|
WorkspaceTab,
|
||||||
|
} from '@/pages/image-video/delivery-video-workspace-types'
|
||||||
import { saveUrlWithProgress } from '@/shared/utils/download-progress'
|
import { saveUrlWithProgress } from '@/shared/utils/download-progress'
|
||||||
import { createRowId } from '@/shared/utils/row-id'
|
import { createRowId } from '@/shared/utils/row-id'
|
||||||
import { safeHttpUrl } from '@/shared/utils/safe-url'
|
import { safeHttpUrl } from '@/shared/utils/safe-url'
|
||||||
@@ -520,13 +411,6 @@ import {
|
|||||||
} from '@/shared/api/java-modules'
|
} from '@/shared/api/java-modules'
|
||||||
import { isTerminalImageVideoTask } from '@/pages/image-video/delivery-video-task-state'
|
import { isTerminalImageVideoTask } from '@/pages/image-video/delivery-video-task-state'
|
||||||
|
|
||||||
type WorkspaceTab = 'remake' | 'imageToVideo'
|
|
||||||
type PreviewKind = 'image' | 'video' | 'file'
|
|
||||||
type MediaType = 'image' | 'video' | 'audio' | 'file'
|
|
||||||
type AssetKey = 'referenceAsset' | 'sceneAsset' | 'modelAsset' | 'speechAsset'
|
|
||||||
type VoiceMode = 'textOnly' | 'uploadAudio' | 'synthesize'
|
|
||||||
type VoiceStatusType = 'info' | 'success' | 'error'
|
|
||||||
|
|
||||||
const IMAGE_VIDEO_TASK_POLL_DELAY_MS = 5000
|
const IMAGE_VIDEO_TASK_POLL_DELAY_MS = 5000
|
||||||
const IMAGE_VIDEO_TASK_MAX_POLLS = 720
|
const IMAGE_VIDEO_TASK_MAX_POLLS = 720
|
||||||
|
|
||||||
@@ -537,70 +421,6 @@ const IMAGE_VIDEO_TASK_MAX_POLLS = 720
|
|||||||
*/
|
*/
|
||||||
let disposed = false
|
let disposed = false
|
||||||
|
|
||||||
type AssetState = {
|
|
||||||
/** v-for 稳定 key(审查 C6):产品图可删中间行,用 index 当 key 会让上传槽组件实例错位复用 */
|
|
||||||
id: string
|
|
||||||
fileName: string
|
|
||||||
previewUrl: string
|
|
||||||
previewKind: PreviewKind
|
|
||||||
sourceUrl: string
|
|
||||||
mediaType: MediaType
|
|
||||||
uploading: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
type AssemblyState = {
|
|
||||||
loading: boolean
|
|
||||||
resultText: string
|
|
||||||
executeId: string
|
|
||||||
polling: boolean
|
|
||||||
pollCount: number
|
|
||||||
videoUrl: string
|
|
||||||
debugUrl: string
|
|
||||||
downloading: boolean
|
|
||||||
pollTimer: number
|
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
type VoiceListItem = {
|
|
||||||
voiceId: string
|
|
||||||
name: string
|
|
||||||
groupId: string
|
|
||||||
description: string
|
|
||||||
sourceKey: string
|
|
||||||
sourceLabel: string
|
|
||||||
raw: unknown
|
|
||||||
}
|
|
||||||
|
|
||||||
const activeTab = ref<WorkspaceTab>('remake')
|
const activeTab = ref<WorkspaceTab>('remake')
|
||||||
const copyLearningLoading = ref(false)
|
const copyLearningLoading = ref(false)
|
||||||
const voiceLoading = ref(false)
|
const voiceLoading = ref(false)
|
||||||
@@ -2117,335 +1937,6 @@ onBeforeUnmount(() => {
|
|||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
.voice-dialog__tabs {
|
|
||||||
max-height: 62vh;
|
|
||||||
overflow-y: auto;
|
|
||||||
padding-right: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-dialog__tabs :deep(.el-tabs__item:not(.is-active)) {
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-dialog__toolbar {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
gap: 8px;
|
|
||||||
margin: 10px 0 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-dialog__toolbar--list {
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin: 12px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-list-summary {
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: baseline;
|
|
||||||
gap: 4px;
|
|
||||||
min-width: 110px;
|
|
||||||
color: #6f6f6f;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-list-summary strong {
|
|
||||||
color: #b58c51;
|
|
||||||
font-size: 18px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-search-input {
|
|
||||||
flex: 1;
|
|
||||||
min-width: 180px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-list {
|
|
||||||
display: grid;
|
|
||||||
gap: 8px;
|
|
||||||
max-height: 420px;
|
|
||||||
overflow-y: auto;
|
|
||||||
padding-right: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.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 #333;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #171717;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-list__meta {
|
|
||||||
display: grid;
|
|
||||||
gap: 4px;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-list__meta strong {
|
|
||||||
color: #f4f4f4;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-list__meta span {
|
|
||||||
color: #9d9d9d;
|
|
||||||
font-size: 12px;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-list__meta em {
|
|
||||||
color: #777;
|
|
||||||
font-size: 12px;
|
|
||||||
font-style: normal;
|
|
||||||
line-height: 1.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-list__source {
|
|
||||||
padding: 3px 8px;
|
|
||||||
border: 1px solid rgba(181, 140, 81, 0.34);
|
|
||||||
border-radius: 999px;
|
|
||||||
color: #b58c51;
|
|
||||||
font-size: 12px;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.preview-panel__meta {
|
|
||||||
display: grid;
|
|
||||||
gap: 8px;
|
|
||||||
padding: 12px;
|
|
||||||
border: 1px solid #363636;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #141414;
|
|
||||||
}
|
|
||||||
|
|
||||||
.generation-mode-tabs :deep(.el-tabs__header) {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.generation-mode-tabs :deep(.el-tabs__item) {
|
|
||||||
color: #f2f2f2;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
.generation-mode-tabs :deep(.el-tabs__active-bar) {
|
|
||||||
background-color: #b99455;
|
|
||||||
}
|
|
||||||
|
|
||||||
.generation-mode-tabs :deep(.el-tabs__content) {
|
|
||||||
color: #a8a8a8;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.generation-mode-tabs p {
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.preview-row {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
gap: 12px;
|
|
||||||
color: #c8c8c8;
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.preview-row__value {
|
|
||||||
color: #f3f3f3;
|
|
||||||
font-weight: 700;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-result-actions {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: minmax(0, 1fr) auto;
|
|
||||||
gap: 10px;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-result-actions .delivery-primary-btn {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.delivery-secondary-btn {
|
|
||||||
min-height: 36px;
|
|
||||||
border-color: #474747;
|
|
||||||
background: #1a1a1a;
|
|
||||||
color: #f2f2f2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.assembly-waiting {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: auto minmax(0, 1fr);
|
|
||||||
gap: 10px;
|
|
||||||
align-items: center;
|
|
||||||
margin: -2px 0 12px;
|
|
||||||
padding: 10px 12px;
|
|
||||||
border: 1px solid rgba(181, 140, 81, 0.42);
|
|
||||||
border-radius: 8px;
|
|
||||||
background: rgba(181, 140, 81, 0.12);
|
|
||||||
color: #f4d392;
|
|
||||||
}
|
|
||||||
|
|
||||||
.assembly-waiting--done {
|
|
||||||
border-color: rgba(74, 170, 118, 0.45);
|
|
||||||
background: rgba(74, 170, 118, 0.12);
|
|
||||||
color: #b8f0cf;
|
|
||||||
}
|
|
||||||
|
|
||||||
.assembly-waiting__spinner {
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
border: 2px solid rgba(244, 211, 146, 0.28);
|
|
||||||
border-top-color: #f4d392;
|
|
||||||
border-radius: 50%;
|
|
||||||
animation: assembly-spin 0.8s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
.assembly-waiting--done .assembly-waiting__spinner {
|
|
||||||
border-color: rgba(184, 240, 207, 0.45);
|
|
||||||
animation: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.assembly-waiting__content {
|
|
||||||
display: grid;
|
|
||||||
gap: 3px;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.assembly-waiting__content strong {
|
|
||||||
font-size: 13px;
|
|
||||||
line-height: 1.4;
|
|
||||||
}
|
|
||||||
|
|
||||||
.assembly-waiting__content span {
|
|
||||||
color: #cfcfcf;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 1.45;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-result-panel {
|
|
||||||
display: grid;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-result-panel__player,
|
|
||||||
.video-result-panel__empty {
|
|
||||||
width: 100%;
|
|
||||||
min-height: 220px;
|
|
||||||
border: 1px solid #303030;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #0f0f0f;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-result-panel__player video {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
max-height: min(48vh, 520px);
|
|
||||||
background: #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-result-panel__empty {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
padding: 24px;
|
|
||||||
color: #858585;
|
|
||||||
font-size: 13px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-result-panel__link {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: auto minmax(0, 1fr);
|
|
||||||
gap: 10px;
|
|
||||||
align-items: center;
|
|
||||||
padding: 9px 10px;
|
|
||||||
border: 1px solid #333;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #151515;
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-result-panel__link span {
|
|
||||||
color: #9f9f9f;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-result-panel__link a {
|
|
||||||
color: #7eb7ff;
|
|
||||||
text-decoration: none;
|
|
||||||
word-break: break-all;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-result-panel__debug {
|
|
||||||
border: 1px solid #333;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #121212;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-result-panel__debug summary {
|
|
||||||
padding: 10px 12px;
|
|
||||||
color: #b8b8b8;
|
|
||||||
font-size: 12px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.video-result-panel__debug :deep(.el-textarea__inner) {
|
|
||||||
border-width: 1px 0 0;
|
|
||||||
border-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes assembly-spin {
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.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;
|
|
||||||
}
|
|
||||||
|
|
||||||
.image-preview-dialog__image {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
max-height: 72vh;
|
|
||||||
object-fit: contain;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: #101010;
|
|
||||||
}
|
|
||||||
|
|
||||||
:deep(.ai-section-card){
|
:deep(.ai-section-card){
|
||||||
border-color: var(--delivery-border);
|
border-color: var(--delivery-border);
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
@@ -2677,11 +2168,6 @@ onBeforeUnmount(() => {
|
|||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
.voice-dialog__toolbar--list {
|
|
||||||
align-items: stretch;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.voice-inline-actions {
|
.voice-inline-actions {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -4,7 +4,8 @@
|
|||||||
* 异常时客户端立刻弹窗并暂停该账号的新任务;已跑完的任务与结果行不受影响。
|
* 异常时客户端立刻弹窗并暂停该账号的新任务;已跑完的任务与结果行不受影响。
|
||||||
*
|
*
|
||||||
* - 暂停:红色不可忽略横幅 + 首次弹确认框,用户排查后点「继续任务」走 resume;
|
* - 暂停:红色不可忽略横幅 + 首次弹确认框,用户排查后点「继续任务」走 resume;
|
||||||
* - 共用密钥:黄色提示条,只报账号数,不阻断任务;
|
* - 共用密钥:仅代理 IP 密钥共用弹 ElMessage 通知(铃铛有服务端 secret_shared 推送),
|
||||||
|
* LLM 密钥共用可接受、不弹窗;不再常驻界面;
|
||||||
* - 轮询失败保留上一轮状态(与 ProxyBalanceAlert 同口径),不把网络抖动刷成误报。
|
* - 轮询失败保留上一轮状态(与 ProxyBalanceAlert 同口径),不把网络抖动刷成误报。
|
||||||
*/
|
*/
|
||||||
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
||||||
@@ -19,6 +20,7 @@ import { AUTH_TOKEN_KEY } from '@/shared/auth/session-keys'
|
|||||||
import {
|
import {
|
||||||
COST_GUARD_POLL_MS,
|
COST_GUARD_POLL_MS,
|
||||||
pausedPromptKey,
|
pausedPromptKey,
|
||||||
|
proxySharedToastText,
|
||||||
sharedWarningKey,
|
sharedWarningKey,
|
||||||
usageLine,
|
usageLine,
|
||||||
} from '@/shared/utils/cost-guard-alert'
|
} from '@/shared/utils/cost-guard-alert'
|
||||||
@@ -62,10 +64,12 @@ async function refresh(): Promise<void> {
|
|||||||
|
|
||||||
function notifySharedWarnings(warnings: SharedSecretWarning[]): void {
|
function notifySharedWarnings(warnings: SharedSecretWarning[]): void {
|
||||||
for (const warning of warnings) {
|
for (const warning of warnings) {
|
||||||
|
// LLM 密钥共用可接受,不弹窗;只对代理 IP 密钥共用做通知
|
||||||
|
if (warning.type !== 'proxy') continue
|
||||||
const key = sharedWarningKey(warning)
|
const key = sharedWarningKey(warning)
|
||||||
if (warnedSharedKeys.has(key)) continue
|
if (warnedSharedKeys.has(key)) continue
|
||||||
warnedSharedKeys.add(key)
|
warnedSharedKeys.add(key)
|
||||||
ElMessage.warning({ message: warning.message, duration: 8000, showClose: true })
|
ElMessage.warning({ message: proxySharedToastText(warning), duration: 8000, showClose: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,9 +134,8 @@ onBeforeUnmount(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="status?.paused || sharedWarnings.length" class="cost-guard-stack">
|
<div v-if="status?.paused" class="cost-guard-stack">
|
||||||
<div
|
<div
|
||||||
v-if="status?.paused"
|
|
||||||
class="cost-guard-alert cost-guard-alert--paused"
|
class="cost-guard-alert cost-guard-alert--paused"
|
||||||
role="alert"
|
role="alert"
|
||||||
aria-live="assertive"
|
aria-live="assertive"
|
||||||
@@ -150,24 +153,6 @@ onBeforeUnmount(() => {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
|
||||||
v-if="sharedWarnings.length"
|
|
||||||
class="cost-guard-alert cost-guard-alert--shared"
|
|
||||||
role="status"
|
|
||||||
>
|
|
||||||
<div class="cost-guard-alert-icon" aria-hidden="true">i</div>
|
|
||||||
<div class="cost-guard-alert-content">
|
|
||||||
<div class="cost-guard-alert-title">密钥共用提示</div>
|
|
||||||
<div
|
|
||||||
v-for="warning in sharedWarnings"
|
|
||||||
:key="sharedWarningKey(warning)"
|
|
||||||
class="cost-guard-alert-reason"
|
|
||||||
>
|
|
||||||
{{ warning.message }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -202,12 +187,6 @@ onBeforeUnmount(() => {
|
|||||||
color: #7d1d1d;
|
color: #7d1d1d;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cost-guard-alert--shared {
|
|
||||||
border: 1px solid #e0a13c;
|
|
||||||
background: #fff8e8;
|
|
||||||
color: #7a4a06;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cost-guard-alert-icon {
|
.cost-guard-alert-icon {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
width: 22px;
|
width: 22px;
|
||||||
@@ -224,10 +203,6 @@ onBeforeUnmount(() => {
|
|||||||
background: #d64545;
|
background: #d64545;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cost-guard-alert--shared .cost-guard-alert-icon {
|
|
||||||
background: #e0a13c;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cost-guard-alert-content {
|
.cost-guard-alert-content {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|||||||
@@ -27,3 +27,8 @@ export function pausedPromptKey(status: CostGuardStatus | null): string {
|
|||||||
export function sharedWarningKey(warning: SharedSecretWarning): string {
|
export function sharedWarningKey(warning: SharedSecretWarning): string {
|
||||||
return `${warning.type}|${warning.moduleLabel}|${warning.accounts}`
|
return `${warning.type}|${warning.moduleLabel}|${warning.accounts}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 代理 IP 共用弹窗文案:精简口语版,不搬运后端的技术口径。 */
|
||||||
|
export function proxySharedToastText(warning: SharedSecretWarning): string {
|
||||||
|
return `这把代理链接被 ${warning.accounts} 个账号共用,别人用多了你就不够用了。建议在「密钥设置」里配一把自己的。`
|
||||||
|
}
|
||||||
|
|||||||
@@ -74,6 +74,24 @@ test('共享密钥提示按键去重,不按文案去重', async () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('密钥共用提示只走通知,不再常驻界面', () => {
|
||||||
|
assert.ok(component.includes('ElMessage.warning'), '共用密钥提示应通过 ElMessage 通知弹出')
|
||||||
|
assert.ok(!component.includes('cost-guard-alert--shared'), '黄色常驻横幅已下线,样式类不得回流')
|
||||||
|
assert.ok(!component.includes('密钥共用提示'), '界面模板不应再渲染「密钥共用提示」横幅')
|
||||||
|
assert.ok(component.includes("warning.type !== 'proxy'"), 'LLM 密钥共用可接受,弹窗只放行代理 IP 类型')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('代理 IP 共用弹窗是精简口语文案,不搬运后端长口径', async () => {
|
||||||
|
const { proxySharedToastText } = await import('../src/shared/utils/cost-guard-alert.ts')
|
||||||
|
const text = proxySharedToastText({ type: 'proxy', moduleLabel: '代理设置', accounts: 3, threshold: 3, message: 'x' })
|
||||||
|
|
||||||
|
assert.match(text, /被 3 个账号共用/)
|
||||||
|
assert.match(text, /密钥设置/)
|
||||||
|
assert.ok(!text.includes('阈值'), '不应出现「阈值」这类技术词')
|
||||||
|
assert.ok(!text.includes('归因'), '不应出现后端长口径的书面语')
|
||||||
|
assert.ok(component.includes('proxySharedToastText'), '弹窗必须用前端精简文案,而不是后端 message 原文')
|
||||||
|
})
|
||||||
|
|
||||||
test('全局挂载并在暂停时提供「继续任务」', () => {
|
test('全局挂载并在暂停时提供「继续任务」', () => {
|
||||||
assert.ok(app.includes("import CostGuardAlert from '@/shared/components/CostGuardAlert.vue'"))
|
assert.ok(app.includes("import CostGuardAlert from '@/shared/components/CostGuardAlert.vue'"))
|
||||||
assert.ok(app.includes('<CostGuardAlert />'), '组件没挂到 App.vue,异常时界面不会弹')
|
assert.ok(app.includes('<CostGuardAlert />'), '组件没挂到 App.vue,异常时界面不会弹')
|
||||||
|
|||||||
Reference in New Issue
Block a user