perf(代码审查落地): 后端 A1-A8 与前端 C1-C8 加固,retention 清理补索引(V141)
A 组(backend-java): - A1 载荷引用计数不再无条件回落全表 COUNT - A2 结果行读取由 LIMIT 1 改整页 - A3 ziniao 索引缓存过期判断下推 SQL - A4 循环子任务认领改 CAS,失败一律抛 - A5 建单事务里不碰外部 IO - A6 连接池补网络层超时(connectTimeout/socketTimeout,env 可覆盖) - A7 日志留现场 + 异步落盘 - A8 其余:货源图片预取、结果工作簿装配等 - V141:三条 retention DELETE 的可用索引,其中 biz_price_track_loop_run 用 STORED 生成列承载 COALESCE 时间线(该表实测 881 行/17MB,COPY 秒级) C 组(frontend-vue):URL 取值走 safe-url、行号取值走 row-id、 交付视频任务状态抽成 delivery-video-task-state.ts,各补用例。
This commit is contained in:
@@ -153,7 +153,7 @@
|
||||
placeholder="例如:防滑耐磨、复古网面透气设计。" />
|
||||
</div>
|
||||
<div class="product-assets">
|
||||
<AiAssetDropzone v-for="(asset, index) in currentWorkspace.productAssets" :key="index"
|
||||
<AiAssetDropzone v-for="(asset, index) in currentWorkspace.productAssets" :key="asset.id"
|
||||
:title="`产品图 ${index + 1}`" :description="index === 0 ? '最多上传 5 张,提交时按接口数组格式传入。' : ''"
|
||||
placeholder="上传产品图" helper="支持 JPG / PNG" accept="image/*" :file-name="asset.fileName"
|
||||
:preview-url="asset.previewUrl" :preview-kind="asset.previewKind" :source-url="asset.sourceUrl"
|
||||
@@ -213,7 +213,7 @@
|
||||
placeholder="例如:防滑耐磨、复古网面透气设计。" />
|
||||
</div>
|
||||
<div class="product-assets">
|
||||
<AiAssetDropzone v-for="(asset, index) in currentWorkspace.productAssets" :key="index"
|
||||
<AiAssetDropzone v-for="(asset, index) in currentWorkspace.productAssets" :key="asset.id"
|
||||
:title="`产品图 ${index + 1}`" :description="index === 0 ? '最多上传 5 张,提交时按接口数组格式传入。' : ''"
|
||||
placeholder="上传产品图" helper="支持 JPG / PNG" accept="image/*" :file-name="asset.fileName"
|
||||
:preview-url="asset.previewUrl" :preview-kind="asset.previewKind" :source-url="asset.sourceUrl"
|
||||
@@ -371,11 +371,11 @@
|
||||
</div>
|
||||
<div v-if="assemblyVideoUrl" class="video-result-panel__link">
|
||||
<span>视频地址</span>
|
||||
<a :href="assemblyVideoUrl" target="_blank" rel="noreferrer">{{ assemblyVideoUrl }}</a>
|
||||
<a :href="safeHttpUrl(assemblyVideoUrl)" target="_blank" rel="noreferrer">{{ assemblyVideoUrl }}</a>
|
||||
</div>
|
||||
<div v-if="assemblyDebugUrl" class="video-result-panel__link">
|
||||
<span>调试链接</span>
|
||||
<a :href="assemblyDebugUrl" target="_blank" rel="noreferrer">{{ assemblyDebugUrl }}</a>
|
||||
<a :href="safeHttpUrl(assemblyDebugUrl)" target="_blank" rel="noreferrer">{{ assemblyDebugUrl }}</a>
|
||||
</div>
|
||||
<details v-if="assemblyResultText" class="video-result-panel__debug">
|
||||
<summary>查看原始返回</summary>
|
||||
@@ -500,6 +500,8 @@ import AiAssetDropzone from '@/shared/components/ai-workflow/AiAssetDropzone.vue
|
||||
import AiChoicePills from '@/shared/components/ai-workflow/AiChoicePills.vue'
|
||||
import AiSectionCard from '@/shared/components/ai-workflow/AiSectionCard.vue'
|
||||
import { saveUrlWithProgress } from '@/shared/utils/download-progress'
|
||||
import { createRowId } from '@/shared/utils/row-id'
|
||||
import { safeHttpUrl } from '@/shared/utils/safe-url'
|
||||
import {
|
||||
cloneImageVideoVoice,
|
||||
deleteImageVideoVoice,
|
||||
@@ -515,6 +517,7 @@ import {
|
||||
type ImageVideoAsyncTaskVo,
|
||||
type ImageVideoWorkflowParameters,
|
||||
} from '@/shared/api/java-modules'
|
||||
import { isTerminalImageVideoTask } from '@/pages/image-video/delivery-video-task-state'
|
||||
|
||||
type WorkspaceTab = 'remake' | 'imageToVideo'
|
||||
type PreviewKind = 'image' | 'video' | 'file'
|
||||
@@ -534,6 +537,8 @@ const IMAGE_VIDEO_TASK_MAX_POLLS = 720
|
||||
let disposed = false
|
||||
|
||||
type AssetState = {
|
||||
/** v-for 稳定 key(审查 C6):产品图可删中间行,用 index 当 key 会让上传槽组件实例错位复用 */
|
||||
id: string
|
||||
fileName: string
|
||||
previewUrl: string
|
||||
previewKind: PreviewKind
|
||||
@@ -675,6 +680,7 @@ const voiceCloneAsset = reactive<AssetState>(createAssetState())
|
||||
|
||||
function createAssetState(): AssetState {
|
||||
return {
|
||||
id: createRowId('asset'),
|
||||
fileName: '',
|
||||
previewUrl: '',
|
||||
previewKind: 'file',
|
||||
@@ -890,7 +896,8 @@ async function setProductAsset(tab: WorkspaceTab, index: number, file: File) {
|
||||
function clearProductAsset(tab: WorkspaceTab, index: number) {
|
||||
const productAssets = workspaces[tab].productAssets
|
||||
if (productAssets.length === 1) {
|
||||
Object.assign(productAssets[0], createAssetState())
|
||||
// 只剩一行时原地清空:保留 id,避免这一行的 :key 变化导致上传槽组件被重建
|
||||
Object.assign(productAssets[0], createAssetState(), { id: productAssets[0].id })
|
||||
} else {
|
||||
productAssets.splice(index, 1)
|
||||
}
|
||||
@@ -987,25 +994,6 @@ function sleep(milliseconds: number) {
|
||||
return new Promise<void>((resolve) => window.setTimeout(resolve, milliseconds))
|
||||
}
|
||||
|
||||
function normalizeTaskStatus(value: string | undefined) {
|
||||
return (value || '').trim().toUpperCase()
|
||||
}
|
||||
|
||||
function isTerminalCozeStatus(value: string | undefined) {
|
||||
return ['SUCCESS', 'SUCCEEDED', 'COMPLETED', 'DONE', 'FINISHED', 'FAILED', 'FAIL', 'ERROR', 'CANCELED', 'CANCELLED']
|
||||
.includes(normalizeTaskStatus(value))
|
||||
}
|
||||
|
||||
function isRecoverableFailedImageVideoTask(task: ImageVideoAsyncTaskVo) {
|
||||
return task.status === 'FAILED'
|
||||
&& Boolean(task.cozeExecuteId)
|
||||
&& !isTerminalCozeStatus(task.cozeStatus)
|
||||
}
|
||||
|
||||
function isTerminalImageVideoTask(task: ImageVideoAsyncTaskVo) {
|
||||
return task.status === 'SUCCESS' || (task.status === 'FAILED' && !isRecoverableFailedImageVideoTask(task))
|
||||
}
|
||||
|
||||
async function waitForImageVideoTask(ticket: ImageVideoAsyncTaskVo): Promise<unknown> {
|
||||
let task = ticket
|
||||
for (let pollCount = 0; pollCount < IMAGE_VIDEO_TASK_MAX_POLLS; pollCount += 1) {
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 交付视频工作流的任务终态判定(从 DeliveryVideoWorkspace.vue 抽出)。
|
||||
*
|
||||
* 单独成模块的理由:这组谓词决定「失败任务要不要继续轮询、什么时候算真失败」,
|
||||
* 判错的后果是把没跑完的任务当完成回传(本项目在外观专利/跟价上吃过同一类亏)。
|
||||
* 留在 2700 行的单文件组件里就没法单测,抽出来才有断言可写。
|
||||
*/
|
||||
import type { ImageVideoAsyncTaskVo } from '@/shared/api/java-modules'
|
||||
|
||||
/** Coze 侧已经不会再变化的状态:命中即代表本地没必要继续等远端回执 */
|
||||
const TERMINAL_COZE_STATUSES = [
|
||||
'SUCCESS', 'SUCCEEDED', 'COMPLETED', 'DONE', 'FINISHED',
|
||||
'FAILED', 'FAIL', 'ERROR', 'CANCELED', 'CANCELLED',
|
||||
]
|
||||
|
||||
export function normalizeTaskStatus(value: string | undefined): string {
|
||||
return (value || '').trim().toUpperCase()
|
||||
}
|
||||
|
||||
export function isTerminalCozeStatus(value: string | undefined): boolean {
|
||||
return TERMINAL_COZE_STATUSES.includes(normalizeTaskStatus(value))
|
||||
}
|
||||
|
||||
/**
|
||||
* 「本地记为失败、但远端还在跑」的可恢复单:
|
||||
* 有 cozeExecuteId 且远端状态未终态 → 继续轮询,不向用户报失败。
|
||||
*/
|
||||
export function isRecoverableFailedImageVideoTask(task: ImageVideoAsyncTaskVo): boolean {
|
||||
return task.status === 'FAILED'
|
||||
&& Boolean(task.cozeExecuteId)
|
||||
&& !isTerminalCozeStatus(task.cozeStatus)
|
||||
}
|
||||
|
||||
/** 终态:成功,或「失败且不可恢复」。 */
|
||||
export function isTerminalImageVideoTask(task: ImageVideoAsyncTaskVo): boolean {
|
||||
return task.status === 'SUCCESS' || (task.status === 'FAILED' && !isRecoverableFailedImageVideoTask(task))
|
||||
}
|
||||
Reference in New Issue
Block a user