fix(pipeline): 提取闸门按「是否走过正式提取步」显隐,而非 script_entities 存在性
脚本生成期有时也会吐 entities(就是那个不稳的旧来源),若按 script_entities 存在性判断, 闸门会被误隐藏、用户看不到三按钮。改为提取步落库时打 metadata.entities_extracted 标记, 前端据此显隐:没走过正式提取 → 盖蒙版露三按钮;走过 → 露卡片。「重新提取」按钮在有实体或 有资产时显示(老项目也能重提)。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
de29449a76
commit
69163a8f7f
@@ -386,6 +386,12 @@ def extract_entities_for_project(*, project, user) -> dict:
|
|||||||
from apps.ai.script_agent import _map_entities_to_project_metadata
|
from apps.ai.script_agent import _map_entities_to_project_metadata
|
||||||
|
|
||||||
_map_entities_to_project_metadata(project, entities)
|
_map_entities_to_project_metadata(project, entities)
|
||||||
|
# 标记「已走过正式提取步」:脚本生成期也可能吐过 entities(不稳的旧来源),不算正式提取;
|
||||||
|
# 前端资产页提取闸门据此标记显隐(没走过 → 盖蒙版露三按钮;走过 → 露卡片)。
|
||||||
|
md_flag = dict(project.metadata or {})
|
||||||
|
md_flag["entities_extracted"] = True
|
||||||
|
project.metadata = md_flag
|
||||||
|
project.save(update_fields=["metadata", "updated_at"])
|
||||||
refs_by_index = {r["index"]: r["entity_refs"] for r in seg_refs}
|
refs_by_index = {r["index"]: r["entity_refs"] for r in seg_refs}
|
||||||
for i, seg in enumerate(segments):
|
for i, seg in enumerate(segments):
|
||||||
new_refs = refs_by_index.get(i, [])
|
new_refs = refs_by_index.get(i, [])
|
||||||
|
|||||||
@@ -2525,11 +2525,11 @@ export function PipelinePage(props: {
|
|||||||
|| assetUrl(productCover); // 商品卡显示商品主图,三视图在右侧面板
|
|| assetUrl(productCover); // 商品卡显示商品主图,三视图在右侧面板
|
||||||
const triViewGen = `${productName} 商品三视图,从左到右:正面 / 侧面 / 背面,统一光照,白色背景,16:9`;
|
const triViewGen = `${productName} 商品三视图,从左到右:正面 / 侧面 / 背面,统一光照,白色背景,16:9`;
|
||||||
const runProductTri = () => { setTriPanelOpen(true); setTriPreviewId(null); void genBaseAsset("product", triViewGen, undefined, "tri:product"); };
|
const runProductTri = () => { setTriPanelOpen(true); setTriPreviewId(null); void genBaseAsset("product", triViewGen, undefined, "tri:product"); };
|
||||||
// 实体提取闸门:进资产趴还没提取(无 script_entities)且没生成任何基础资产 → 盖蒙版 + 三按钮,不自动花钱
|
// 实体提取闸门:没走过正式提取步(entities_extracted)且没生成任何基础资产 → 盖蒙版 + 三按钮,不自动花钱。
|
||||||
const seList = project.metadata?.script_entities;
|
// 用 entities_extracted 标记而非 script_entities 存在性:脚本生成期也可能吐过不稳的 entities,那不算正式提取。
|
||||||
const extracted = Array.isArray(seList) && seList.length > 0;
|
const entitiesExtracted = project.metadata?.entities_extracted === true;
|
||||||
const hasAnyAsset = KIND_ORDER.some((k) => groupsByKind(k).length > 0);
|
const hasAnyAsset = KIND_ORDER.some((k) => groupsByKind(k).length > 0);
|
||||||
const gateVisible = extractState === "running" || (!extracted && !hasAnyAsset);
|
const gateVisible = extractState === "running" || (!entitiesExtracted && !hasAnyAsset);
|
||||||
return (
|
return (
|
||||||
<section className="stage active" data-stage-pane="2">
|
<section className="stage active" data-stage-pane="2">
|
||||||
{gateVisible && (
|
{gateVisible && (
|
||||||
@@ -2587,7 +2587,7 @@ export function PipelinePage(props: {
|
|||||||
<strong className="mono">// 人物 +¥0.20/张</strong>
|
<strong className="mono">// 人物 +¥0.20/张</strong>
|
||||||
<strong className="mono">// 场景 +¥0.15/张</strong>
|
<strong className="mono">// 场景 +¥0.15/张</strong>
|
||||||
<span style={{ color: "var(--black-alpha-48)" }}>商品图无成本(直接复用商品库)</span>
|
<span style={{ color: "var(--black-alpha-48)" }}>商品图无成本(直接复用商品库)</span>
|
||||||
{extracted && (
|
{(entitiesExtracted || hasAnyAsset) && (
|
||||||
<button type="button" className="btn btn-ghost btn-sm eg-reextract" disabled={extractState === "running"} data-stop onClick={() => void runExtract("only")}>
|
<button type="button" className="btn btn-ghost btn-sm eg-reextract" disabled={extractState === "running"} data-stop onClick={() => void runExtract("only")}>
|
||||||
{extractState === "running" ? "提取中…" : "重新提取角色 / 场景"}
|
{extractState === "running" ? "提取中…" : "重新提取角色 / 场景"}
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -241,6 +241,8 @@ export type Project = {
|
|||||||
scene_prompts?: Record<string, string>;
|
scene_prompts?: Record<string, string>;
|
||||||
// 提取步产出:角色/场景实体全量(含 id/ref_index);下游故事板/视频按每镜 entity_refs 取参考图
|
// 提取步产出:角色/场景实体全量(含 id/ref_index);下游故事板/视频按每镜 entity_refs 取参考图
|
||||||
script_entities?: Array<{ id: string; type: string; name: string; visual_prompt?: string; ref_index?: number }>;
|
script_entities?: Array<{ id: string; type: string; name: string; visual_prompt?: string; ref_index?: number }>;
|
||||||
|
// 是否走过正式提取步(资产页提取闸门据此显隐;脚本生成期吐的不稳 entities 不算)
|
||||||
|
entities_extracted?: boolean;
|
||||||
} & Record<string, unknown>;
|
} & Record<string, unknown>;
|
||||||
created_at: string;
|
created_at: string;
|
||||||
updated_at: string;
|
updated_at: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user