|
|
@@ -77,64 +77,43 @@ export default function MaterialRecallTab() {
|
|
|
message.warning('请输入素材ID')
|
|
|
return
|
|
|
}
|
|
|
- // 空选 = 全部维度; 否则用户显式勾选的子集
|
|
|
- const codes =
|
|
|
- selectedCodes.length === 0 ? listAllConfigCodes(configCodes) : selectedCodes
|
|
|
- if (codes.length === 0) {
|
|
|
- message.warning('维度字典尚未加载完成, 请稍后再试')
|
|
|
- return
|
|
|
- }
|
|
|
|
|
|
- const myGen = ++submitGenRef.current
|
|
|
- const isStale = () => myGen !== submitGenRef.current
|
|
|
- setLoading(true)
|
|
|
+ // matchByMaterialId 为单次调用 (spec 约束), configCode 选填:
|
|
|
+ // 空选 → 不传, 后端走全部维度; 单选 → 传具体维度; 多选 → 传 ALL 走全部
|
|
|
+ const configCodeParam =
|
|
|
+ selectedCodes.length === 1
|
|
|
+ ? selectedCodes[0]
|
|
|
+ : selectedCodes.length > 1
|
|
|
+ ? ALL_CONFIG_CODE
|
|
|
+ : undefined
|
|
|
|
|
|
let dimensionLabel: string
|
|
|
if (selectedCodes.length === 0) {
|
|
|
- dimensionLabel = `全部 (${codes.length} 个维度)`
|
|
|
- } else if (codes.length === 1) {
|
|
|
- dimensionLabel = getConfigDisplayLabel(codes[0], configCodes)
|
|
|
+ const allCodes = listAllConfigCodes(configCodes)
|
|
|
+ dimensionLabel = `全部 (${allCodes.length} 个维度)`
|
|
|
+ } else if (selectedCodes.length === 1) {
|
|
|
+ dimensionLabel = getConfigDisplayLabel(selectedCodes[0], configCodes)
|
|
|
} else {
|
|
|
- dimensionLabel = `${codes.map((c) => getConfigDisplayLabel(c, configCodes)).join(' / ')} (${codes.length} 个维度)`
|
|
|
+ dimensionLabel = `${selectedCodes.map((c) => getConfigDisplayLabel(c, configCodes)).join(' / ')} (${selectedCodes.length} 个维度)`
|
|
|
}
|
|
|
setResultMeta({
|
|
|
dimensionLabel,
|
|
|
- dimensionCode: codes.length === 1 ? codes[0] : ALL_CONFIG_CODE,
|
|
|
+ dimensionCode: selectedCodes.length === 1 ? selectedCodes[0] : ALL_CONFIG_CODE,
|
|
|
description: `基于素材 "${id}"`,
|
|
|
})
|
|
|
|
|
|
+ const myGen = ++submitGenRef.current
|
|
|
+ const isStale = () => myGen !== submitGenRef.current
|
|
|
+ setLoading(true)
|
|
|
+
|
|
|
try {
|
|
|
- const settled = await Promise.allSettled(
|
|
|
- codes.map((code) =>
|
|
|
- matchByMaterialId({ materialId: id, configCode: code, topN }),
|
|
|
- ),
|
|
|
- )
|
|
|
+ const data = await matchByMaterialId({ materialId: id, configCode: configCodeParam, topN })
|
|
|
if (isStale()) return
|
|
|
- const failedDims: string[] = []
|
|
|
- const merged: RecallResultVO = {
|
|
|
- items: [],
|
|
|
- videoCount: 0,
|
|
|
- materialCount: 0,
|
|
|
- articleCount: 0,
|
|
|
- total: 0,
|
|
|
- }
|
|
|
- settled.forEach((s, i) => {
|
|
|
- if (s.status === 'fulfilled') {
|
|
|
- merged.items.push(...s.value.items)
|
|
|
- } else {
|
|
|
- failedDims.push(getConfigDisplayLabel(codes[i], configCodes))
|
|
|
- }
|
|
|
- })
|
|
|
- merged.items.sort((a, b) => (b.score ?? -Infinity) - (a.score ?? -Infinity))
|
|
|
- merged.videoCount = merged.items.filter((x) => x.modality === 'VIDEO').length
|
|
|
- merged.materialCount = merged.items.filter((x) => x.modality === 'MATERIAL').length
|
|
|
- merged.articleCount = merged.items.filter((x) => x.modality === 'ARTICLE').length
|
|
|
- merged.total = merged.items.length
|
|
|
- setResult(merged)
|
|
|
- if (failedDims.length > 0) {
|
|
|
- message.warning(`部分维度召回失败: ${failedDims.join(', ')} — 已展示其余维度结果`)
|
|
|
+ setResult(data)
|
|
|
+ if (data.total === 0) {
|
|
|
+ message.info('无召回结果')
|
|
|
} else {
|
|
|
- message.success(`召回完成, 共 ${merged.total} 条`)
|
|
|
+ message.success(`召回完成, 共 ${data.total} 条`)
|
|
|
}
|
|
|
} catch {
|
|
|
if (!isStale()) message.error('召回失败')
|