feat(short-drama-agent-front): 接入分阶段镜头生产与摄影修订
This commit is contained in:
1 parent
1e9ef33d1d
commit
87427d9d43
29 files changed
+2787
-136
No files matched your search
@@ -1,5 +1,13 @@
|
||||
# 接口数据同步说明
|
||||
|
||||
## 2026-11-15 V8-9.1 / V8-9.2 分阶段镜头生产
|
||||
|
||||
已在根目录 dev 增量接入正式 shotIds 定向摄影/画面状态、逐镜复用、派生批次停止、原 executionId 刷新恢复观察、独立摄影免费预检与版本绑定采用、原失败及零模型请求恢复展示,以及所选范围的参考素材/计划/资产缺口。默认 force=false、concurrency=1、maxRepairAttempts=0,不自动开始下一阶段或重发未知请求。
|
||||
|
||||
继续使用原分镜目录、摄影抽屉、工作流观察、统一 HTTP 错误和首帧授权/Preview 流程。正式四镜已完成摄影和画面状态,默认不重复生成。当前项目级生产仍受真实 needs_review 门禁限制,局部完成不改写全项目结论。
|
||||
|
||||
逐文件职责、真实免费 API 结果、Mock/Chrome 验收、正式使用条件与接口局限见 [本轮完整交接](audits/v8-9-staged-production-2026-11-15.md)。只修改前端,未执行真实付费或正式业务写入;实现验收后用户已授权提交并推送 dev,Git 结果以仓库记录为准。
|
||||
|
||||
## 2026-11-01 图片预览、质量门禁与派生任务
|
||||
|
||||
本次只接入后端根目录 `dev` 的正式 `/api` 路由,依据 `subject-form.routes.ts`、`subject-identity.routes.ts`、`production.routes.ts`、`storyboard.routes.ts` 及相应 Service 核对。未接入 3413 隔离验收服务、脚本、测试专用路由或测试页面;测试夹具只用于 Vitest。
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
# V8-9.1 / V8-9.2 前端接入交接
|
||||
|
||||
## 范围与基线
|
||||
|
||||
- 前端根目录 `dev`,基线 `1e9ef33d1d3a78766c08933a97f1b2f7c1faecd0`。开始时工作区干净。本轮只修改前端,未创建工作树。实现验收时未提交;随后用户明确授权检查完整 Diff、提交并推送 dev,Git 结果以仓库记录为准,不合并发布分支。
|
||||
- 已核对后端根目录 `dev@c6f03454ed98e843a6f4ce3548bb1fbd9154bc18` 的 AGENTS、活跃计划、交接、Storyboard / Workflow 公开文档、两份前端 Prompt,以及正式路由、摄影 Schema、采用服务、派生新鲜度和生产准备服务。
|
||||
- 正式项目 `cmw02vpwi000005axrdtus3pa`。所有收费生成、摄影采用、停止和并发写入测试均使用 Mock;正式项目只做免费读取、生产计划和首帧 Preview。没有覆盖正式结果、修改主体绑定或调用文本、图片、Vision、视频、Repair、Primary。
|
||||
|
||||
## 已交付行为
|
||||
|
||||
1. 复用分镜工作台的 Episode / Beat / Shot 目录,增加单镜及段落勾选。默认“所选镜头”、`concurrency=1`、`force=false`、`maxRepairAttempts=0`。当前集及全项目仍保留原批量语义,省略 `shotIds`。
|
||||
2. 显示正式摄影、画面状态、任务运行/停止/失败及未知请求。有效结果全部具备时不重复 POST;混合范围完整传递正式镜头,后端逐镜复用。空、重复、跨集范围不能提交。HTTP 错误、空响应、字段缺失和合法空目录分别处理。
|
||||
3. 画面状态必须等本次范围摄影有效后由用户单独发起,提交前重新读取正式确认、摄影和准备情况。`force=true` 明示下游失效及独立文本费用;同数量不同镜头、参数和范围变化会撤销原确认。
|
||||
4. 沿用项目级发现、原 executionId、免费 GET / SSE 和活动任务锁。增加两类派生任务停止入口。停止后使用“已停止”,保留费用和在途结果。相同终态允许接受更晚的回执,拒绝重新激活和重复相同记录;未知领取即使 force 也不能重发。提交连接中断时持久保留待核对范围,只提供免费核对原提交。
|
||||
5. 在原“摄影草案与审核”全屏抽屉内,已有摄影且无画面状态时使用独立摄影阶段。复用构图/机位编辑字段,保留其余真实摄影枚举及意图。免费预检携带原 id、ISO 时间、rawJson(含 null)和正式 shotFingerprint;采用冻结同一请求并加入 sourceFingerprint。`changed=false` 的预检仍可采用;幂等回执可接受。409 保留输入、撤销预检并要求显式重读,不自动覆盖。已有下游仍由原组合草案与服务端即时保护处理。
|
||||
6. 画面状态免费恢复显示原执行、新执行、零模型请求和原失败历史。`received` 仅表示收到模型结果,不能证明可信回执或业务通过。普通页面没有 trace / 请求指纹输入,没有自动恢复或重试按钮;管理核查与原收费失败保持独立。
|
||||
7. 免费核对所选镜头参考素材、正式项目入口、分阶段门禁和逐镜首帧/视频描述/视频缺口。先显示参考,再顺序读取完整计划与资产状态,避免重查询争抢;计划及状态可取消,读取上限为 120 秒。局部就绪不改变全项目生产门禁。
|
||||
8. 完整项目上游复检受限时,可凭真实正式确认归属和非零镜头数进入分镜核对;完整生产和素材入口仍保留原门禁。图片授权、OpenAI 选择、原首帧 Preview 指纹、独立 Vision 与 Primary 流程沿用。首帧摄影摘要只展示摄影字段,不混入原文和内部版本。
|
||||
|
||||
## 复用组件及链路
|
||||
|
||||
保留 `StoryboardPage`、`BeatShotDirectory`、`DirectoryItem`、`ShotDerivedReview`、`ShotDesign`、`WorkspacePage`、`WorkspaceTools`、`AppDrawer`、`AppDialog`、`AppForm`、`WorkspaceSectionHeading`、`WorkspaceActionTooltip`、`ConfirmAction`、`WorkflowExecutionPanel`、`useWorkflowExecution`、`useQuery`、`runOperation`、`useActionMessage` 与统一 HTTP 错误处理。没有另建分镜页面、任务中心、API 服务或第二套主体归属规则。
|
||||
|
||||
构图和机位字段抽为 `DirectionCameraFields`,独立阶段与原组合修订共用。原组合草案、场景沿用、视线修订、保存草案及正式首帧候选流程保留。
|
||||
|
||||
## 真实 API 核对结果
|
||||
|
||||
以下均在 2026-11-15 本地正式 `localhost:3412/api` 核对,未做正式写入:
|
||||
|
||||
| 接口 | 结果 |
|
||||
| --- | --- |
|
||||
| GET Storyboard quality-confirmation(原别名及 `/storyboard/quality-confirmation`) | 200,valid=true,正式 60 镜,确认与证据指纹一致 |
|
||||
| GET storyboard-directions / storyboard-visual-states,episodeNo=1 | 各 200,本集 7/17,staleCount=0;全项目各 7/60 |
|
||||
| GET production/entry-readiness | 200,ready=false;当前原因为正式分镜复检 needs_review,不能当作全项目可生产 |
|
||||
| POST production/plan `{}` | 200,约 19.25 秒,canStart=false,分阶段门禁保持真实阻断 |
|
||||
| GET production/status | 200,约 16.27 秒,completed=false,stage=subject_images |
|
||||
| GET image-authorizations | 200,有 1 条授权,billingBlocked=false;未修改授权额度和范围 |
|
||||
| GET 四镜 references | 200,缺失引用为空;普通引用数量为 3/3/4/5,不等同最终模型参考职责数 |
|
||||
| POST 四镜 keyframe/preview `{provider:'openai-image'}` | 均 200,返回正式指纹,blocking=false;最终实际参考数量 3/4/5/6 |
|
||||
| GET 最新画面状态 Workflow 及其 recoveryOf 原任务 | 新任务 completed、recovered=true、actualModelRequests=0;原任务仍 failed,历史保留 |
|
||||
|
||||
生成、停止和采用的正式路由/Schema已核对,写操作成功、失败与并发边界由隔离 Mock 验证。本轮未为验收在正式项目执行任何此类写操作。普通 UI 不开放管理用 SDK 回执恢复参数。
|
||||
|
||||
## 素材导航禁用原因补充核查
|
||||
|
||||
用户截图中的“视觉风格、主体身份、形态图片”禁用来自正式 `stage-readiness.preparation.ready=false`,不是这三项自身数据丢失。实际 `visualStyle.ready=true`、`identity.ready=true`;正式质量确认 valid=true,结构检查、来源审计和动作审计均通过。
|
||||
|
||||
免费质量预检具体返回第 1 集 Beat 3 的 3.1~3.4 共 4 项 `missing_subject_reference`:VisualState 出现“金属搭扣”,但没有绑定独立 `@PR0003`。当前状态为 needs_review、preflightEligible=false,再经 checkCurrent → stage-readiness → 前端三个素材入口共同禁用。
|
||||
|
||||
已只读定位后端不一致:`storyboard-visual-state.service.ts` 的生成/恢复校验使用 `isBoundAttachedPropPartMention` 判定已绑定母件的连接部件;`storyboard-subject-coverage-audit.service.ts` 在 VisualState 分支直接调用普通 findMissing 并写入问题,没有经过相同归属过滤。因此四镜正式 VS 已免费恢复保存、单镜 Preview 通过,但项目复检仍出现同类误报。此前后端交接所述“覆盖审计共用部件规则”在此分支未完整落实,必须以当前代码与真实接口为准。
|
||||
|
||||
建议后端复用正式母件/Form/字段归属规则修复原覆盖审计,并覆盖完整 preflight、checkCurrent、stage-readiness、production/entry-readiness 链路。前端本轮不绕过门禁、不新增独立搭扣、不重生成四镜,不改写已通过数据;后端仓库未修改。
|
||||
|
||||
## 自动化与 Chrome 验收
|
||||
|
||||
- Vitest 集中回归:30 套、243 项通过,涵盖分镜、制作前审核、工作流、项目访问、原首帧、授权和预览。新增定向用例 19 项,覆盖范围/复用/顺序/force/断线持久保护/停止及在途回执/摄影预检采用/并发/原失败与免费恢复。相关复验 9 套、153 项通过,含免费准备失败/取消及同数量不同范围撤销确认;随后补充原组合摄影完整预览采用回归,新增定向套最终 19 项全部通过。其余未变更用例复用此前通过结果。
|
||||
- 本次 Git 检查另执行完整 Vitest:113 套、873 项通过,无真实模型调用。
|
||||
- TypeScript、改动范围 Oxlint、Vue ESLint、定向格式与 `git diff --check` 均通过。Vite production build 通过;测试页面不进入正式构建入口。
|
||||
- 本机 pnpm 的版本管理拉取返回 fetch failed,因此直接运行项目现有 node_modules/.bin 下同名工具完成上述脚本对应检查,没有安装或升级依赖。
|
||||
- 复用本地 Chrome 标签页,全部使用 localhost,未使用 Playwright。正式项目核对四镜 4/4 可复用、默认生成禁用、全项目与局部门禁区分、真实逐镜参考和阶段缺口、免费恢复与原失败并存。覆盖确认只打开查看并取消,恢复 force=false,未提交。
|
||||
- `tests/browser/staged-production.html` 全量拦截请求,未知接口 403,不连接正式服务。桌面完成摄影编辑→免费预检→人工确认→采用并刷新;停止批次→查看“已停止”→免费刷新收到在途结果;均显示真实模型请求 0。
|
||||
- 手机宽度 390px(约 650 / 905px 高度)检查目录、字段间距、24 行长内容输入、局部滚动、固定标题和底栏、关闭及采用按钮。任务状态和辅助按钮正常换行,不横向挤出。普通、键盘焦点及禁用状态沿用主题中性底面。
|
||||
- 当前用户主题主色为蓝色,沿用其已有偏好;主操作仍使用统一 primary,默认主题为绿色。
|
||||
|
||||
## 文件与职责
|
||||
|
||||
| 状态 | 文件 | 职责 |
|
||||
| --- | --- | --- |
|
||||
| 新增 | src/features/storyboard/staged-derived.ts | 正式范围、来源状态、任务范围及未知领取保护 |
|
||||
| 新增 | src/features/storyboard/components/DirectionCameraFields.vue | 独立与组合摄影共享构图、机位编辑及间距 |
|
||||
| 新增 | src/features/storyboard/components/DirectionStageReview.vue | 独立摄影来源读取、免费预检、版本绑定采用与冲突 |
|
||||
| 新增 | src/features/storyboard/components/StagedShotPreparation.vue | 所选参考、项目阶段计划和逐镜缺口读取 |
|
||||
| 新增 | tests/features/storyboard/staged-derived.test.ts | 19 项定向流程、费用和历史边界回归 |
|
||||
| 新增 | tests/browser/staged-production.html | 本地 Chrome 隔离验收入口 |
|
||||
| 新增 | tests/browser/staged-production.ts | 全请求 Mock 与真实组件场景 |
|
||||
| 新增 | docs/audits/v8-9-staged-production-2026-11-15.md | 本轮范围、API、验证、文件职责及交接 |
|
||||
| 修改 | src/features/storyboard/StoryboardPage.vue | 原目录多选、范围/费用确认、准备摘要与停止入口 |
|
||||
| 修改 | src/features/storyboard/useStoryboard.ts | 定向生成编排、有效结果复用、原任务及未知提交保护 |
|
||||
| 修改 | src/features/storyboard/types.ts | 正式摄影原版本和可选 shotIds |
|
||||
| 修改 | src/features/storyboard/components/BeatShotDirectory.vue | 原目录增加镜头、段落多选和窄屏布局 |
|
||||
| 修改 | src/features/storyboard/components/ShotDerivedReview.vue | 原抽屉接入独立摄影,保留组合草案,共用字段 |
|
||||
| 修改 | src/features/storyboard/derived-review-api.ts | 原 confirm 路由的 phase=direction 模式 |
|
||||
| 修改 | src/features/storyboard/derived-review.types.ts | 独立摄影请求、预检和幂等回执契约 |
|
||||
| 修改 | src/features/workflows/execution-api.ts | 原任务 stop 请求,绑定 projectId |
|
||||
| 修改 | src/features/workflows/execution.ts | 停止状态、原回执更新、任务恢复观察及防回退 |
|
||||
| 修改 | src/features/workflows/WorkflowExecutionPanel.vue | 停止/领取/恢复/原失败、位置问题及高级详情 |
|
||||
| 修改 | src/features/workflows/ConfirmAction.vue | 同数量不同输入或范围改变时撤销费用确认 |
|
||||
| 修改 | src/features/storyboard-preparation/types.ts | 正式入口中的阶段与逐镜缺口字段 |
|
||||
| 修改 | src/features/production/types.ts | 正式项目分阶段准备契约 |
|
||||
| 修改 | src/features/production/api.ts | 完整计划、状态读取的可取消耗时边界 |
|
||||
| 修改 | src/features/production/components/KeyframeDialog.vue | 摄影摘要排除内部记录元数据,保留原生图流程 |
|
||||
| 修改 | src/features/projects/ProjectLayout.vue | 正式镜头只读发现,不修改项目质量或生产结论 |
|
||||
| 修改 | src/features/projects/useProjectStageAccess.ts | 只读分镜与完整生产入口分离 |
|
||||
| 修改 | src/lib/user-facing-text.ts | 七类来源、范围及未知请求业务错误中文 |
|
||||
| 修改 | tests/features/projects/access.test.ts | 正式分镜可读、完整生产仍受限 |
|
||||
| 修改 | tests/features/workflows/pages.test.ts | 原批量操作明确选择范围,更新默认参数及状态回归 |
|
||||
| 修改 | docs/api-contract-sync.md | 更新现有前端交接索引 |
|
||||
|
||||
删除 0。保留原后端门禁、原组合修订、图片授权、首帧/审核/Primary 与任务发现;强化原范围、版本、停止及请求未知保护。没有重复实现或待迁移的旧主流程。
|
||||
|
||||
## 正式使用与边界
|
||||
|
||||
可以在现有分镜工作台选择镜头、核对准备情况,默认复用有效成果;满足真实来源和费用条件后,由用户主动分别启动摄影或画面状态。独立摄影仅适用于尚无下游的真实镜头,最终以服务端预检与事务保护为准。正式四镜已有画面状态,因此应沿原组合摄影修订,不走独立阶段。
|
||||
|
||||
当前正式项目完整生产仍被服务端 needs_review 阻断。局部首帧 Preview 通过不能解除它,也不代表图片或视觉审核已经完成。后续由用户主动进入原首帧入口选择 openai-image,重新核对来源、参考图、授权额度及未知费用后生成候选;不自动切换供应方或启动后续流程。
|
||||
|
||||
接口局限:当服务只返回整集 staleCount 而没有逐镜 derivedAssetShotGaps 时,无法可靠定位具体过期镜头。此时已有记录标记“需核对来源”,不猜测过期位置,也不放行依赖未知摄影的画面状态。普通 UI 不提供缺少可信回执时的自动恢复。
|
||||
|
||||
未执行真实收费或正式写入验收,属于本轮明确禁止项;这部分通过 Mock 覆盖。没有其它主动省略的前端目标。
|
||||
@@ -68,6 +68,8 @@ export const productionApi = {
|
||||
plan: (projectId: string, signal?: AbortSignal, input: ProductionPlanInput = {}) =>
|
||||
request<ProductionPlanResponse>(`${projectPath(projectId)}/production/plan`, {
|
||||
method: 'POST',
|
||||
// 完整项目计划可能耗时,仍可通过信号取消,不重发 POST。
|
||||
timeoutMs: 120_000,
|
||||
// 计划携带与当前准备范围一致的阶段,不创建任务。
|
||||
body: {
|
||||
stage: input.stage,
|
||||
@@ -79,7 +81,7 @@ export const productionApi = {
|
||||
}),
|
||||
/** 读取真实主资产完成状态,不能用任务提交回执代替。 */
|
||||
status: (projectId: string, signal?: AbortSignal) =>
|
||||
request<ProjectProductionStatus>(`${projectPath(projectId)}/production/status`, { signal }),
|
||||
request<ProjectProductionStatus>(`${projectPath(projectId)}/production/status`, { signal, timeoutMs: 120_000 }),
|
||||
/**
|
||||
* 启动有限范围的串联生产,最终结果通过任务查询取得。
|
||||
* @param projectId 正式项目 ID
|
||||
|
||||
@@ -46,7 +46,19 @@ const formRef = ref<InstanceType<typeof AppForm> | null>(null)
|
||||
const directionSummary = computed(() =>
|
||||
props.direction
|
||||
? Object.entries(props.direction)
|
||||
.filter(([, value]) => value)
|
||||
.filter(
|
||||
([field, value]) =>
|
||||
[
|
||||
'shotSize',
|
||||
'cameraAngle',
|
||||
'cameraMovement',
|
||||
'composition',
|
||||
'cameraPosition',
|
||||
'lensIntent',
|
||||
'depthOfField',
|
||||
'visualIntent'
|
||||
].includes(field) && value
|
||||
)
|
||||
.map(([field, value]) => directionLabel(value, field))
|
||||
.join(' · ')
|
||||
: ''
|
||||
|
||||
@@ -562,8 +562,23 @@ export interface ProductionPlanStage {
|
||||
manualBlocked: number
|
||||
}
|
||||
|
||||
/** 服务端计算的项目分阶段门禁,不能由局部结果推断。 */
|
||||
export interface ProductionStageReadiness {
|
||||
/** 参考素材阶段。 */ referenceImages: {
|
||||
/** 当前门禁。 */ status: 'ready' | 'blocked'
|
||||
/** 真实原因。 */ reason: string | null
|
||||
}
|
||||
/** 首帧阶段。 */ keyframes: {
|
||||
/** 当前门禁。 */ status: 'ready' | 'blocked'
|
||||
/** 真实原因。 */ reason: string | null
|
||||
}
|
||||
/** 视频阶段。 */ videos: { /** 当前门禁。 */ status: 'ready' | 'blocked'; /** 真实原因。 */ reason: string | null }
|
||||
}
|
||||
|
||||
/** 后端执行计划只读取资产,不触发模型生成。 */
|
||||
export interface ProductionPlan {
|
||||
/** 免费计划返回的分阶段准备状态。 */
|
||||
stageReadiness?: ProductionStageReadiness
|
||||
/** 项目配置就绪状态;兼容尚未返回此字段的服务版本。 */
|
||||
configuration?: {
|
||||
/** 当前配置可用于制作计划。 */
|
||||
@@ -613,6 +628,8 @@ export interface ProductionPlan {
|
||||
|
||||
/** 缺少项目配置时仅返回入口状态,各制作阶段不可读取或执行。 */
|
||||
export interface ProductionConfigurationBlockedPlan {
|
||||
/** 配置阻断时仍保留真实分阶段门禁。 */
|
||||
stageReadiness?: ProductionStageReadiness
|
||||
/** 所属项目编号。 */
|
||||
projectId: string
|
||||
/** 配置未完成时禁止启动。 */
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { useQuery } from '../../composables/useQuery'
|
||||
import { preparationApi } from '../storyboard-preparation/api'
|
||||
import ContextNotice from '../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { computed, h, inject, onScopeDispose, provide, ref, watch, watchEffect } from 'vue'
|
||||
@@ -171,7 +173,28 @@ watchEffect(() => {
|
||||
)
|
||||
invalidateEpisodeSource(record.projectId, number)
|
||||
})
|
||||
const stageAccess = useProjectStageAccess(id, context.stageReadiness)
|
||||
/** 上游复检阻断时仍允许核对已有正式分镜,批量生产门禁保持服务端结论。 */
|
||||
const formalStoryboardKey = computed(() =>
|
||||
context.project.value?.status === 'completed' &&
|
||||
context.stageReadiness.value &&
|
||||
!context.stageReadiness.value.preparation.ready &&
|
||||
!context.stageReadiness.value.breakdown.ready
|
||||
? id.value
|
||||
: ''
|
||||
)
|
||||
/** 正式确认只用于发现可读镜头,不在这里自动审核或放行生成。 */
|
||||
const formalStoryboard = useQuery(formalStoryboardKey, (projectId, signal) =>
|
||||
projectId ? preparationApi.approval(projectId, signal) : Promise.resolve(null)
|
||||
)
|
||||
/** 只读入口要求真实项目归属和非零正式镜头数量。 */
|
||||
const formalStoryboardReadable = computed(
|
||||
() =>
|
||||
!formalStoryboard.loading.value &&
|
||||
!formalStoryboard.error.value &&
|
||||
formalStoryboard.data.value?.confirmation?.projectId === id.value &&
|
||||
Number(formalStoryboard.data.value?.evidence?.shotCount) > 0
|
||||
)
|
||||
const stageAccess = useProjectStageAccess(id, context.stageReadiness, formalStoryboardReadable)
|
||||
const complete = stageAccess.scriptReady
|
||||
/** 当前路由所属的制作步骤;项目素材不是制作步骤。 */
|
||||
const currentSection = computed(() => projectSectionFromPath(route.path))
|
||||
|
||||
@@ -11,9 +11,14 @@ function accessState(ready: boolean | undefined, reason: string | null | undefin
|
||||
* 使用真实准备情况控制侧栏与页面入口,仅转换原因文案。
|
||||
* @param projectId 当前项目编号
|
||||
* @param readiness 当前项目各步骤的准备情况
|
||||
* @param formalStoryboardReadable 正式镜头存在时允许只读查看,不改变生产门禁
|
||||
* @returns 各步骤入口、原因与下一步引导
|
||||
*/
|
||||
export function useProjectStageAccess(projectId: Ref<string>, readiness: Ref<ProjectStageReadiness | null>) {
|
||||
export function useProjectStageAccess(
|
||||
projectId: Ref<string>,
|
||||
readiness: Ref<ProjectStageReadiness | null>,
|
||||
formalStoryboardReadable?: Ref<boolean>
|
||||
) {
|
||||
/** 当前步骤能否进入及对应中文说明,不改变原始准备状态。 */
|
||||
const sections = computed<Record<ProjectSection, ProjectAccess['sections'][ProjectSection]>>(() => {
|
||||
const state = readiness.value?.projectId === projectId.value ? readiness.value : null
|
||||
@@ -50,7 +55,8 @@ export function useProjectStageAccess(projectId: Ref<string>, readiness: Ref<Pro
|
||||
},
|
||||
storyboard: {
|
||||
// 正式分镜可以先进入核对草案和单镜头;全项目素材缺失仍阻断制作。
|
||||
enabled: preparationReady || state?.breakdown.ready === true,
|
||||
enabled:
|
||||
preparationReady || state?.breakdown.ready === true || formalStoryboardReadable?.value === true,
|
||||
reason: preparationReason || state?.breakdown.reason || '请先完成正式分镜准备',
|
||||
nextPath: 'breakdown',
|
||||
nextLabel: '前往剧本拆解'
|
||||
|
||||
@@ -110,6 +110,15 @@ export interface StoryboardReviewInput {
|
||||
}
|
||||
/** 正式制作入口的只读结论。 */
|
||||
export interface ProductionEntryReadiness {
|
||||
/** 正式分镜本身是否已就绪,不表示派生与下游生产已就绪。 */
|
||||
storyboardReady?: boolean
|
||||
/** 服务端提供的逐镜缺口;未返回时不能猜测具体过期镜头。 */
|
||||
derivedAssetShotGaps?: Array<{
|
||||
/** 正式集号。 */ episode: number
|
||||
/** 正式镜头身份。 */ shotId: string
|
||||
/** 摄影来源状态。 */ direction: 'missing' | 'stale' | 'current'
|
||||
/** 画面来源状态。 */ visualState: 'missing' | 'stale' | 'current'
|
||||
}>
|
||||
/** 当前允许进入制作计划。 */ ready: boolean
|
||||
/** 存在拆解结构检查。 */ hasStoryboardValidation: boolean
|
||||
/** 明确结构结论。 */ storyboardValid: boolean | null
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import StagedShotPreparation from './components/StagedShotPreparation.vue'
|
||||
import { derivedTaskState, type DerivedPhase } from './staged-derived'
|
||||
import type { DesignedShot } from './types'
|
||||
import { inject } from 'vue'
|
||||
import { routeLocationKey } from 'vue-router'
|
||||
import ContinuityReviewDrawer from '../production/components/ContinuityReviewDrawer.vue'
|
||||
import WorkspaceActionTooltip from '../../components/ui/WorkspaceActionTooltip.vue'
|
||||
import { ScanEye } from '@lucide/vue'
|
||||
import { errorMessage } from '../../lib/http'
|
||||
import { userFacingText } from '../../lib/user-facing-text'
|
||||
import { isOperationRunning } from '../workflows/operations'
|
||||
|
||||
@@ -15,7 +19,18 @@ import { integerRule } from '../../lib/form-rules'
|
||||
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
import ActionMenu from '../../components/ui/ActionMenu.vue'
|
||||
import WorkspaceTools from '../../components/ui/WorkspaceTools.vue'
|
||||
import { NScrollbar, NButton, NCheckbox, NInputNumber, NProgress, NSelect, NTab, NTabs } from 'naive-ui'
|
||||
import {
|
||||
NScrollbar,
|
||||
NButton,
|
||||
NCheckbox,
|
||||
NInputNumber,
|
||||
NProgress,
|
||||
NSelect,
|
||||
NTab,
|
||||
NTabs,
|
||||
NCollapse,
|
||||
NCollapseItem
|
||||
} from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { EmptyState } from '../../components/ui'
|
||||
import { downloadText } from '../../lib/format'
|
||||
@@ -75,6 +90,18 @@ function locateMotion(item: MotionPlanAudit['items'][number]) {
|
||||
/** 分镜工作区按单集查看正式数据,生成配置与镜头检查分开。 */
|
||||
const {
|
||||
id,
|
||||
checkedShotIds,
|
||||
generationScope,
|
||||
selectedShots,
|
||||
scopeLabel,
|
||||
stateFor,
|
||||
needsGeneration,
|
||||
unresolvedRequest,
|
||||
toggleShots,
|
||||
rangeDirectionCurrent,
|
||||
designEntry,
|
||||
submissionUnknown,
|
||||
inspectSubmission,
|
||||
selectedEpisode,
|
||||
episodeNo,
|
||||
episodeOptions,
|
||||
@@ -103,6 +130,44 @@ const {
|
||||
executions,
|
||||
run
|
||||
} = useStoryboard()
|
||||
/**
|
||||
* 显示正式派生状态与当前任务,不将候选或领取回执当作审核通过。
|
||||
* @param item 当前正式镜头
|
||||
* @param phase 摄影或画面状态
|
||||
* @returns 当前可读状态
|
||||
*/
|
||||
function shotStageLabel(item: DesignedShot, phase: DerivedPhase) {
|
||||
const state = stateFor(item, phase)
|
||||
const labels = { current: '当前有效', missing: '尚未生成', stale: '来源过期', unknown: '需核对来源' }
|
||||
const task = derivedTaskState(
|
||||
executions[phase === 'direction' ? 1 : 2]!.observer.query.data.value,
|
||||
item.shotId,
|
||||
episodeNo.value
|
||||
)
|
||||
const tasks = { running: '正在执行', stopped: '已停止', failed: '执行失败', unresolved: '请求结果未知' }
|
||||
return `${labels[state]}${task ? ` · ${tasks[task]}` : ''}`
|
||||
}
|
||||
/** 本轮派生任务作用范围与费用确认共用同一说明。 */
|
||||
const derivedDescription = computed(
|
||||
() =>
|
||||
`${scopeLabel.value};会调用收费文本模型,图片持续授权不涵盖文本费用。${force.value ? '覆盖所选范围已有结果,可能使画面状态、首帧、视频描述与视频来源失效。' : '复用当前有效结果,只补齐缺失或过期镜头。'}提交后仅观察原任务,不会自动开始下一阶段。`
|
||||
)
|
||||
/**
|
||||
* 摄影采用后刷新正式来源和阶段状态,不触发任何生成。
|
||||
* @returns 当前读取完成
|
||||
*/
|
||||
async function refreshDerivedSources() {
|
||||
await Promise.all([query.refresh(), designEntry.refresh(), approval.refresh()])
|
||||
}
|
||||
/** 用户主动核对原提交,读取错误进入统一消息层。 */
|
||||
async function inspectDerivedSubmission() {
|
||||
try {
|
||||
if ((await inspectSubmission()) === false)
|
||||
feedback?.warning('尚未找到与原提交范围匹配的新任务,请继续核对原请求,不要重复生成。')
|
||||
} catch (cause) {
|
||||
feedback?.error(errorMessage(cause))
|
||||
}
|
||||
}
|
||||
/** 仅在首帧标签读取项目列表中的本镜就绪结果,独立于项目制作入口。 */
|
||||
const keyframeProject = computed(() => (detailTab.value === 'keyframes' ? id.value : ''))
|
||||
/** 按当前项目读取后端的逐镜头首帧就绪项。 */
|
||||
@@ -425,6 +490,87 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
<p class="mt-2 text-sm text-muted">从镜头拆解到摄影设计,再补齐每一镜的即时状态。</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 以下是按正式 Episode、Beat、Shot 选择的生成范围。 -->
|
||||
<section class="workspace-section-stack" aria-label="派生镜头范围">
|
||||
<label class="workspace-form-field"
|
||||
><span>生成范围</span
|
||||
><NSelect
|
||||
v-model:value="generationScope"
|
||||
:disabled="operation.pending"
|
||||
aria-label="派生生成范围"
|
||||
:options="[
|
||||
{ label: '所选镜头', value: 'selected' },
|
||||
{ label: '当前集', value: 'episode' },
|
||||
{ label: '全项目', value: 'project' }
|
||||
]"
|
||||
/></label>
|
||||
<p class="text-sm">{{ scopeLabel }} · 默认复用已有有效结果。</p>
|
||||
<NCollapse
|
||||
><NCollapseItem name="range-selection" title="选择镜头(按段落)">
|
||||
<BeatShotDirectory
|
||||
:shots="shots"
|
||||
:active-id="shot?.shotId || ''"
|
||||
item-class="shot-link"
|
||||
selectable
|
||||
:checked-ids="checkedShotIds"
|
||||
:selection-disabled="operation.pending || query.loading.value"
|
||||
@select="selectedShot = $event"
|
||||
@toggle="toggleShots([$event])"
|
||||
@toggle-beat="toggleShots"
|
||||
>
|
||||
<template #meta="{ shot: item }"
|
||||
><span class="directory-status"
|
||||
>摄影:{{ shotStageLabel(item, 'direction') }}</span
|
||||
><span class="directory-status"
|
||||
>画面:{{ shotStageLabel(item, 'visualState') }}</span
|
||||
></template
|
||||
>
|
||||
</BeatShotDirectory>
|
||||
</NCollapseItem></NCollapse
|
||||
>
|
||||
<p
|
||||
v-if="generationScope === 'selected' && selectedShots.length && !force"
|
||||
class="text-xs text-muted"
|
||||
>
|
||||
本次可复用:摄影
|
||||
{{ selectedShots.filter(item => stateFor(item, 'direction') === 'current').length }}/{{
|
||||
selectedShots.length
|
||||
}},画面状态
|
||||
{{
|
||||
selectedShots.filter(item => stateFor(item, 'visualState') === 'current').length
|
||||
}}/{{ selectedShots.length }}。{{
|
||||
!needsGeneration('direction') && !needsGeneration('visualState')
|
||||
? '所选镜头无需重复生成,可继续核对首帧准备。'
|
||||
: ''
|
||||
}}
|
||||
</p>
|
||||
<p v-if="force" class="text-sm">
|
||||
覆盖模式已开启:所选范围已有结果会重做,相关下游来源可能失效。提交前需要再次确认。
|
||||
</p>
|
||||
<p
|
||||
v-if="unresolvedRequest('direction') || unresolvedRequest('visualState')"
|
||||
role="alert"
|
||||
class="text-sm"
|
||||
>
|
||||
本次范围存在已发送但结果未知的原请求,已暂停重复生成。停止或覆盖模式均不能解除费用核对。
|
||||
</p>
|
||||
<NButton v-if="submissionUnknown" @click="inspectDerivedSubmission">免费核对原提交</NButton>
|
||||
<p v-if="submissionUnknown" role="alert" class="text-sm">
|
||||
提交结果待核对,已暂停重复提交。请刷新原任务状态或重新读取任务记录;不会自动重新生成。
|
||||
</p>
|
||||
<p v-if="designEntry.loading.value" role="status" class="text-xs text-muted">
|
||||
正在核对项目准备情况…
|
||||
</p>
|
||||
<p v-else-if="designEntry.error.value" role="alert" class="text-sm">
|
||||
项目准备情况读取失败:{{ designEntry.error.value }}
|
||||
</p>
|
||||
<p v-else-if="designEntry.data.value" class="text-xs text-muted">
|
||||
全项目生产:{{ designEntry.data.value.ready ? '入口已就绪' : '入口未就绪'
|
||||
}}<span v-if="designEntry.data.value.reason">
|
||||
· {{ userFacingText(designEntry.data.value.reason) }}</span
|
||||
>
|
||||
</p>
|
||||
</section>
|
||||
<section class="mt-3" aria-label="分镜生成配置">
|
||||
<AppForm :model="formModel" :rules="rules" :disabled="operation.pending" validate-on-change>
|
||||
<div class="form-controls storyboard-controls">
|
||||
@@ -458,7 +604,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
v-model:checked="force"
|
||||
:disabled="operation.pending"
|
||||
class="control-row-checkbox text-xs"
|
||||
>批量覆盖已有结果</NCheckbox
|
||||
>覆盖本次范围已有结果</NCheckbox
|
||||
>
|
||||
</div>
|
||||
</AppForm>
|
||||
@@ -532,23 +678,31 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
<span class="mr-2 font-mono text-xs text-muted">01</span>导演摄影设计
|
||||
</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
设置景别、机位、运镜和构图。覆盖模式会重做全部剧集。
|
||||
先准备摄影,再由用户另行发起画面状态生成。已有有效镜头自动复用。
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<ConfirmAction
|
||||
:loading="
|
||||
isOperationRunning(operation, '生成项目导演设计') ||
|
||||
isOperationRunning(operation, '摄影设计') ||
|
||||
!!executions[1]?.observer.active.value
|
||||
"
|
||||
:label="force ? '重生成全部导演设计' : '补齐项目导演设计'"
|
||||
:label="`${force ? '重生成' : '补齐'}${scopeLabel}摄影设计`"
|
||||
:disabled="!allowed['direction-all']"
|
||||
acknowledgement
|
||||
:description="
|
||||
force
|
||||
? '重新生成项目全部剧集的导演设计,覆盖已有结果。'
|
||||
: '补齐全项目导演设计,跳过已完成的剧集。'
|
||||
primary
|
||||
:confirmation-key="
|
||||
JSON.stringify([
|
||||
id,
|
||||
episodeNo,
|
||||
generationScope,
|
||||
checkedShotIds,
|
||||
concurrency,
|
||||
maxRepairAttempts,
|
||||
force
|
||||
])
|
||||
"
|
||||
:description="derivedDescription"
|
||||
@confirm="run('direction-all')"
|
||||
/>
|
||||
</div>
|
||||
@@ -565,21 +719,34 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<ConfirmAction
|
||||
:loading="
|
||||
isOperationRunning(operation, '生成项目即时状态') ||
|
||||
isOperationRunning(operation, '画面状态') ||
|
||||
!!executions[2]?.observer.active.value
|
||||
"
|
||||
:label="force ? '重生成全部即时状态' : '补齐项目即时状态'"
|
||||
:label="`${force ? '重生成' : '补齐'}${scopeLabel}画面状态`"
|
||||
:disabled="!allowed['visual-all']"
|
||||
acknowledgement
|
||||
:description="
|
||||
force
|
||||
? '重新生成整个项目的即时状态,覆盖已有结果。每集必须先有完整导演设计。'
|
||||
: '补齐项目即时状态,跳过完整剧集;未完成导演设计的剧集会返回失败原因。'
|
||||
primary
|
||||
:confirmation-key="
|
||||
JSON.stringify([
|
||||
id,
|
||||
episodeNo,
|
||||
generationScope,
|
||||
checkedShotIds,
|
||||
concurrency,
|
||||
maxRepairAttempts,
|
||||
force
|
||||
])
|
||||
"
|
||||
:description="derivedDescription + '本次范围的摄影设计必须当前有效。'"
|
||||
@confirm="run('visual-all')"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="!rangeDirectionCurrent" class="text-xs text-muted">
|
||||
请先补齐或核对本次范围的摄影设计,再生成画面状态。
|
||||
</p>
|
||||
<!-- 以下是所选范围的只读参考素材与分阶段生产缺口。 -->
|
||||
<StagedShotPreparation :project-id="id" :shots="selectedShots" :active="toolsOpen" />
|
||||
<p class="mt-4 text-[11px] leading-6 text-muted">
|
||||
设计更新后,请依次更新画面状态和视频提示词。自动修复次数只用于画面状态。
|
||||
</p>
|
||||
@@ -618,6 +785,9 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
:execution="entry.observer.query.data.value"
|
||||
:loading="entry.observer.query.loading.value"
|
||||
:error="entry.observer.query.error.value"
|
||||
:can-stop="entry.observer.canStop.value"
|
||||
:stopping="entry.observer.stopping.value"
|
||||
@stop="entry.observer.stop"
|
||||
@refresh="entry.observer.query.refresh"
|
||||
@dismiss="entry.observer.dismiss"
|
||||
/>
|
||||
@@ -654,7 +824,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
{{ data.visualStates.staleCount }} 个。</span
|
||||
> </ContextNotice
|
||||
><ContextNotice
|
||||
v-if="!prerequisites.directionEpisode || !prerequisites.visualEpisode"
|
||||
v-if="!approved && (!prerequisites.directionEpisode || !prerequisites.visualEpisode)"
|
||||
type="info"
|
||||
:show-icon="false"
|
||||
class="mt-4"
|
||||
@@ -675,7 +845,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
<h3>
|
||||
镜头目录 <span>{{ shots.length }} 镜</span>
|
||||
</h3>
|
||||
<span>按段落排列</span>
|
||||
<span>已选 {{ checkedShotIds.length }} 镜</span>
|
||||
</div>
|
||||
<NScrollbar
|
||||
class="panel-scroll directory-scroll"
|
||||
@@ -686,11 +856,16 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
:shots="shots"
|
||||
:active-id="shot?.shotId || ''"
|
||||
item-class="shot-link"
|
||||
selectable
|
||||
:checked-ids="checkedShotIds"
|
||||
:selection-disabled="operation.pending || query.loading.value"
|
||||
@toggle="toggleShots([$event])"
|
||||
@toggle-beat="toggleShots"
|
||||
@select="selectedShot = $event"
|
||||
>
|
||||
<template #meta="{ shot: item }">
|
||||
<span class="directory-status">{{ item.direction ? '设计已保存' : '待设计' }}</span>
|
||||
<span class="directory-status">{{ item.visualState ? '状态已保存' : '待状态' }}</span>
|
||||
<span class="directory-status">摄影:{{ shotStageLabel(item, 'direction') }}</span>
|
||||
<span class="directory-status">画面:{{ shotStageLabel(item, 'visualState') }}</span>
|
||||
</template>
|
||||
</BeatShotDirectory>
|
||||
</NScrollbar>
|
||||
@@ -749,7 +924,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
|
||||
:shot="shot"
|
||||
:shots="shots"
|
||||
:disabled="blocked"
|
||||
@changed="query.refresh"
|
||||
@changed="refreshDerivedSources"
|
||||
/>
|
||||
</div>
|
||||
<ShotDesign :shot="shot" />
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, useId } from 'vue'
|
||||
import { useDirectorySelection } from '../../../composables/useDirectorySelection'
|
||||
import { NCheckbox } from 'naive-ui'
|
||||
import { DirectoryItem } from '../../../components/ui'
|
||||
import type { DesignedShot } from '../types'
|
||||
|
||||
@@ -12,9 +13,15 @@ const props = defineProps<{
|
||||
activeId: string
|
||||
/** 页面传入的目录条目样式。 */
|
||||
itemClass: string
|
||||
/** 开启正式镜头多选,仍复用同一段落目录。 */
|
||||
selectable?: boolean
|
||||
/** 当前勾选的正式镜头。 */
|
||||
checkedIds?: string[]
|
||||
/** 读取或提交期间保持选择稳定。 */
|
||||
selectionDisabled?: boolean
|
||||
}>()
|
||||
/** 用户选择目录镜头时通知页面更新当前镜头。 */
|
||||
const emit = defineEmits<{ select: [shotId: string] }>()
|
||||
const emit = defineEmits<{ select: [shotId: string]; toggle: [shotId: string]; toggleBeat: [shotIds: string[]] }>()
|
||||
/** 两个镜头页面共用的目录根节点,用于定位当前选中的正式镜头。 */
|
||||
const directoryRoot = ref<HTMLDivElement | null>(null)
|
||||
/** 当前目录实例的唯一标识,关联各段落标题和目录组。 */
|
||||
@@ -54,26 +61,60 @@ useDirectorySelection(
|
||||
:aria-labelledby="`${directoryId}-beat-${group.beatNo}`"
|
||||
>
|
||||
<h4 :id="`${directoryId}-beat-${group.beatNo}`" class="directory-group-heading">
|
||||
<span>段落 {{ String(group.beatNo).padStart(2, '0') }}</span>
|
||||
<NCheckbox
|
||||
v-if="selectable"
|
||||
:checked="group.shots.every(shot => checkedIds?.includes(shot.shotId))"
|
||||
:indeterminate="
|
||||
group.shots.some(shot => checkedIds?.includes(shot.shotId)) &&
|
||||
!group.shots.every(shot => checkedIds?.includes(shot.shotId))
|
||||
"
|
||||
:disabled="selectionDisabled"
|
||||
:aria-label="`选择段落 ${group.beatNo} 的全部镜头`"
|
||||
@update:checked="
|
||||
emit(
|
||||
'toggleBeat',
|
||||
group.shots.map(shot => shot.shotId)
|
||||
)
|
||||
"
|
||||
>
|
||||
段落 {{ String(group.beatNo).padStart(2, '0') }}
|
||||
</NCheckbox>
|
||||
<span v-else>段落 {{ String(group.beatNo).padStart(2, '0') }}</span>
|
||||
<span class="directory-group-count">{{ group.shots.length }} 镜</span>
|
||||
</h4>
|
||||
<div class="beat-directory-items">
|
||||
<DirectoryItem
|
||||
<div
|
||||
v-for="shot in group.shots"
|
||||
:key="shot.shotId"
|
||||
:active="activeId === shot.shotId"
|
||||
:class="itemClass"
|
||||
:aria-label="`段落 ${group.beatNo} · 镜头 ${shot.shotNo} · ${shot.title}`"
|
||||
@click="emit('select', shot.shotId)"
|
||||
class="directory-select-row"
|
||||
:class="{ 'has-selection': selectable }"
|
||||
>
|
||||
{{ shot.title }}
|
||||
<template #eyebrow>
|
||||
<!-- 窄屏目录变为横向条目时补回归属,桌面不重复显示分组编号。 -->
|
||||
<span class="directory-mobile-beat">段落 {{ String(group.beatNo).padStart(2, '0') }} / </span>
|
||||
<span class="directory-shot-number">镜头 {{ String(shot.shotNo).padStart(2, '0') }}</span>
|
||||
</template>
|
||||
<template #meta><slot name="meta" :shot="shot" /></template>
|
||||
</DirectoryItem>
|
||||
<!-- 以下是镜头多选入口,与打开详情的按钮分开。 -->
|
||||
<NCheckbox
|
||||
v-if="selectable"
|
||||
:checked="checkedIds?.includes(shot.shotId) ?? false"
|
||||
:disabled="selectionDisabled"
|
||||
:aria-label="`选择镜头 ${group.beatNo}.${shot.shotNo}`"
|
||||
class="directory-shot-checkbox"
|
||||
@update:checked="emit('toggle', shot.shotId)"
|
||||
/>
|
||||
<DirectoryItem
|
||||
:active="activeId === shot.shotId"
|
||||
:class="itemClass"
|
||||
:aria-label="`段落 ${group.beatNo} · 镜头 ${shot.shotNo} · ${shot.title}`"
|
||||
@click="emit('select', shot.shotId)"
|
||||
>
|
||||
{{ shot.title }}
|
||||
<template #eyebrow>
|
||||
<!-- 窄屏目录变为横向条目时补回归属,桌面不重复显示分组编号。 -->
|
||||
<span class="directory-mobile-beat"
|
||||
>段落 {{ String(group.beatNo).padStart(2, '0') }} /
|
||||
</span>
|
||||
<span class="directory-shot-number">镜头 {{ String(shot.shotNo).padStart(2, '0') }}</span>
|
||||
</template>
|
||||
<template #meta><slot name="meta" :shot="shot" /></template>
|
||||
</DirectoryItem>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -82,6 +123,17 @@ useDirectorySelection(
|
||||
<style>
|
||||
/* 本组件专属布局与 Naive 内部结构覆盖。 */
|
||||
@reference "../../../styles/styles.css";
|
||||
.directory-select-row {
|
||||
display: contents;
|
||||
}
|
||||
.directory-select-row.has-selection {
|
||||
display: grid;
|
||||
grid-template-columns: 28px minmax(0, 1fr);
|
||||
align-items: center;
|
||||
}
|
||||
.directory-shot-checkbox {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.beat-shot-directory {
|
||||
display: contents;
|
||||
}
|
||||
@@ -108,6 +160,9 @@ useDirectorySelection(
|
||||
.beat-directory-items {
|
||||
display: contents;
|
||||
}
|
||||
.directory-select-row.has-selection {
|
||||
flex: 0 0 210px;
|
||||
}
|
||||
.directory-mobile-beat {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<script setup lang="ts">
|
||||
import { NInput } from 'naive-ui'
|
||||
/** 原组合草案与独立摄影阶段共用的构图、机位编辑。 */
|
||||
defineProps<{ /** 正式提交期间锁定输入。 */ disabled?: boolean }>()
|
||||
/** 用户编辑的构图原文,不翻译创作内容。 */
|
||||
const composition = defineModel<string>('composition', { required: true })
|
||||
/** 用户编辑的摄影机位置,不更改主体归属。 */
|
||||
const cameraPosition = defineModel<string>('cameraPosition', { required: true })
|
||||
</script>
|
||||
<template>
|
||||
<!-- 以下是两种摄影修订共用的字段,使用真实纵向间距。 -->
|
||||
<div class="workspace-section-stack">
|
||||
<label class="workspace-form-field"
|
||||
><span>构图</span
|
||||
><NInput
|
||||
v-model:value="composition"
|
||||
type="textarea"
|
||||
:disabled="disabled"
|
||||
aria-label="摄影构图"
|
||||
:autosize="{ minRows: 3, maxRows: 8 }"
|
||||
/></label>
|
||||
<label class="workspace-form-field"
|
||||
><span>摄影机位置</span
|
||||
><NInput
|
||||
v-model:value="cameraPosition"
|
||||
type="textarea"
|
||||
:disabled="disabled"
|
||||
aria-label="摄影机位置"
|
||||
:autosize="{ minRows: 3, maxRows: 8 }"
|
||||
/></label>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,249 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox, NInput } from 'naive-ui'
|
||||
import { WorkspaceSectionHeading } from '../../../components/ui'
|
||||
import { useActionMessage } from '../../../components/ui/useActionMessage'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { ApiError, errorMessage } from '../../../lib/http'
|
||||
import { preparationApi } from '../../storyboard-preparation/api'
|
||||
import { currentStoryboardApproval } from '../../storyboard-preparation/model'
|
||||
import { getOperation, runOperation } from '../../workflows/operations'
|
||||
import { storyboardApi } from '../api'
|
||||
import { derivedReviewApi } from '../derived-review-api'
|
||||
import type { DirectionReviewInput, DirectionReviewResult } from '../derived-review.types'
|
||||
import type { DesignedShot } from '../types'
|
||||
import DirectionCameraFields from './DirectionCameraFields.vue'
|
||||
|
||||
/** 尚无画面状态时在原摄影抽屉内采用独立摄影,最终条件由服务端检查。 */
|
||||
const props = defineProps<{
|
||||
/** 当前正式项目。 */ projectId: string
|
||||
/** 正式集号。 */ episodeNo: number
|
||||
/** 正式镜头。 */ shot: DesignedShot
|
||||
/** 项目活动任务或错误限制。 */ disabled: boolean
|
||||
}>()
|
||||
/** 采用后由原页面刷新正式摄影及阶段状态。 */
|
||||
const emit = defineEmits<{ adopted: [] }>()
|
||||
/** 构图原文。 */
|
||||
const composition = ref('')
|
||||
/** 机位原文。 */
|
||||
const cameraPosition = ref('')
|
||||
/** 用户输入的实际审核署名,预检与采用保持一致。 */
|
||||
const reviewer = ref('')
|
||||
/** 人工确认当前草案及预检。 */
|
||||
const acknowledged = ref(false)
|
||||
/** 正式采用时防止重复操作或意外关闭。 */
|
||||
const saving = ref(false)
|
||||
/** 免费预检可以取消。 */
|
||||
const previewing = ref(false)
|
||||
/** 并发或来源冲突后必须显式重读,不自动覆盖版本。 */
|
||||
const sourceConflict = ref(false)
|
||||
/** 本次冻结的请求与预检来源,changed=false不影响采用。 */
|
||||
const reviewed = ref<{ input: DirectionReviewInput; result: DirectionReviewResult } | null>(null)
|
||||
/** 中文消息反馈。 */
|
||||
const message = useActionMessage()
|
||||
/** 当前镜头范围,组件卸载后自动取消读取。 */
|
||||
const key = computed(() => JSON.stringify([props.projectId, props.episodeNo, props.shot.shotId]))
|
||||
/** 打开时重读原摄影和正式确认,完整原版本留在状态中。 */
|
||||
const source = useQuery(key, async (value, signal) => {
|
||||
const [projectId, episodeNo, shotId] = JSON.parse(value) as [string, number, string]
|
||||
const [approval, directions, visuals] = await Promise.all([
|
||||
preparationApi.approval(projectId, signal),
|
||||
storyboardApi.directions(projectId, episodeNo, signal),
|
||||
storyboardApi.visualStates(projectId, episodeNo, signal)
|
||||
])
|
||||
if (!currentStoryboardApproval(approval, projectId)) throw new Error('正式分镜确认已失效,请先重新核对。')
|
||||
if (
|
||||
!directions ||
|
||||
directions.projectId !== projectId ||
|
||||
directions.episodeNo !== episodeNo ||
|
||||
!visuals ||
|
||||
visuals.projectId !== projectId ||
|
||||
visuals.episodeNo !== episodeNo
|
||||
)
|
||||
throw new Error('摄影来源不属于当前项目或剧集。')
|
||||
const direction = directions.beats.flatMap(beat => beat.shots).find(shot => shot.shotId === shotId)?.direction
|
||||
const visual = visuals.beats.flatMap(beat => beat.shots).find(shot => shot.shotId === shotId)
|
||||
if (!direction?.id || !direction.updatedAt || direction.rawJson === undefined || !visual)
|
||||
throw new Error('缺少可核对的原摄影版本,请刷新后重试。')
|
||||
if (visual.visualState) throw new Error('本镜已有画面状态,请关闭并刷新后使用原组合摄影修订。')
|
||||
return { approval, direction }
|
||||
})
|
||||
/** 新来源只初始化摄影内容,不补造画面状态。 */
|
||||
watch(source.data, value => {
|
||||
composition.value = value?.direction.composition ?? ''
|
||||
cameraPosition.value = value?.direction.cameraPosition ?? ''
|
||||
})
|
||||
/** 正式采用需要冻结同一份已预检草案。 */
|
||||
const canAdopt = computed(
|
||||
() =>
|
||||
!!reviewed.value &&
|
||||
acknowledged.value &&
|
||||
!props.disabled &&
|
||||
!saving.value &&
|
||||
!source.error.value &&
|
||||
!source.loading.value &&
|
||||
!sourceConflict.value
|
||||
)
|
||||
/** 免费预检必须有真实版本及实际署名。 */
|
||||
const canPreview = computed(
|
||||
() =>
|
||||
!!source.data.value &&
|
||||
!source.error.value &&
|
||||
!source.loading.value &&
|
||||
!sourceConflict.value &&
|
||||
!!reviewer.value.trim() &&
|
||||
!!composition.value.trim() &&
|
||||
!!cameraPosition.value.trim() &&
|
||||
!props.disabled &&
|
||||
!saving.value
|
||||
)
|
||||
/** 当前免费预检取消控制器。 */
|
||||
let controller: AbortController | undefined
|
||||
/** 任何编辑、切换、来源变化都会撤销旧预检。 */
|
||||
function clear() {
|
||||
controller?.abort()
|
||||
reviewed.value = null
|
||||
acknowledged.value = false
|
||||
previewing.value = false
|
||||
}
|
||||
watch([key, composition, cameraPosition, reviewer, source.data], clear, { flush: 'sync' })
|
||||
onScopeDispose(clear)
|
||||
/** 免费核查同一完整摄影草案,不调用模型。 */
|
||||
async function preview() {
|
||||
if (!canPreview.value || previewing.value) return
|
||||
clear()
|
||||
const current = source.data.value!
|
||||
const direction = current.direction
|
||||
const input: DirectionReviewInput = {
|
||||
phase: 'direction',
|
||||
preview: true,
|
||||
reviewer: reviewer.value.trim(),
|
||||
expectedShotFingerprint: current.approval.confirmation!.shotFingerprint,
|
||||
shots: [
|
||||
{
|
||||
shotId: props.shot.shotId,
|
||||
expectedDirectionId: direction.id!,
|
||||
expectedDirectionUpdatedAt: direction.updatedAt!,
|
||||
expectedDirectionRawJson: direction.rawJson!,
|
||||
direction: {
|
||||
shotNo: props.shot.shotNo,
|
||||
shotSize: direction.shotSize,
|
||||
cameraAngle: direction.cameraAngle,
|
||||
cameraMovement: direction.cameraMovement,
|
||||
composition: composition.value.trim(),
|
||||
cameraPosition: cameraPosition.value.trim(),
|
||||
lensIntent: direction.lensIntent,
|
||||
depthOfField: direction.depthOfField,
|
||||
visualIntent: direction.visualIntent
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
const target = key.value
|
||||
const pending = new AbortController()
|
||||
controller = pending
|
||||
previewing.value = true
|
||||
try {
|
||||
const result = await derivedReviewApi.direction(props.projectId, input, pending.signal)
|
||||
if (pending.signal.aborted || target !== key.value) return
|
||||
if (
|
||||
result?.projectId !== props.projectId ||
|
||||
result.phase !== 'direction' ||
|
||||
!result.preview ||
|
||||
!/^[a-f0-9]{64}$/.test(result.sourceFingerprint) ||
|
||||
!result.shots?.some(shot => shot.shotId === props.shot.shotId)
|
||||
)
|
||||
throw new Error('预检未返回当前镜头的有效来源,请重新核对。')
|
||||
reviewed.value = { input, result }
|
||||
message?.success('摄影免费预检通过,尚未采用')
|
||||
} catch (cause) {
|
||||
if (!pending.signal.aborted && target === key.value) {
|
||||
if (cause instanceof ApiError && cause.status === 409) sourceConflict.value = true
|
||||
message?.error(errorMessage(cause))
|
||||
}
|
||||
} finally {
|
||||
if (controller === pending) previewing.value = false
|
||||
}
|
||||
}
|
||||
/** 正式采用原已审快照;并发或下游冲突只展示原因,不自动覆盖。 */
|
||||
async function adopt() {
|
||||
if (!canAdopt.value || !reviewed.value) return
|
||||
const reviewedInput = reviewed.value
|
||||
const target = key.value
|
||||
const projectId = props.projectId
|
||||
saving.value = true
|
||||
try {
|
||||
const ok = await runOperation(projectId, '采用独立摄影修订', async () => {
|
||||
const result = await derivedReviewApi.direction(projectId, {
|
||||
...reviewedInput.input,
|
||||
preview: false,
|
||||
expectedSourceFingerprint: reviewedInput.result.sourceFingerprint
|
||||
})
|
||||
if (
|
||||
!result ||
|
||||
result.projectId !== projectId ||
|
||||
result.phase !== 'direction' ||
|
||||
result.preview ||
|
||||
!result.shots?.some(shot => shot.shotId === reviewedInput.input.shots[0]!.shotId)
|
||||
)
|
||||
throw new Error('采用回执不完整,请先刷新正式摄影,不要重复提交。')
|
||||
})
|
||||
if (target !== key.value) return
|
||||
if (ok) {
|
||||
message?.success('已采用摄影修订,画面状态尚未生成')
|
||||
emit('adopted')
|
||||
} else {
|
||||
clear()
|
||||
const operation = getOperation(projectId)
|
||||
if (operation.cause instanceof ApiError && operation.cause.status === 409) sourceConflict.value = true
|
||||
message?.error(operation.error)
|
||||
}
|
||||
} finally {
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
/** 用户明确重新核对版本时保留当前草稿,新的来源仍须再次免费预检。 */
|
||||
async function reloadSource() {
|
||||
const draft = { composition: composition.value, cameraPosition: cameraPosition.value }
|
||||
clear()
|
||||
await source.refresh()
|
||||
composition.value = draft.composition
|
||||
cameraPosition.value = draft.cameraPosition
|
||||
if (!source.error.value) sourceConflict.value = false
|
||||
}
|
||||
/** 由共用抽屉的固定底栏调用采用操作和忙碌状态。 */
|
||||
defineExpose({ saving, canAdopt, adopt })
|
||||
</script>
|
||||
<template>
|
||||
<!-- 以下是生成画面状态之前的独立摄影审核,沿用原字段编辑器。 -->
|
||||
<section class="workspace-section-stack">
|
||||
<WorkspaceSectionHeading
|
||||
title="先修订摄影"
|
||||
description="免费预检并采用摄影修改,不生成画面状态。已有下游结果时需使用原组合修订。"
|
||||
/>
|
||||
<NButton :disabled="saving" :loading="source.loading.value" @click="reloadSource">重新读取正式来源</NButton>
|
||||
<p v-if="sourceConflict" role="alert">来源或原摄影版本已变化。当前输入保留,请重新读取并核对后再预检。</p>
|
||||
<p v-if="source.loading.value" role="status">正在核对正式来源…</p>
|
||||
<div v-if="source.error.value" class="space-y-3">
|
||||
<p role="alert">{{ source.error.value }}</p>
|
||||
</div>
|
||||
<template v-if="source.data.value && !source.error.value">
|
||||
<DirectionCameraFields
|
||||
v-model:composition="composition"
|
||||
v-model:camera-position="cameraPosition"
|
||||
:disabled="saving"
|
||||
/>
|
||||
<label class="workspace-form-field"
|
||||
><span>审核人</span
|
||||
><NInput v-model:value="reviewer" :disabled="saving" :maxlength="120" aria-label="摄影审核人"
|
||||
/></label>
|
||||
<NButton :disabled="!canPreview" :loading="previewing" @click="preview">免费预检摄影修改</NButton>
|
||||
<p v-if="reviewed" role="status" class="text-sm">
|
||||
预检通过。采用将只更新本镜摄影;来源、版本或下游变化时会停止采用。
|
||||
</p>
|
||||
<NCheckbox v-if="reviewed" v-model:checked="acknowledged" :disabled="saving"
|
||||
>我已核对本镜摄影修改,确认采用。</NCheckbox
|
||||
>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,4 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import DirectionCameraFields from './DirectionCameraFields.vue'
|
||||
import DirectionStageReview from './DirectionStageReview.vue'
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NSelect, NTag } from 'naive-ui'
|
||||
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
|
||||
@@ -42,6 +44,15 @@ const emit = defineEmits<{ changed: [] }>()
|
||||
const open = ref(false)
|
||||
/** 在同一摄影入口切换受控修订与场景沿用。 */
|
||||
const mode = ref<'camera' | 'scene' | 'gaze'>('camera')
|
||||
/** 独立摄影只复用真实已有摄影,不填充空画面状态。 */
|
||||
const directionOnly = computed(() => !!props.shot.direction && !props.shot.visualState)
|
||||
/** 共用抽屉中的独立摄影编辑器,用于固定底栏采用操作。 */
|
||||
const directionEditor = ref<InstanceType<typeof DirectionStageReview> | null>(null)
|
||||
/** 独立摄影采用后关闭同一抽屉并刷新原页面。 */
|
||||
function directionAdopted() {
|
||||
open.value = false
|
||||
emit('changed')
|
||||
}
|
||||
/** 本次明确选择的正式主体。 */
|
||||
const gazeSubject = ref<string | null>(null)
|
||||
/** 人工填写的目标视线。 */
|
||||
@@ -80,7 +91,9 @@ const saving = ref(false)
|
||||
/** 当前消息层。 */
|
||||
const message = useActionMessage()
|
||||
/** 关闭或切换镜头后撤销旧读取。 */
|
||||
const key = computed(() => (open.value ? JSON.stringify([props.projectId, props.shot.shotId]) : ''))
|
||||
const key = computed(() =>
|
||||
open.value && !directionOnly.value ? JSON.stringify([props.projectId, props.shot.shotId]) : ''
|
||||
)
|
||||
/** 服务端草案单独读取,不阻塞外部草案的免费预览。 */
|
||||
const savedDraft = useQuery(key, async (value, signal) => {
|
||||
if (!value) return null
|
||||
@@ -544,11 +557,21 @@ async function adopt() {
|
||||
<NButton class="workspace-action-button" @click="open = true">摄影草案与审核</NButton>
|
||||
<AppDrawer
|
||||
v-model:open="open"
|
||||
:busy="saving || savingDraft"
|
||||
:busy="saving || savingDraft || directionEditor?.saving"
|
||||
title="摄影草案与审核"
|
||||
:description="`第 ${episodeNo} 集 · 镜头 ${shot.beatNo}.${shot.shotNo} · ${shot.title}`"
|
||||
>
|
||||
<div class="workspace-section-stack workspace-section-stack-spacious">
|
||||
<!-- 以下是画面状态生成之前的独立摄影阶段,原组合流程仍在同一抽屉。 -->
|
||||
<DirectionStageReview
|
||||
v-if="open && directionOnly"
|
||||
ref="directionEditor"
|
||||
:project-id="projectId"
|
||||
:episode-no="episodeNo"
|
||||
:shot="shot"
|
||||
:disabled="disabled"
|
||||
@adopted="directionAdopted"
|
||||
/>
|
||||
<div v-else class="workspace-section-stack workspace-section-stack-spacious">
|
||||
<!-- 以下是当前分镜来源、质量诊断与人工确认状态 -->
|
||||
<section v-if="preflight.data.value" class="space-y-2 text-sm">
|
||||
<WorkspaceSectionHeading title="正式分镜审核" />
|
||||
@@ -660,7 +683,7 @@ async function adopt() {
|
||||
aria-label="视线修订主体"
|
||||
/>
|
||||
<p v-if="formalGaze">当前正式视线:{{ formalGaze.gaze || '未填写' }}</p>
|
||||
<label class="block space-y-1"
|
||||
<label class="workspace-form-field"
|
||||
><span>修订后的视线</span
|
||||
><NInput
|
||||
v-model:value="gazeAfter"
|
||||
@@ -669,7 +692,7 @@ async function adopt() {
|
||||
:disabled="saving"
|
||||
aria-label="修订后的视线"
|
||||
/></label>
|
||||
<label class="block space-y-1"
|
||||
<label class="workspace-form-field"
|
||||
><span>修订理由</span
|
||||
><NInput
|
||||
v-model:value="gazeReason"
|
||||
@@ -682,18 +705,12 @@ async function adopt() {
|
||||
只修改所选主体视线。采用后需要重新核对来源与质量,历史审核结论和主图保留。
|
||||
</p>
|
||||
</section>
|
||||
<template v-else-if="mode === 'camera'">
|
||||
<label class="block"
|
||||
>构图<NInput v-model:value="composition" type="textarea" :disabled="saving" class="mt-1"
|
||||
/></label>
|
||||
<label class="block"
|
||||
>摄影机位置<NInput
|
||||
v-model:value="cameraPosition"
|
||||
type="textarea"
|
||||
:disabled="saving"
|
||||
class="mt-1"
|
||||
/></label>
|
||||
</template>
|
||||
<DirectionCameraFields
|
||||
v-else-if="mode === 'camera'"
|
||||
v-model:composition="composition"
|
||||
v-model:camera-position="cameraPosition"
|
||||
:disabled="saving"
|
||||
/>
|
||||
<template v-else-if="mode === 'scene'">
|
||||
<p v-if="previousShot">
|
||||
前镜 {{ previousShot.beatNo }}.{{ previousShot.shotNo }} · {{ previousShot.title }}
|
||||
@@ -857,9 +874,17 @@ async function adopt() {
|
||||
</section>
|
||||
</div>
|
||||
<template #footer>
|
||||
<NButton :disabled="saving || savingDraft" @click="open = false">关闭</NButton>
|
||||
<NButton :disabled="saving || savingDraft || directionEditor?.saving" @click="open = false">关闭</NButton>
|
||||
<NButton
|
||||
v-if="!useSaved"
|
||||
v-if="directionOnly"
|
||||
type="primary"
|
||||
:disabled="!directionEditor?.canAdopt"
|
||||
:loading="directionEditor?.saving"
|
||||
@click="directionEditor?.adopt"
|
||||
>正式采用摄影修改</NButton
|
||||
>
|
||||
<NButton
|
||||
v-if="!directionOnly && !useSaved"
|
||||
:loading="savingDraft"
|
||||
:disabled="
|
||||
disabled ||
|
||||
@@ -874,7 +899,7 @@ async function adopt() {
|
||||
>保存草案</NButton
|
||||
>
|
||||
<NButton
|
||||
v-if="reviewed"
|
||||
v-if="!directionOnly && reviewed"
|
||||
type="primary"
|
||||
:loading="saving"
|
||||
:disabled="disabled || !acknowledged || !reviewer.trim() || !preflight.data.value?.current.valid"
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { NButton, NCollapse, NCollapseItem } from 'naive-ui'
|
||||
import { WorkspaceSectionHeading } from '../../../components/ui'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import { userFacingText } from '../../../lib/user-facing-text'
|
||||
import { productionApi } from '../../production/api'
|
||||
import { storyboardApi } from '../api'
|
||||
import type { DesignedShot } from '../types'
|
||||
|
||||
/** 复用原生产计划和状态接口,只核对用户选择的镜头,不启动任何生产。 */
|
||||
const props = defineProps<{
|
||||
/** 当前正式项目。 */ projectId: string
|
||||
/** 所属抽屉是否打开,关闭时取消只读请求。 */ active: boolean
|
||||
/** 所选正式镜头。 */ shots: DesignedShot[]
|
||||
}>()
|
||||
/** 用户主动读取后才计算相对耗时的完整生产计划。 */
|
||||
const requested = ref(false)
|
||||
/** 范围或来源变化后立即废弃上一次准备结果。 */
|
||||
const identity = computed(() => JSON.stringify([props.projectId, props.shots]))
|
||||
watch(
|
||||
identity,
|
||||
() => {
|
||||
requested.value = false
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
/** 查询身份包含正式范围,离开或切换后不回填旧结果。 */
|
||||
const key = computed(() => (props.active && requested.value && props.shots.length ? identity.value : ''))
|
||||
/** 先读取轻量参考,避免完整计划占用服务时把引用误报为超时。 */
|
||||
const query = useQuery(key, async (value, signal) => {
|
||||
if (!value) return null
|
||||
const [, shots] = JSON.parse(value) as [string, DesignedShot[]]
|
||||
return { references: await Promise.allSettled(shots.map(shot => storyboardApi.references(shot.shotId, signal))) }
|
||||
})
|
||||
/** 完成参考查询后按需读取完整计划,不与另一个完整生产状态争抢。 */
|
||||
const planKey = computed(() => (key.value && query.updatedAt.value && !query.loading.value ? key.value : ''))
|
||||
/** 免费计划保留配置阻断及真实失败原因。 */
|
||||
const planQuery = useQuery(planKey, async (value, signal) => {
|
||||
if (!value) return null
|
||||
const [projectId] = JSON.parse(value) as [string]
|
||||
const result = await productionApi.plan(projectId, signal)
|
||||
if (!result || result.projectId !== projectId) throw new Error('生产计划未返回匹配的项目数据。')
|
||||
return result
|
||||
})
|
||||
/** 计划读取结束后再核对正式资产状态,包括计划失败的情况。 */
|
||||
const statusKey = computed(() =>
|
||||
planKey.value && !planQuery.loading.value && (planQuery.updatedAt.value || planQuery.error.value)
|
||||
? planKey.value
|
||||
: ''
|
||||
)
|
||||
/** 原资产读取只代表有效主资产,不由计划或任务完成推断。 */
|
||||
const statusQuery = useQuery(statusKey, async (value, signal) => {
|
||||
if (!value) return null
|
||||
const [projectId] = JSON.parse(value) as [string]
|
||||
const result = await productionApi.status(projectId, signal)
|
||||
if (!result || result.projectId !== projectId || typeof result.completed !== 'boolean')
|
||||
throw new Error('生产状态未返回匹配的项目数据。')
|
||||
return result
|
||||
})
|
||||
/** 当前计划查询成功后才能展示阶段结论。 */
|
||||
const plan = computed(() => (planQuery.error.value ? null : planQuery.data.value))
|
||||
/** 用户明确刷新时先废弃旧计划,然后重读同一范围。 */
|
||||
async function refreshPreparation() {
|
||||
requested.value = false
|
||||
await Promise.resolve()
|
||||
requested.value = true
|
||||
}
|
||||
/** 服务端定义的项目分阶段门禁,不根据局部镜头结果改写。 */
|
||||
const stageRows = computed(() =>
|
||||
[
|
||||
{ key: 'referenceImages' as const, label: '参考素材' },
|
||||
{ key: 'keyframes' as const, label: '首帧' },
|
||||
{ key: 'videos' as const, label: '视频' }
|
||||
].map(row => ({ ...row, value: plan.value?.stageReadiness?.[row.key] }))
|
||||
)
|
||||
/**
|
||||
* 展示后端逐镜准备状态,缺少明细时保留待确认。
|
||||
* @param status 正式准备状态
|
||||
* @returns 用户可读的阶段状态
|
||||
*/
|
||||
function stageLabel(status?: string) {
|
||||
return status === 'skipped'
|
||||
? '已有有效结果'
|
||||
: status === 'ready'
|
||||
? '可进入本阶段'
|
||||
: status === 'in_progress'
|
||||
? '正在执行'
|
||||
: status === 'blocked'
|
||||
? '需要准备'
|
||||
: '待确认'
|
||||
}
|
||||
/**
|
||||
* 按选择顺序读取正式参考结果,校验返回身份和数组结构。
|
||||
* @param index 所选镜头下标
|
||||
* @returns 真实结果或读取错误
|
||||
*/
|
||||
function referenceAt(index: number) {
|
||||
const result = query.data.value?.references[index]
|
||||
if (!result) return { error: '待核对', data: null }
|
||||
if (result.status === 'rejected') return { error: errorMessage(result.reason), data: null }
|
||||
const data = result.value
|
||||
return data &&
|
||||
data.shotId === props.shots[index]?.shotId &&
|
||||
Array.isArray(data.references) &&
|
||||
Array.isArray(data.missing)
|
||||
? { data, error: '' }
|
||||
: { error: '参考素材记录不完整,请重新读取。', data: null }
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是按用户选择范围进行的免费生产准备核对。 -->
|
||||
<section class="workspace-section-stack" aria-label="所选镜头生产准备">
|
||||
<WorkspaceSectionHeading title="所选镜头生产准备" description="只核对来源、参考素材和阶段缺口,不开始生成。">
|
||||
<template #actions
|
||||
><NButton
|
||||
:disabled="!shots.length"
|
||||
:loading="query.loading.value || planQuery.loading.value || statusQuery.loading.value"
|
||||
@click="refreshPreparation"
|
||||
>免费核对生产准备</NButton
|
||||
></template
|
||||
>
|
||||
</WorkspaceSectionHeading>
|
||||
<p v-if="!shots.length" class="text-xs text-muted">请先在镜头目录勾选要核对的镜头。</p>
|
||||
<p v-if="query.loading.value" role="status" class="text-xs text-muted">
|
||||
正在读取正式生产计划和所选镜头参考素材…
|
||||
</p>
|
||||
<p v-if="query.error.value" role="alert" class="text-sm">{{ query.error.value }}</p>
|
||||
<template v-if="query.data.value">
|
||||
<p v-if="planQuery.loading.value || statusQuery.loading.value" role="status" class="text-xs text-muted">
|
||||
正在核对项目阶段计划和正式资产,已读取的参考素材可先查看…
|
||||
</p>
|
||||
<p v-if="planQuery.error.value" role="alert">计划读取失败:{{ planQuery.error.value }}</p>
|
||||
<p v-if="statusQuery.error.value" role="alert">资产状态读取失败:{{ statusQuery.error.value }}</p>
|
||||
<p v-else-if="statusQuery.data.value" class="text-xs text-muted">
|
||||
全项目资产:{{
|
||||
statusQuery.data.value.completed ? '已完成' : '尚未完成'
|
||||
}}。局部镜头准备完成不代表项目可批量生产。
|
||||
</p>
|
||||
<!-- 以下是完整项目的分阶段门禁,不能代替单镜最终预览。 -->
|
||||
<div v-if="plan" class="space-y-2 text-sm">
|
||||
<p>
|
||||
项目生产入口:{{
|
||||
typeof plan.entryReadiness?.ready !== 'boolean'
|
||||
? '待确认'
|
||||
: plan.entryReadiness.ready
|
||||
? '已就绪'
|
||||
: '未就绪'
|
||||
}}<span v-if="plan.entryReadiness?.reason">
|
||||
· {{ userFacingText(plan.entryReadiness.reason) }}</span
|
||||
>
|
||||
</p>
|
||||
<p v-for="row in stageRows" :key="row.key">
|
||||
{{ row.label }}:{{ stageLabel(row.value?.status)
|
||||
}}<span v-if="row.value?.reason"> · {{ userFacingText(row.value.reason) }}</span>
|
||||
</p>
|
||||
</div>
|
||||
<NCollapse :default-expanded-names="['selected-preparation']">
|
||||
<NCollapseItem name="selected-preparation" title="逐镜缺口">
|
||||
<section v-for="(shot, index) in shots" :key="shot.shotId" class="py-3 space-y-2 text-sm">
|
||||
<h4 class="font-medium">镜头 {{ shot.beatNo }}.{{ shot.shotNo }} · {{ shot.title }}</h4>
|
||||
<p v-if="referenceAt(index).error">参考素材:{{ referenceAt(index).error }}</p>
|
||||
<template v-else-if="referenceAt(index).data">
|
||||
<p>
|
||||
参考素材:{{
|
||||
referenceAt(index).data!.missing.length ? '参考素材缺失' : '当前引用齐备'
|
||||
}}
|
||||
· 已有 {{ referenceAt(index).data!.references.length }} 项
|
||||
</p>
|
||||
<p v-for="missing in referenceAt(index).data!.missing" :key="missing.subjectId">
|
||||
{{ missing.subjectName }}:{{ userFacingText(missing.reason) }}
|
||||
</p>
|
||||
</template>
|
||||
<div
|
||||
v-for="stage in ['keyframes', 'videoPrompts', 'videos'] as const"
|
||||
:key="stage"
|
||||
class="space-y-1"
|
||||
>
|
||||
<p>
|
||||
{{
|
||||
stage === 'keyframes' ? '首帧' : stage === 'videoPrompts' ? '视频描述' : '视频'
|
||||
}}:{{
|
||||
stageLabel(
|
||||
plan?.details?.[stage]?.find(item => item.shotId === shot.shotId)?.status
|
||||
)
|
||||
}}
|
||||
</p>
|
||||
<p
|
||||
v-for="(issue, issueIndex) in plan?.details?.[stage]?.find(
|
||||
item => item.shotId === shot.shotId
|
||||
)?.issues ?? []"
|
||||
:key="issueIndex"
|
||||
class="text-xs text-muted"
|
||||
>
|
||||
{{ userFacingText(issue.reason) }}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<p class="text-xs text-muted">
|
||||
生图前请进入本镜首帧入口,重新预览正式来源、原参考图、实际模型及持续授权。生成、视觉审核和主图确认分别执行。
|
||||
</p>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,6 +1,8 @@
|
||||
import { keyframeScope } from '../production/keyframe-scope'
|
||||
import { request } from '../../lib/http'
|
||||
import type {
|
||||
DirectionReviewInput,
|
||||
DirectionReviewResult,
|
||||
DerivedReviewSelection,
|
||||
DraftProviderInput,
|
||||
ShotDraftPreview,
|
||||
@@ -11,6 +13,18 @@ import type {
|
||||
|
||||
/** 已审摄影草案的正式读写入口。 */
|
||||
export const derivedReviewApi = {
|
||||
/**
|
||||
* 沿原采用接口免费预检或采用独立摄影,不生成画面状态。
|
||||
* @param projectId 正式项目
|
||||
* @param body 原摄影版本、正式确认与同一草案
|
||||
* @param signal 取消过期的免费预检
|
||||
* @returns 摄影阶段的版本绑定与幂等回执
|
||||
*/
|
||||
direction: (projectId: string, body: DirectionReviewInput, signal?: AbortSignal) =>
|
||||
request<DirectionReviewResult>(
|
||||
`/projects/${encodeURIComponent(projectId)}/storyboard-derived-reviews/confirm`,
|
||||
{ method: 'POST', body, signal }
|
||||
),
|
||||
/** 读取指定镜头已保存的原稿,无草案时返回空。 */
|
||||
draft: (projectId: string, shotId: string, signal?: AbortSignal) =>
|
||||
request<SavedKeyframeDraft | null>(
|
||||
|
||||
@@ -95,3 +95,40 @@ export interface SaveKeyframeDraft {
|
||||
/** 本次原模型参数。 */ providerInput?: DraftProviderInput
|
||||
/** 受控修订绑定的正式来源。 */ expectedCurrentFormalSourceFingerprint?: string
|
||||
}
|
||||
|
||||
/** 摄影阶段独立修订的完整原版本与草案,不包含虚构的画面状态。 */
|
||||
export interface DirectionReviewSelection {
|
||||
/** 正式镜头身份。 */ shotId: string
|
||||
/** 已读取的原摄影记录身份。 */ expectedDirectionId: string
|
||||
/** 已读取的原摄影更新时间,原样回传。 */ expectedDirectionUpdatedAt: string
|
||||
/** 原摄影原文,保持字符串与 null。 */ expectedDirectionRawJson: string | null
|
||||
/** 原枚举及完整摄影字段,仅修改用户编辑的内容。 */ direction: ShotDirection & {
|
||||
/** 段落内镜号。 */ shotNo: number
|
||||
}
|
||||
}
|
||||
|
||||
/** 独立摄影免费预检与正式采用请求。 */
|
||||
export interface DirectionReviewInput {
|
||||
/** 仅修改摄影阶段。 */ phase: 'direction'
|
||||
/** 免费预检不写入。 */ preview: boolean
|
||||
/** 实际审核署名。 */ reviewer: string
|
||||
/** 正式确认中的分镜版本。 */ expectedShotFingerprint: string
|
||||
/** 正式采用必须绑定原免费预检。 */ expectedSourceFingerprint?: string
|
||||
/** 一到十二个不重复的正式镜头。 */ shots: DirectionReviewSelection[]
|
||||
}
|
||||
|
||||
/** 原采用接口在摄影阶段返回的幂等回执。 */
|
||||
export interface DirectionReviewResult {
|
||||
/** 所属项目。 */ projectId: string
|
||||
/** 独立摄影阶段。 */ phase: 'direction'
|
||||
/** 是否只读预检。 */ preview: boolean
|
||||
/** 绑定当前摄影、主体与来源的版本。 */ sourceFingerprint: string
|
||||
/** 正式采用是否写入变化,预检始终为 false。 */ changed: boolean
|
||||
/** 每镜正式采用情况。 */ shots: Array<{
|
||||
/** 正式镜头。 */ shotId: string
|
||||
/** 正式摄影身份。 */ directionId: string
|
||||
/** 当前摄影更新时间。 */ updatedAt: string
|
||||
/** 是否实际更新。 */ changed: boolean
|
||||
/** 是否已经采用相同草案。 */ alreadyApplied: boolean
|
||||
}>
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
import type { ProductionEntryReadiness } from '../storyboard-preparation/types'
|
||||
import type { WorkflowExecution } from '../workflows/execution.types'
|
||||
import type { DesignedShot, StoryboardBatchInput } from './types'
|
||||
|
||||
/** 可独立执行的派生阶段。 */
|
||||
export type DerivedPhase = 'direction' | 'visualState'
|
||||
/** 范围状态以正式读取为准,未知与缺失分别展示。 */
|
||||
export type DerivedState = 'current' | 'missing' | 'stale' | 'unknown'
|
||||
/** 原批次的镜头状态,不作为业务质量结论。 */
|
||||
export type DerivedTaskState = 'running' | 'stopped' | 'failed' | 'unresolved' | null
|
||||
|
||||
/**
|
||||
* 读取单镜正式状态;旧接口缺少逐镜过期信息时保守保留待核对。
|
||||
* @param shot 当前正式镜头
|
||||
* @param phase 派生阶段
|
||||
* @param staleCount 当前集该阶段的真实过期数
|
||||
* @param entry 当前项目的正式入口结果
|
||||
* @returns 正式有效、缺失、过期或待核对
|
||||
*/
|
||||
export function derivedState(
|
||||
shot: DesignedShot,
|
||||
phase: DerivedPhase,
|
||||
staleCount: number | undefined,
|
||||
entry?: ProductionEntryReadiness | null
|
||||
): DerivedState {
|
||||
if (!shot[phase]) return 'missing'
|
||||
const gap = entry?.derivedAssetShotGaps?.find(item => item.shotId === shot.shotId)
|
||||
if (gap) return gap[phase]
|
||||
return staleCount === 0 ? 'current' : 'unknown'
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅按服务端记录的镜头范围关联执行,保留未知请求和停止语义。
|
||||
* @param execution 原任务记录
|
||||
* @param shotId 正式镜头身份
|
||||
* @param episodeNo 当前集号
|
||||
* @returns 本镜所属任务状态或无关联
|
||||
*/
|
||||
export function derivedTaskState(
|
||||
execution: WorkflowExecution | null,
|
||||
shotId: string,
|
||||
episodeNo: number
|
||||
): DerivedTaskState {
|
||||
if (!execution) return null
|
||||
const metadata = execution.metadata ?? {}
|
||||
if (typeof metadata.episodeNo === 'number' && metadata.episodeNo !== episodeNo) return null
|
||||
if (Array.isArray(metadata.shotIds) && !metadata.shotIds.includes(shotId)) return null
|
||||
if (execution.status === 'running' || execution.status === 'pending') return 'running'
|
||||
const text = JSON.stringify(execution.result) + (execution.error ?? '')
|
||||
if (text.includes('STORYBOARD_DERIVED_REQUEST_UNRESOLVED')) return 'unresolved'
|
||||
if (execution.stage === 'stopped' || execution.result?.stoppedByUser === true) return 'stopped'
|
||||
return execution.status === 'failed' ? 'failed' : null
|
||||
}
|
||||
|
||||
/**
|
||||
* 固定用户确认的正式范围,拒绝空选、重复或跨集镜头。
|
||||
* @param scope 用户选择的范围模式
|
||||
* @param shotIds 当前勾选的正式镜头
|
||||
* @param shots 当前集正式目录
|
||||
* @param episodeNo 当前集号
|
||||
* @param concurrency 并发数
|
||||
* @param force 是否明确覆盖
|
||||
* @returns 不包含占位或重复镜头的正式请求
|
||||
*/
|
||||
export function derivedBatchInput(
|
||||
scope: 'selected' | 'episode' | 'project',
|
||||
shotIds: string[],
|
||||
shots: DesignedShot[],
|
||||
episodeNo: number,
|
||||
concurrency: number,
|
||||
force: boolean
|
||||
): StoryboardBatchInput {
|
||||
if (!Number.isSafeInteger(concurrency) || concurrency < 1) throw new Error('请填写有效的并发数。')
|
||||
if (scope !== 'project' && (!Number.isSafeInteger(episodeNo) || episodeNo < 1))
|
||||
throw new Error('请先选择正式剧集。')
|
||||
if (scope === 'selected') {
|
||||
if (!shotIds.length || new Set(shotIds).size !== shotIds.length) throw new Error('请选择不重复的正式镜头。')
|
||||
if (shotIds.some(id => !shots.some(shot => shot.shotId === id)))
|
||||
throw new Error('所选镜头已不属于当前集,请刷新目录后重新选择。')
|
||||
}
|
||||
return {
|
||||
concurrency,
|
||||
force,
|
||||
...(scope !== 'project' ? { episodeNo } : {}),
|
||||
...(scope === 'selected' ? { shotIds: [...shotIds] } : {})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 原已领取但未收回结果的范围不能因停止或覆盖而再次收费。
|
||||
* @param execution 原派生任务
|
||||
* @param episodeNo 本次集号,省略表示全项目
|
||||
* @param shotIds 本次正式镜头,省略表示整个所选集或项目
|
||||
* @returns 本次范围是否存在结果未知的领取
|
||||
*/
|
||||
export function unresolvedDerivedRequest(execution: WorkflowExecution | null, episodeNo?: number, shotIds?: string[]) {
|
||||
const metadata = execution?.metadata
|
||||
if (!metadata) return false
|
||||
const matchesEpisode =
|
||||
episodeNo === undefined || typeof metadata.episodeNo !== 'number' || metadata.episodeNo === episodeNo
|
||||
const matchesShots =
|
||||
!shotIds ||
|
||||
!Array.isArray(metadata.shotIds) ||
|
||||
shotIds.some(shotId => (metadata.shotIds as unknown[]).includes(shotId))
|
||||
if (
|
||||
matchesEpisode &&
|
||||
matchesShots &&
|
||||
((execution?.error ?? '') + JSON.stringify(execution?.result)).includes('STORYBOARD_DERIVED_REQUEST_UNRESOLVED')
|
||||
)
|
||||
return true
|
||||
if (!Array.isArray(metadata.claims)) return false
|
||||
return metadata.claims.some((claim: unknown) => {
|
||||
if (!claim || typeof claim !== 'object' || !('state' in claim) || claim.state !== 'submitted') return false
|
||||
const scope = claim as Record<string, unknown>
|
||||
const claimEpisode = typeof scope.episodeNo === 'number' ? scope.episodeNo : metadata.episodeNo
|
||||
if (episodeNo !== undefined && typeof claimEpisode === 'number' && episodeNo !== claimEpisode) return false
|
||||
const ids = Array.isArray(scope.shotIds) ? scope.shotIds : metadata.shotIds
|
||||
return !shotIds || !Array.isArray(ids) || shotIds.some(shotId => ids.includes(shotId))
|
||||
})
|
||||
}
|
||||
@@ -2,13 +2,27 @@ import type { EpisodeShots } from '../breakdown/types'
|
||||
|
||||
/** 导演摄影设计的正式数据库字段。 */
|
||||
export interface ShotDirection {
|
||||
/** 正式摄影记录身份,编辑前必须重新读取并核对。 */
|
||||
id?: string
|
||||
/** 正式摄影更新时间,采用时原样回传。 */
|
||||
updatedAt?: string
|
||||
/** 正式摄影原文,采用时保留 null 与原始字符串。 */
|
||||
rawJson?: string | null
|
||||
/** 正式景别。 */
|
||||
shotSize: string
|
||||
/** 正式摄影角度。 */
|
||||
cameraAngle: string
|
||||
/** 正式运镜方式。 */
|
||||
cameraMovement: string
|
||||
/** 画面构图原文。 */
|
||||
composition: string
|
||||
/** 摄影机位置原文。 */
|
||||
cameraPosition: string
|
||||
/** 正式焦段倾向。 */
|
||||
lensIntent: string
|
||||
/** 正式景深倾向。 */
|
||||
depthOfField: string
|
||||
/** 摄影视觉意图原文。 */
|
||||
visualIntent: string
|
||||
}
|
||||
|
||||
@@ -103,7 +117,11 @@ export interface StoryboardBatchResult {
|
||||
|
||||
/** 批处理配置:默认跳过完成项,force 才覆盖。 */
|
||||
export interface StoryboardBatchInput {
|
||||
/** 正式镜头范围;省略时沿用原批量语义,不允许空数组或重复。 */
|
||||
shotIds?: string[]
|
||||
/** 本批最大并发数量。 */
|
||||
concurrency: number
|
||||
/** 用户明确开启后覆盖本次范围的已有结果。 */
|
||||
force: boolean
|
||||
/** 可选试跑剧集范围。 */
|
||||
episodeNo?: number
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import { derivedBatchInput, derivedState, unresolvedDerivedRequest, type DerivedPhase } from './staged-derived'
|
||||
import type { WorkflowExecution } from '../workflows/execution.types'
|
||||
import { workflowExecutionApi } from '../workflows/execution-api'
|
||||
import { useShotSelection } from './useShotSelection'
|
||||
import { useWorkflowExecution } from '../workflows/execution'
|
||||
import type { StoryboardBatchResult, PromptBatchResult, StoryboardShotRegenerationResult } from './types'
|
||||
import { ApiError } from '../../lib/http'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useQuery } from '../../composables/useQuery'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
@@ -23,16 +27,87 @@ export type StoryboardCommand = 'shots-current' | 'direction-all' | 'visual-all'
|
||||
/** 分镜查询、依赖判断与操作入口;不修改后端 graph。 */
|
||||
export function useStoryboard() {
|
||||
const context = useProjectContext()
|
||||
/** 用户勾选的正式镜头;切换项目或集后清空。 */
|
||||
const checkedShotIds = ref<string[]>([])
|
||||
/** 默认只处理所选镜头,旧全项目批量需用户明确选择。 */
|
||||
const generationScope = ref<'selected' | 'episode' | 'project'>('selected')
|
||||
/** 本地只保存原待核对请求的范围与任务身份,不代替服务端执行状态。 */
|
||||
const pendingSubmission = ref<{
|
||||
/** 原工作流名称。 */ workflowName: string
|
||||
/** 提交前已知的旧执行,避免误认历史任务。 */ previousExecutionId: string
|
||||
/** 用户已确认的真实范围。 */ batch: { episodeNo?: number; shotIds?: string[] }
|
||||
} | null>(null)
|
||||
/** 提交回执未知时保持禁止重复发送,刷新页面后也不解除。 */
|
||||
const submissionUnknown = computed(() => pendingSubmission.value !== null)
|
||||
/** 正式镜头与候选来源仍由完整拆解记录判断。 */
|
||||
const breakdownRecords = context.useWorkflowCheckpoints('breakdown')
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const id = computed(() => context.project.value?.id ?? '')
|
||||
/**
|
||||
* 保存待核对请求,明确按原项目隔离,切换项目不串写。
|
||||
* @param projectId 原请求所属项目
|
||||
* @param value 尚未核清的请求或已核清状态
|
||||
*/
|
||||
function setPendingSubmission(projectId: string, value: typeof pendingSubmission.value) {
|
||||
if (id.value === projectId) pendingSubmission.value = value
|
||||
try {
|
||||
const storageKey = `short-drama:derived-submission:${projectId}`
|
||||
if (value) localStorage.setItem(storageKey, JSON.stringify(value))
|
||||
else localStorage.removeItem(storageKey)
|
||||
} catch {
|
||||
/* 存储受限时仍保留当前会话的重复请求保护。 */
|
||||
}
|
||||
}
|
||||
/** 刷新页面恢复原待核对范围,不通过自动重发来恢复。 */
|
||||
watch(
|
||||
id,
|
||||
projectId => {
|
||||
pendingSubmission.value = null
|
||||
try {
|
||||
const saved = JSON.parse(localStorage.getItem(`short-drama:derived-submission:${projectId}`) ?? 'null')
|
||||
if (
|
||||
saved &&
|
||||
['storyboard-direction', 'storyboard-visual-state'].includes(saved.workflowName) &&
|
||||
typeof saved.previousExecutionId === 'string' &&
|
||||
saved.batch &&
|
||||
typeof saved.batch === 'object'
|
||||
)
|
||||
pendingSubmission.value = saved
|
||||
} catch {
|
||||
/* 损坏记录不构造假的任务身份。 */
|
||||
}
|
||||
},
|
||||
{ immediate: true, flush: 'sync' }
|
||||
)
|
||||
/**
|
||||
* 只核对与原范围一致的新执行,不能将旧历史误当作提交成功。
|
||||
* @param record 服务端发现的真实工作流
|
||||
* @returns 当前记录是否属于待核对请求
|
||||
*/
|
||||
function recognizeSubmission(record: WorkflowExecution) {
|
||||
const pending = pendingSubmission.value
|
||||
if (
|
||||
!pending ||
|
||||
record.projectId !== id.value ||
|
||||
record.workflowName !== pending.workflowName ||
|
||||
record.id === pending.previousExecutionId
|
||||
)
|
||||
return false
|
||||
if (
|
||||
record.metadata?.episodeNo !== pending.batch.episodeNo ||
|
||||
JSON.stringify(record.metadata?.shotIds) !== JSON.stringify(pending.batch.shotIds)
|
||||
)
|
||||
return false
|
||||
setPendingSubmission(record.projectId, null)
|
||||
return true
|
||||
}
|
||||
|
||||
/** 两个镜头工作区共用地址选择,刷新恢复同一正式镜头。 */
|
||||
const { selectedEpisode, selectedShot } = useShotSelection(() => episodeNo.value)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const concurrency = ref(2)
|
||||
const concurrency = ref(1)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const maxRepairAttempts = ref(2)
|
||||
const maxRepairAttempts = ref(0)
|
||||
/** 当前工作区的响应式状态或派生业务条件。 */
|
||||
const force = ref(false)
|
||||
/** 正式镜头查询只补充正式快照正文,不混入最新候选。 */
|
||||
@@ -69,6 +144,10 @@ export function useStoryboard() {
|
||||
storyboardApi.visualStates(projectId, number, signal)
|
||||
])
|
||||
if (
|
||||
!directions ||
|
||||
!visualStates ||
|
||||
!Array.isArray(directions.beats) ||
|
||||
!Array.isArray(visualStates.beats) ||
|
||||
directions.projectId !== projectId ||
|
||||
visualStates.projectId !== projectId ||
|
||||
directions.episodeNo !== number ||
|
||||
@@ -76,6 +155,38 @@ export function useStoryboard() {
|
||||
) {
|
||||
throw new Error('分镜查询返回了不匹配的项目或剧集,请刷新后重试。')
|
||||
}
|
||||
if (
|
||||
![directions.coverage, visualStates.coverage].every(
|
||||
value => typeof value === 'number' && Number.isFinite(value) && value >= 0 && value <= 1
|
||||
) ||
|
||||
directions.beats.some(beat => !Array.isArray(beat.shots)) ||
|
||||
visualStates.beats.some(beat => !Array.isArray(beat.shots))
|
||||
)
|
||||
throw new Error('分镜状态字段缺失,请重新读取;暂不允许生成。')
|
||||
const directionRows = directions.beats.flatMap(beat => beat.shots)
|
||||
const visualRows = visualStates.beats.flatMap(beat => beat.shots)
|
||||
if (
|
||||
directionRows.some(row => !row || !Object.hasOwn(row, 'direction') || row.direction === undefined) ||
|
||||
visualRows.some(row => !row || !Object.hasOwn(row, 'visualState') || row.visualState === undefined)
|
||||
)
|
||||
throw new Error('分镜状态字段缺失,请重新读取;暂不允许生成。')
|
||||
if (
|
||||
![
|
||||
directions.shotCount,
|
||||
directions.directionCount,
|
||||
directions.staleCount,
|
||||
visualStates.shotCount,
|
||||
visualStates.visualStateCount,
|
||||
visualStates.staleCount
|
||||
].every(count => Number.isSafeInteger(count) && count >= 0) ||
|
||||
directionRows.length !== directions.shotCount ||
|
||||
visualRows.length !== visualStates.shotCount ||
|
||||
directionRows.length !== visualRows.length ||
|
||||
new Set(directionRows.map(row => row.shotId)).size !== directionRows.length ||
|
||||
new Set(visualRows.map(row => row.shotId)).size !== visualRows.length ||
|
||||
directionRows.some(row => !row.shotId || !visualRows.some(visual => visual.shotId === row.shotId))
|
||||
)
|
||||
throw new Error('分镜状态记录不完整,请重新读取;暂不允许生成。')
|
||||
return { directions, visualStates }
|
||||
})
|
||||
const data = query.data
|
||||
@@ -88,10 +199,8 @@ export function useStoryboard() {
|
||||
() =>
|
||||
!approval.loading.value && !approval.error.value && currentStoryboardApproval(approval.data.value, id.value)
|
||||
)
|
||||
/** 仅在分镜页且项目设计尚未就绪时读取全项目覆盖,不为每次切换剧集重复查询。 */
|
||||
const designProject = computed(() =>
|
||||
approved.value && context.stageReadiness.value?.storyboard.ready === false ? id.value : ''
|
||||
)
|
||||
/** 分镜页独立读取项目覆盖和门禁,不为切换剧集重复查询。 */
|
||||
const designProject = computed(() => id.value)
|
||||
/** 全项目有效设计数量与制作前检查使用同一接口。 */
|
||||
const designEntry = useQuery(designProject, (projectId, signal) =>
|
||||
projectId ? preparationApi.entry(projectId, signal) : Promise.resolve(null)
|
||||
@@ -127,6 +236,92 @@ export function useStoryboard() {
|
||||
const shots = computed(() =>
|
||||
mergeDesignedShots(data.value?.directions ?? null, data.value?.visualStates ?? null, source.value)
|
||||
)
|
||||
/** 目录与集号共同约束选中范围,刷新后删除已失效的镜头身份。 */
|
||||
watch(
|
||||
queryKey,
|
||||
() => {
|
||||
checkedShotIds.value = []
|
||||
force.value = false
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
watch(shots, rows => {
|
||||
checkedShotIds.value = checkedShotIds.value.filter(shotId => rows.some(shot => shot.shotId === shotId))
|
||||
})
|
||||
/** 本次实际选中的镜头,不用预设镜号或历史快照代替正式身份。 */
|
||||
const selectedShots = computed(() => shots.value.filter(shot => checkedShotIds.value.includes(shot.shotId)))
|
||||
/** 本次范围说明同时用于按钮与费用确认,改变范围会撤销确认。 */
|
||||
const scopeLabel = computed(() =>
|
||||
generationScope.value === 'project'
|
||||
? '全项目'
|
||||
: generationScope.value === 'episode'
|
||||
? `第 ${episodeNo.value} 集`
|
||||
: `第 ${episodeNo.value} 集所选 ${checkedShotIds.value.length} 镜`
|
||||
)
|
||||
/**
|
||||
* 单镜状态只采用正式缺口与真实过期计数。
|
||||
* @param shot 当前正式镜头
|
||||
* @param phase 派生阶段
|
||||
* @returns 本镜正式来源状态
|
||||
*/
|
||||
function stateFor(shot: (typeof shots.value)[number], phase: DerivedPhase) {
|
||||
return derivedState(
|
||||
shot,
|
||||
phase,
|
||||
phase === 'direction' ? data.value?.directions.staleCount : data.value?.visualStates.staleCount,
|
||||
designEntry.error.value || designEntry.loading.value ? null : designEntry.data.value
|
||||
)
|
||||
}
|
||||
/** 所选范围与全项目门禁分开计算,只放行已核实的本次摄影。 */
|
||||
const rangeDirectionCurrent = computed(() => {
|
||||
if (generationScope.value === 'project') {
|
||||
const assets = designEntry.data.value?.derivedAssets
|
||||
return (
|
||||
!designEntry.loading.value &&
|
||||
!designEntry.error.value &&
|
||||
!!assets?.shotCount &&
|
||||
assets.directionCount === assets.shotCount &&
|
||||
assets.staleDirectionCount === 0
|
||||
)
|
||||
}
|
||||
const range = generationScope.value === 'selected' ? selectedShots.value : shots.value
|
||||
return range.length > 0 && range.every(shot => stateFor(shot, 'direction') === 'current')
|
||||
})
|
||||
/**
|
||||
* 有效结果全部具备时不再提交相同阶段,覆盖模式须单独确认。
|
||||
* @param phase 当前派生阶段
|
||||
* @returns 本次范围是否仍有待补齐结果
|
||||
*/
|
||||
function needsGeneration(phase: DerivedPhase) {
|
||||
if (force.value) return true
|
||||
if (generationScope.value === 'project') {
|
||||
const assets = designEntry.data.value?.derivedAssets
|
||||
if (!assets || designEntry.error.value || designEntry.loading.value) return false
|
||||
return phase === 'direction'
|
||||
? assets.directionCount !== assets.shotCount || assets.staleDirectionCount !== 0
|
||||
: assets.visualStateCount !== assets.shotCount || assets.staleVisualStateCount !== 0
|
||||
}
|
||||
const range = generationScope.value === 'selected' ? selectedShots.value : shots.value
|
||||
return range.some(shot => stateFor(shot, phase) !== 'current')
|
||||
}
|
||||
/** 处理范围必须已经选定且属于当前正式目录。 */
|
||||
const rangeValid = computed(
|
||||
() =>
|
||||
generationScope.value !== 'selected' ||
|
||||
(checkedShotIds.value.length > 0 && checkedShotIds.value.length === selectedShots.value.length)
|
||||
)
|
||||
/**
|
||||
* 只修改正式目录中的勾选项。
|
||||
* @param ids 用户切换的单镜或段落范围
|
||||
*/
|
||||
function toggleShots(ids: string[]) {
|
||||
if (operation.value.pending || query.loading.value) return
|
||||
if (ids.some(shotId => !shots.value.some(shot => shot.shotId === shotId))) return
|
||||
const remove = ids.every(shotId => checkedShotIds.value.includes(shotId))
|
||||
checkedShotIds.value = remove
|
||||
? checkedShotIds.value.filter(shotId => !ids.includes(shotId))
|
||||
: [...new Set([...checkedShotIds.value, ...ids])]
|
||||
}
|
||||
/** 明确指定的镜头不存在时不代选其它镜头;首次进入才选择第一镜。 */
|
||||
const shot = computed(() =>
|
||||
selectedShot.value ? shots.value.find(item => item.shotId === selectedShot.value) : shots.value[0]
|
||||
@@ -143,6 +338,8 @@ export function useStoryboard() {
|
||||
const blocked = computed(
|
||||
() =>
|
||||
operation.value.pending ||
|
||||
submissionUnknown.value ||
|
||||
query.loading.value ||
|
||||
!!context.error.value ||
|
||||
context.summaryBlocked.value ||
|
||||
breakdownRecords.loading.value ||
|
||||
@@ -179,31 +376,46 @@ export function useStoryboard() {
|
||||
context.stageReadiness.value?.projectId === id.value &&
|
||||
context.stageReadiness.value.subjectAssets.ready === true
|
||||
)
|
||||
/** 批量操作继续使用原项目级前置条件。 */
|
||||
/**
|
||||
* 只阻断本次范围未收回的模型请求,停止不解除费用核对。
|
||||
* @param phase 当前派生阶段
|
||||
* @returns 是否存在重发风险
|
||||
*/
|
||||
function unresolvedRequest(phase: DerivedPhase) {
|
||||
return unresolvedDerivedRequest(
|
||||
executions[phase === 'direction' ? 1 : 2]!.observer.query.data.value,
|
||||
generationScope.value === 'project' ? undefined : episodeNo.value,
|
||||
generationScope.value === 'selected' ? checkedShotIds.value : undefined
|
||||
)
|
||||
}
|
||||
/** 派生使用本次正式范围,旧拆镜与视频描述继续遵守项目素材门禁。 */
|
||||
const allowed = computed<Record<StoryboardCommand, boolean>>(() => ({
|
||||
'shots-current':
|
||||
projectAssetsReady.value && !blocked.value && episodeNo.value > 0 && hasCurrentEpisodeShots.value,
|
||||
'direction-all':
|
||||
projectAssetsReady.value &&
|
||||
approved.value &&
|
||||
!blocked.value &&
|
||||
prerequisites.value.directionProject &&
|
||||
batchValid.value,
|
||||
'visual-all':
|
||||
projectAssetsReady.value &&
|
||||
approved.value &&
|
||||
!blocked.value &&
|
||||
prerequisites.value.visualProject &&
|
||||
batchValid.value &&
|
||||
repairsValid.value,
|
||||
rangeValid.value &&
|
||||
needsGeneration('direction') &&
|
||||
!unresolvedRequest('direction'),
|
||||
'visual-all':
|
||||
approved.value &&
|
||||
!blocked.value &&
|
||||
batchValid.value &&
|
||||
repairsValid.value &&
|
||||
rangeValid.value &&
|
||||
rangeDirectionCurrent.value &&
|
||||
needsGeneration('visualState') &&
|
||||
!unresolvedRequest('visualState'),
|
||||
prompts: projectAssetsReady.value && !blocked.value && shots.value.length > 0 && batchValid.value
|
||||
}))
|
||||
|
||||
/** 正式后台任务观察器;重生成使用后端 breakdown 名称并通过 metadata 区分。 */
|
||||
const executions = [
|
||||
{ title: '单集镜头重生成', observer: useWorkflowExecution(id, 'breakdown') },
|
||||
{ title: '项目导演设计', observer: useWorkflowExecution(id, 'storyboard-direction') },
|
||||
{ title: '项目即时状态', observer: useWorkflowExecution(id, 'storyboard-visual-state') },
|
||||
{ title: '摄影设计任务', observer: useWorkflowExecution(id, 'storyboard-direction') },
|
||||
{ title: '画面状态任务', observer: useWorkflowExecution(id, 'storyboard-visual-state') },
|
||||
{ title: '项目视频提示词', observer: useWorkflowExecution(id, 'video-prompt') }
|
||||
]
|
||||
/** 真实终态结果才发布回执;刷新恢复也按后端 metadata 归属。 */
|
||||
@@ -211,7 +423,9 @@ export function useStoryboard() {
|
||||
watch(
|
||||
() => entry.observer.query.data.value,
|
||||
(record, previous) => {
|
||||
if (!record || record.projectId !== id.value || !['completed', 'failed'].includes(record.status)) return
|
||||
if (!record || record.projectId !== id.value) return
|
||||
recognizeSubmission(record)
|
||||
if (!['completed', 'failed'].includes(record.status)) return
|
||||
const target = getStoryboardSession(record.projectId)
|
||||
if (index === 0 && record.metadata?.action !== 'regenerate-storyboard-episode') return
|
||||
if (record.result && (record.status === 'completed' || index === 1 || index === 2)) {
|
||||
@@ -238,13 +452,14 @@ export function useStoryboard() {
|
||||
target.receipt = { kind: 'prompts', title: entry.title, result }
|
||||
} else {
|
||||
const result = record.result as unknown as StoryboardBatchResult
|
||||
if (result.projectId !== record.projectId || !Array.isArray(result.episodes)) return
|
||||
target.receipt = { kind: 'batch', title: entry.title, result }
|
||||
if (result.projectId === record.projectId && Array.isArray(result.episodes))
|
||||
target.receipt = { kind: 'batch', title: entry.title, result }
|
||||
}
|
||||
}
|
||||
if (!previous) return
|
||||
void Promise.all([
|
||||
query.refresh(),
|
||||
designEntry.refresh(),
|
||||
index === 0
|
||||
? context.refreshWorkflow('breakdown', record.projectId, record.id + ':' + record.status)
|
||||
: context.refreshWorkflow(null, record.projectId, record.id + ':' + record.status),
|
||||
@@ -254,19 +469,32 @@ export function useStoryboard() {
|
||||
)
|
||||
}
|
||||
|
||||
/** 捕获提交时的目标与配置,切换剧集不改变正在运行的请求或回执。 */
|
||||
/**
|
||||
* 捕获提交时的目标与配置,切换剧集不改变正在运行的请求或回执。
|
||||
* @param command 用户已确认的生成阶段
|
||||
*/
|
||||
async function run(command: StoryboardCommand) {
|
||||
if (!allowed.value[command]) return
|
||||
const projectId = id.value
|
||||
const batch = { concurrency: concurrency.value, force: force.value }
|
||||
const derived = command === 'direction-all' || command === 'visual-all'
|
||||
const batch = derived
|
||||
? derivedBatchInput(
|
||||
generationScope.value,
|
||||
checkedShotIds.value,
|
||||
shots.value,
|
||||
episodeNo.value,
|
||||
concurrency.value,
|
||||
force.value
|
||||
)
|
||||
: { concurrency: concurrency.value, force: force.value }
|
||||
const repairs = maxRepairAttempts.value
|
||||
const targetEpisode = episodeNo.value
|
||||
const target = getStoryboardSession(projectId)
|
||||
const expectedApproval = JSON.stringify(approval.data.value?.evidence)
|
||||
const titles: Record<StoryboardCommand, string> = {
|
||||
'shots-current': `第 ${targetEpisode} 集镜头`,
|
||||
'direction-all': '项目导演设计',
|
||||
'visual-all': '项目即时状态',
|
||||
'direction-all': `${scopeLabel.value}摄影设计`,
|
||||
'visual-all': `${scopeLabel.value}画面状态`,
|
||||
prompts: '项目视频提示词'
|
||||
}
|
||||
target.receipt = null
|
||||
@@ -292,13 +520,57 @@ export function useStoryboard() {
|
||||
terminal ? record.id + ':' + record.status : undefined
|
||||
)
|
||||
} else if (command === 'direction-all') {
|
||||
setPendingSubmission(projectId, {
|
||||
workflowName: 'storyboard-direction',
|
||||
previousExecutionId: executions[1]!.observer.executionId.value,
|
||||
batch
|
||||
})
|
||||
const started = await storyboardApi.generateDirections(projectId, batch)
|
||||
if (!started?.executionId) throw new Error('未收到可核对的任务回执,请先读取原任务状态。')
|
||||
setPendingSubmission(projectId, null)
|
||||
await executions[1]!.observer.track(started.executionId, projectId)
|
||||
} else if (command === 'visual-all') {
|
||||
const fresh = await storyboardApi.directions(projectId, targetEpisode)
|
||||
const freshEntry = await preparationApi.entry(projectId)
|
||||
if (!freshEntry?.derivedAssets) throw new Error('准备状态未返回有效结果,请重新读取。')
|
||||
if (
|
||||
batch.episodeNo &&
|
||||
fresh.staleCount !== 0 &&
|
||||
(!batch.shotIds ||
|
||||
batch.shotIds.some(
|
||||
shotId =>
|
||||
freshEntry.derivedAssetShotGaps?.find(item => item.shotId === shotId)?.direction !==
|
||||
'current'
|
||||
))
|
||||
)
|
||||
throw new Error('本次范围的摄影来源未确认有效,请刷新并核对。')
|
||||
if (
|
||||
!batch.episodeNo &&
|
||||
(freshEntry.derivedAssets.directionCount !== freshEntry.derivedAssets.shotCount ||
|
||||
freshEntry.derivedAssets.staleDirectionCount !== 0)
|
||||
)
|
||||
throw new Error('请先补齐全项目当前有效摄影。')
|
||||
const freshRows = fresh.beats.flatMap(beat => beat.shots)
|
||||
if (batch.shotIds?.some(shotId => !freshRows.some(row => row.shotId === shotId)))
|
||||
throw new Error('所选镜头来源已变化,请重新读取正式目录。')
|
||||
if (
|
||||
batch.episodeNo &&
|
||||
freshRows
|
||||
.filter(row => !batch.shotIds || batch.shotIds.includes(row.shotId))
|
||||
.some(row => !row.direction)
|
||||
)
|
||||
throw new Error('请先补齐本次范围的摄影设计。')
|
||||
setPendingSubmission(projectId, {
|
||||
workflowName: 'storyboard-visual-state',
|
||||
previousExecutionId: executions[2]!.observer.executionId.value,
|
||||
batch
|
||||
})
|
||||
const started = await storyboardApi.generateVisualStates(projectId, {
|
||||
...batch,
|
||||
maxRepairAttempts: repairs
|
||||
})
|
||||
if (!started?.executionId) throw new Error('未收到可核对的任务回执,请先读取原任务状态。')
|
||||
setPendingSubmission(projectId, null)
|
||||
await executions[2]!.observer.track(started.executionId, projectId)
|
||||
} else {
|
||||
target.prompts = {}
|
||||
@@ -306,16 +578,50 @@ export function useStoryboard() {
|
||||
await executions[3]!.observer.track(started.executionId, projectId)
|
||||
}
|
||||
})
|
||||
const cause = getOperation(projectId).cause
|
||||
if (!submitted && cause instanceof ApiError && cause.status >= 400 && cause.status < 500)
|
||||
setPendingSubmission(projectId, null)
|
||||
if (id.value !== projectId) return
|
||||
await Promise.all([
|
||||
query.refresh(),
|
||||
designEntry.refresh(),
|
||||
context.refreshStageReadiness(),
|
||||
submitted && command !== 'shots-current' ? context.summaryQuery.refresh() : Promise.resolve()
|
||||
])
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅免费读取待核对原任务,不重新提交生成。
|
||||
* @returns 是否找到范围一致的原执行;无待核对请求时不处理
|
||||
*/
|
||||
async function inspectSubmission() {
|
||||
const pending = pendingSubmission.value
|
||||
const projectId = id.value
|
||||
if (!pending) return
|
||||
const record = await workflowExecutionApi.latest(projectId, pending.workflowName)
|
||||
if (id.value !== projectId) return false
|
||||
if (!record || !recognizeSubmission(record)) return false
|
||||
const entry =
|
||||
executions.find(item => item.observer.query.data.value?.workflowName === record.workflowName) ??
|
||||
executions[pending.workflowName === 'storyboard-direction' ? 1 : 2]!
|
||||
await entry.observer.track(record.id, projectId)
|
||||
return true
|
||||
}
|
||||
|
||||
return {
|
||||
id,
|
||||
inspectSubmission,
|
||||
checkedShotIds,
|
||||
generationScope,
|
||||
selectedShots,
|
||||
scopeLabel,
|
||||
stateFor,
|
||||
needsGeneration,
|
||||
unresolvedRequest,
|
||||
toggleShots,
|
||||
rangeDirectionCurrent,
|
||||
designEntry,
|
||||
submissionUnknown,
|
||||
selectedEpisode,
|
||||
episodeNo,
|
||||
episodeOptions,
|
||||
|
||||
@@ -11,6 +11,8 @@ const props = defineProps<{
|
||||
description: string
|
||||
/** 费用与覆盖确认默认警告;调用方可按真实语义使用默认、成功或错误状态。 */
|
||||
status?: 'default' | 'warning' | 'success' | 'error'
|
||||
/** 同数量的不同镜头或输入变化时,也撤销原费用确认。 */
|
||||
confirmationKey?: string
|
||||
/** 前置条件未满足时禁止操作。 */
|
||||
disabled?: boolean
|
||||
/** 当前操作请求是否仍在执行。 */
|
||||
@@ -35,7 +37,7 @@ function requestOpen() {
|
||||
}
|
||||
|
||||
/** 取消后重新打开,或确认目标改变,都必须重新确认任务与费用。 */
|
||||
watch([open, () => props.label, () => props.description], () => {
|
||||
watch([open, () => props.label, () => props.description, () => props.confirmationKey], () => {
|
||||
acknowledged.value = false
|
||||
})
|
||||
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import WorkspaceActionTooltip from '../../components/ui/WorkspaceActionTooltip.vue'
|
||||
import ConfirmAction from './ConfirmAction.vue'
|
||||
import { useQuery } from '../../composables/useQuery'
|
||||
import { workflowExecutionApi } from './execution-api'
|
||||
import { userFacingText } from '../../lib/user-facing-text'
|
||||
import ContextNotice from '../../components/ui/ContextNotice.vue'
|
||||
import WorkspaceSectionHeading from '../../components/ui/WorkspaceSectionHeading.vue'
|
||||
@@ -27,17 +31,63 @@ const props = withDefaults(
|
||||
embedded?: boolean
|
||||
/** 当前项目结果已更新时,旧创作任务只作为历史执行记录展示。 */
|
||||
resultIsHistorical?: boolean
|
||||
/** 当前观察器允许停止派生批次。 */
|
||||
canStop?: boolean
|
||||
/** 正在提交停止请求。 */
|
||||
stopping?: boolean
|
||||
/** 关联恢复历史只向原任务展开一层。 */
|
||||
showRecoveryHistory?: boolean
|
||||
}>(),
|
||||
{ title: '制作任务', showStatusHint: true, embedded: false, resultIsHistorical: false }
|
||||
{ title: '制作任务', showStatusHint: true, embedded: false, resultIsHistorical: false, showRecoveryHistory: true }
|
||||
)
|
||||
/** 刷新状态与隐藏任务记录事件。 */
|
||||
const emit = defineEmits<{ refresh: []; dismiss: [] }>()
|
||||
const emit = defineEmits<{ refresh: []; dismiss: []; stop: [] }>()
|
||||
const percentage = computed(() => executionPercentage(props.execution?.current ?? 0, props.execution?.total ?? 0))
|
||||
const result = computed(() => props.execution?.result ?? {})
|
||||
/** 导演设计和画面状态的逐集结果独立于任务执行终态。 */
|
||||
const derivedTask = computed(() =>
|
||||
['storyboard-direction', 'storyboard-visual-state'].includes(props.execution?.workflowName ?? '')
|
||||
)
|
||||
/** 用户停止与质量失败分开表达。 */
|
||||
const stopped = computed(
|
||||
() => derivedTask.value && (props.execution?.stage === 'stopped' || result.value.stoppedByUser === true)
|
||||
)
|
||||
/** 只有明确零模型请求的恢复回执才展示免费复用。 */
|
||||
const recovered = computed(
|
||||
() =>
|
||||
props.execution?.workflowName === 'storyboard-visual-state' &&
|
||||
props.execution.status === 'completed' &&
|
||||
typeof props.execution.metadata?.recoveryOf === 'string' &&
|
||||
result.value.recovered === true &&
|
||||
result.value.actualModelRequests === 0
|
||||
)
|
||||
/** 原失败执行的身份来自当前正式恢复记录,不由用户填写内部字段。 */
|
||||
const recoveryKey = computed(() =>
|
||||
props.showRecoveryHistory && props.execution && typeof props.execution.metadata?.recoveryOf === 'string'
|
||||
? JSON.stringify([props.execution.projectId, props.execution.metadata.recoveryOf])
|
||||
: ''
|
||||
)
|
||||
/** 免费读取原失败记录,原始错误和回执历史完整保留。 */
|
||||
const originalExecution = useQuery(recoveryKey, async (key, signal) => {
|
||||
if (!key) return null
|
||||
const [projectId, executionId] = JSON.parse(key) as [string, string]
|
||||
const record = await workflowExecutionApi.get(executionId, signal, projectId)
|
||||
if (
|
||||
!record ||
|
||||
record.id !== executionId ||
|
||||
record.projectId !== projectId ||
|
||||
record.workflowName !== 'storyboard-visual-state'
|
||||
)
|
||||
throw new Error('原执行记录与恢复来源不一致。')
|
||||
return record
|
||||
})
|
||||
/** 只统计正式领取状态,不将已收到结果等同质量通过。 */
|
||||
const claims = computed(() => {
|
||||
const rows = props.execution?.metadata?.claims
|
||||
return Array.isArray(rows)
|
||||
? rows.filter((row): row is Record<string, unknown> => !!row && typeof row === 'object' && !Array.isArray(row))
|
||||
: []
|
||||
})
|
||||
/** 部分失败和人工核对标记不能显示为全部完成。 */
|
||||
const derivedNeedsReview = computed(
|
||||
() =>
|
||||
@@ -55,11 +105,39 @@ const derivedEpisodes = computed(() => {
|
||||
{
|
||||
episodeNo: item.episodeNo,
|
||||
status: 'status' in item && typeof item.status === 'string' ? item.status : '',
|
||||
error: 'error' in item && typeof item.error === 'string' ? item.error : ''
|
||||
error: 'error' in item && typeof item.error === 'string' ? item.error : '',
|
||||
issues:
|
||||
'remainingIssues' in item && Array.isArray(item.remainingIssues)
|
||||
? item.remainingIssues.filter(
|
||||
(
|
||||
issue
|
||||
): issue is {
|
||||
episodeNo: number
|
||||
beatNo: number | null
|
||||
shotNo: number | null
|
||||
message: string
|
||||
} => !!issue && typeof issue === 'object' && typeof issue.message === 'string'
|
||||
)
|
||||
: []
|
||||
}
|
||||
]
|
||||
})
|
||||
})
|
||||
/**
|
||||
* 展示去重业务摘要,原完整记录仍保留在高级详情中。
|
||||
* @param value 原业务错误
|
||||
* @returns 可读且去重的原因
|
||||
*/
|
||||
function derivedErrorSummary(value: string) {
|
||||
return [
|
||||
...new Set(
|
||||
userFacingText(value)
|
||||
.split(/[;;]/)
|
||||
.map(text => text.trim())
|
||||
.filter(Boolean)
|
||||
)
|
||||
].join(';')
|
||||
}
|
||||
/** 只改变旧记录的展示语义,不改写原始任务或审核结果。 */
|
||||
const historical = computed(
|
||||
() => props.resultIsHistorical && ['completed', 'failed'].includes(props.execution?.status ?? '')
|
||||
@@ -118,6 +196,8 @@ const progressLabel = computed(() =>
|
||||
const statusLabel = computed(() => {
|
||||
const labels = { pending: '等待开始', running: '执行中', completed: '已完成', failed: '失败' }
|
||||
if (!props.execution) return ''
|
||||
if (stopped.value) return '已停止'
|
||||
if (recovered.value) return '已免费复用原回执'
|
||||
if (historical.value)
|
||||
return breakdownTask.value && props.execution.status === 'failed' ? '历史执行记录 · 失败' : '历史执行记录'
|
||||
if (derivedTask.value && ['completed', 'failed'].includes(props.execution.status))
|
||||
@@ -150,7 +230,7 @@ const staleMotionPlanCount = computed(() => {
|
||||
})
|
||||
/** 业务未通过或结果未知时,不把任务执行结束展示为全成功。 */
|
||||
const statusType = computed(() => {
|
||||
if (historical.value) return 'default'
|
||||
if (historical.value || stopped.value || recovered.value) return 'default'
|
||||
if (derivedTask.value)
|
||||
return props.execution?.status === 'failed' ? 'error' : derivedNeedsReview.value ? 'warning' : 'default'
|
||||
if (scriptCreation.value && props.execution?.status === 'completed')
|
||||
@@ -240,6 +320,7 @@ const scopeLabel = computed(() => {
|
||||
: metadata.inputModeFilter === 'omni_reference'
|
||||
? '全模态参考'
|
||||
: '全部推荐模式'
|
||||
if (derivedTask.value && Array.isArray(metadata.shotIds)) return `${episode} · 所选 ${metadata.shotIds.length} 镜`
|
||||
if (keyframeQuality.value && typeof metadata.shotId === 'string') return `${episode} · 单镜头`
|
||||
return videoQuality.value ? `${episode} · ${mode}` : episode
|
||||
})
|
||||
@@ -278,15 +359,21 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
<p v-if="scopeLabel && !breakdownTask" class="mt-1 text-xs text-muted">范围:{{ scopeLabel }}</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<NButton
|
||||
v-if="!embedded && (finished || error)"
|
||||
class="icon-button"
|
||||
quaternary
|
||||
aria-label="隐藏制作任务记录"
|
||||
title="隐藏制作任务记录"
|
||||
@click="emit('dismiss')"
|
||||
><X :size="15"
|
||||
/></NButton>
|
||||
<ConfirmAction
|
||||
v-if="derivedTask && canStop"
|
||||
label="停止后续生成"
|
||||
status="default"
|
||||
:loading="stopping"
|
||||
description="停止后不再领取后续模型请求。已发送请求仍可能返回结果并产生费用;停止不代表退款,也不授权重新收费。"
|
||||
@confirm="emit('stop')"
|
||||
/>
|
||||
<NButton v-if="derivedTask" size="small" :loading="loading" @click="emit('refresh')">刷新状态</NButton>
|
||||
<WorkspaceActionTooltip
|
||||
v-if="!embedded && showRecoveryHistory && (finished || error)"
|
||||
label="隐藏制作任务记录"
|
||||
><NButton class="icon-button" quaternary aria-label="隐藏制作任务记录" @click="emit('dismiss')"
|
||||
><X :size="15" /></NButton
|
||||
></WorkspaceActionTooltip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -318,6 +405,23 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
</template>
|
||||
|
||||
<template v-if="execution">
|
||||
<!-- 以下是派生批次的停止、原回执与免费恢复状态。 -->
|
||||
<div v-if="derivedTask" class="mt-3 space-y-2 text-xs leading-6" aria-label="模型请求与恢复状态">
|
||||
<p v-if="stopped">已停止后续生成。已发送请求及已返回结果保留;仍需核对在途结果和费用,不会自动重试。</p>
|
||||
<p v-if="recovered">
|
||||
已复用原结果完成免费恢复,新增模型请求 0 次。请重新核对正式画面状态;原失败历史保留。
|
||||
</p>
|
||||
<p v-if="claims.length">
|
||||
请求结果未知 {{ claims.filter(item => item.state === 'submitted').length }} 步 · 已收到结果
|
||||
{{ claims.filter(item => item.state === 'received').length }} 步。收到结果不代表质量通过。
|
||||
</p>
|
||||
<p v-else-if="!recovered">
|
||||
{{ finished ? '没有可确认的模型领取信息,不能据此判断未产生费用。' : '等待模型领取记录。' }}
|
||||
</p>
|
||||
<p v-if="execution.status === 'failed' && !stopped">
|
||||
原失败记录保留。原回执是否可信需受控核查,不会自动重新生成或重试。
|
||||
</p>
|
||||
</div>
|
||||
<!-- 以下是拆解任务的直接可见摘要,替代折叠详情和重复进度说明 -->
|
||||
<dl v-if="breakdownTask" class="mt-4 grid grid-cols-1 gap-x-6 gap-y-4 sm:grid-cols-2 xl:grid-cols-4">
|
||||
<div>
|
||||
@@ -370,7 +474,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
: '正在创作剧本'
|
||||
: '正在准备本次任务'
|
||||
}}</template>
|
||||
<template v-if="execution.currentResourceId && !scriptCreation && !breakdownTask">
|
||||
<template v-if="execution.currentResourceId && !scriptCreation && !breakdownTask && !derivedTask">
|
||||
· 当前镜头 <code>{{ execution.currentResourceId }}</code></template
|
||||
>
|
||||
</p>
|
||||
@@ -482,7 +586,7 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
</p>
|
||||
</ContextNotice>
|
||||
<ContextNotice
|
||||
v-else-if="execution.status === 'failed' && showStatusHint && !historical"
|
||||
v-else-if="execution.status === 'failed' && showStatusHint && !historical && !stopped"
|
||||
type="error"
|
||||
:show-icon="embedded || diagnosisRecovery || keyframeRecovery"
|
||||
:emphasized="embedded || diagnosisRecovery || keyframeRecovery"
|
||||
@@ -490,19 +594,33 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
:title="embedded ? '任务未完成' : undefined"
|
||||
class="mt-3"
|
||||
>
|
||||
<p>{{ userFacingText(execution.error) || '制作任务执行失败。' }}</p>
|
||||
<p>
|
||||
{{
|
||||
(derivedTask
|
||||
? derivedEpisodes.length
|
||||
? '派生执行未完成,请核对下方逐集原因。'
|
||||
: derivedErrorSummary(execution.error ?? '')
|
||||
: userFacingText(execution.error)) || '制作任务执行失败。'
|
||||
}}
|
||||
</p>
|
||||
<p class="mt-2 text-xs">
|
||||
{{
|
||||
diagnosisTask
|
||||
? '请先核对最新诊断记录。服务中断时还需确认费用,再决定是否手动重新诊断。'
|
||||
: scriptCreation
|
||||
? '请先核对已保存的剧本内容,处理报错原因后从当前阶段恢复生成或改写。'
|
||||
: '请先刷新相关资产状态,确认已成功的镜头;处理报错原因后,只对仍处于“可执行”的镜头重新提交。'
|
||||
: derivedTask
|
||||
? '请先核对已有结果、原回执和费用;未知请求不得重复提交。'
|
||||
: scriptCreation
|
||||
? '请先核对已保存的剧本内容,处理报错原因后从当前阶段恢复生成或改写。'
|
||||
: '请先刷新相关资产状态,确认已成功的镜头;处理报错原因后,只对仍处于“可执行”的镜头重新提交。'
|
||||
}}
|
||||
</p>
|
||||
</ContextNotice>
|
||||
<!-- 以下是派生任务的部分成功与失败明细,失败终态也保留已有结果 -->
|
||||
<div v-if="derivedTask && finished" class="mt-4 space-y-3 text-xs leading-6" aria-label="逐集设计结果">
|
||||
<div
|
||||
v-if="derivedTask && finished && !recovered && Array.isArray(result.episodes)"
|
||||
class="mt-4 space-y-3 text-xs leading-6"
|
||||
aria-label="逐集设计结果"
|
||||
>
|
||||
<p>
|
||||
共 {{ result.episodeCount ?? '待确认' }} 集 · 已保存 {{ result.completedEpisodes ?? '待确认' }} 集 ·
|
||||
跳过 {{ result.skippedEpisodes ?? '待确认' }} 集 · 失败 {{ result.failedEpisodes ?? '待确认' }} 集
|
||||
@@ -519,7 +637,12 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
: item.status === 'completed'
|
||||
? '已保存'
|
||||
: '状态待确认'
|
||||
}}<span v-if="item.error">:{{ userFacingText(item.error) }}</span>
|
||||
}}<span v-if="item.error">:{{ derivedErrorSummary(item.error) }}</span>
|
||||
<p v-for="(issue, index) in item.issues" :key="index" class="mt-1">
|
||||
段落 {{ issue.beatNo ?? '待确认' }} · 镜头 {{ issue.shotNo ?? '待确认' }}:{{
|
||||
userFacingText(issue.message)
|
||||
}}
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@@ -548,6 +671,14 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
<NCollapse v-if="!breakdownTask && !embedded" class="mt-3 text-xs text-muted">
|
||||
<NCollapseItem name="task-details" title="任务详情">
|
||||
<p class="mt-2 break-all font-mono">任务编号 · {{ execution.id }}</p>
|
||||
<pre v-if="derivedTask && claims.length" class="mt-2 whitespace-pre-wrap wrap-anywhere">{{
|
||||
JSON.stringify(claims, null, 2)
|
||||
}}</pre>
|
||||
<pre
|
||||
v-if="derivedTask && (execution.error || result.episodes)"
|
||||
class="mt-2 whitespace-pre-wrap wrap-anywhere"
|
||||
>{{ JSON.stringify({ error: execution.error, result: execution.result }, null, 2) }}</pre>
|
||||
<p v-if="recoveryKey" class="mt-2 break-all">原执行 · {{ execution.metadata?.recoveryOf }}</p>
|
||||
<!-- 以下是逐镜已结束质量任务的持久化状态模块 -->
|
||||
<ul v-if="videoQuality && settledItems.length" class="mt-2 space-y-2">
|
||||
<li v-for="item in settledItems" :key="item.shotId" class="break-all">
|
||||
@@ -562,6 +693,26 @@ function isInputMode(value: unknown, inputMode: string): boolean {
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</template>
|
||||
<!-- 以下是免费恢复关联的原失败历史,不修改原终态。 -->
|
||||
<section v-if="recoveryKey" class="mt-4 space-y-2" aria-label="原失败历史">
|
||||
<p class="text-xs text-muted">
|
||||
原失败执行{{
|
||||
originalExecution.data.value?.status === 'failed' ? '仍保留为失败' : '状态待核对'
|
||||
}},与本次免费恢复分别记录。
|
||||
</p>
|
||||
<WorkflowExecutionPanel
|
||||
v-if="originalExecution.data.value"
|
||||
title="原失败执行"
|
||||
:execution="originalExecution.data.value"
|
||||
:loading="originalExecution.loading.value"
|
||||
:error="originalExecution.error.value"
|
||||
:show-recovery-history="false"
|
||||
@refresh="originalExecution.refresh"
|
||||
/>
|
||||
<NButton v-else :loading="originalExecution.loading.value" @click="originalExecution.refresh"
|
||||
>读取原失败执行</NButton
|
||||
>
|
||||
</section>
|
||||
<!-- 以下是运行期间已经终止的过期候选统计模块 -->
|
||||
<p
|
||||
v-if="videoQuality && execution?.status === 'running' && staleMotionPlanCount > 0"
|
||||
|
||||
@@ -4,6 +4,17 @@ import type { WorkflowExecution } from './execution.types'
|
||||
|
||||
/** WorkflowExecution 查询接口;数据库状态是任务进度的权威来源。 */
|
||||
export const workflowExecutionApi = {
|
||||
/**
|
||||
* 停止派生批次的后续领取,已发送请求与费用仍保留。
|
||||
* @param executionId 原正式任务编号
|
||||
* @param projectId 任务所属项目
|
||||
* @returns 原工作流的权威状态
|
||||
*/
|
||||
stop: (executionId: string, projectId: string) =>
|
||||
request<WorkflowExecution>(`/workflow-executions/${encodeURIComponent(executionId)}/stop`, {
|
||||
method: 'POST',
|
||||
body: { projectId }
|
||||
}),
|
||||
/**
|
||||
* 按项目发现最新后台任务,不依赖本地保存的句柄。
|
||||
* @param projectId 当前正式项目编号
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { errorMessage } from '../../lib/http'
|
||||
import { userFacingText } from '../../lib/user-facing-text'
|
||||
import { computed, onScopeDispose, reactive, ref, watch, type Ref } from 'vue'
|
||||
import { usePolling } from '../../composables/usePolling'
|
||||
@@ -104,6 +105,7 @@ export function executionStageLabel(stage: string | null) {
|
||||
exhausted: '修复次数已用完',
|
||||
provider_failed: '模型生成失败',
|
||||
submission_failed: '任务提交失败',
|
||||
stopped: '已停止',
|
||||
completed: '执行完成',
|
||||
stale_motion_plan: '动作版本过期,质量流程已停止',
|
||||
failed: '执行失败'
|
||||
@@ -186,18 +188,13 @@ export function useWorkflowExecution(
|
||||
const known = query.data.value
|
||||
if (
|
||||
known?.id === id &&
|
||||
(['completed', 'failed'].includes(known.status) ||
|
||||
Date.parse(known.updatedAt) > Date.parse(record.updatedAt))
|
||||
((['completed', 'failed'].includes(known.status) && record.status !== known.status) ||
|
||||
Date.parse(known.updatedAt) > Date.parse(record.updatedAt) ||
|
||||
JSON.stringify(known) === JSON.stringify(record))
|
||||
)
|
||||
return known
|
||||
const activity = executionActivity[storageKey(targetProjectId, workflowName)]
|
||||
if (
|
||||
!signal.aborted &&
|
||||
!disposed &&
|
||||
projectId.value === targetProjectId &&
|
||||
activity?.id === id &&
|
||||
!activity.terminal
|
||||
) {
|
||||
if (!signal.aborted && !disposed && projectId.value === targetProjectId && activity?.id === id) {
|
||||
activity.terminal = ['completed', 'failed'].includes(record.status)
|
||||
activity.active = !activity.terminal
|
||||
executionRecords[storageKey(targetProjectId, workflowName)] = record
|
||||
@@ -230,6 +227,14 @@ export function useWorkflowExecution(
|
||||
}
|
||||
if (!observedActive.has(record.id) || announcedExecutions.has(record.id) || !message) return
|
||||
announcedExecutions.add(record.id)
|
||||
if (record.stage === 'stopped' || record.result?.stoppedByUser === true) {
|
||||
message.info('批次已停止。已发送请求和费用仍需核对。')
|
||||
return
|
||||
}
|
||||
if (record.result?.recovered === true && record.result?.actualModelRequests === 0) {
|
||||
message.info('已免费复用原回执,请核对正式画面状态。')
|
||||
return
|
||||
}
|
||||
if (record.status === 'failed') {
|
||||
message.error(record.error || '后台任务失败,请查看任务记录。', { duration: 8000, closable: true })
|
||||
return
|
||||
@@ -331,8 +336,9 @@ export function useWorkflowExecution(
|
||||
known &&
|
||||
(Date.parse(record.createdAt) < Date.parse(known.createdAt) ||
|
||||
(record.id === known.id &&
|
||||
(['completed', 'failed'].includes(known.status) ||
|
||||
Date.parse(record.updatedAt) < Date.parse(known.updatedAt))))
|
||||
((['completed', 'failed'].includes(known.status) && record.status !== known.status) ||
|
||||
Date.parse(record.updatedAt) < Date.parse(known.updatedAt) ||
|
||||
JSON.stringify(known) === JSON.stringify(record))))
|
||||
)
|
||||
return
|
||||
const activityKey = storageKey(record.projectId, workflowName)
|
||||
@@ -387,5 +393,45 @@ export function useWorkflowExecution(
|
||||
async function discover() {
|
||||
await discoveryReaders.get(storageKey(projectId.value, workflowName))?.()
|
||||
}
|
||||
return { executionId, query, active, track, dismiss, discovering, discoveryError, discover }
|
||||
/** 停止请求独立于项目活动锁,避免无法停止正在运行的批次。 */
|
||||
const stopping = ref(false)
|
||||
/** 只允许两类派生批次停止后续领取。 */
|
||||
const canStop = computed(
|
||||
() =>
|
||||
['storyboard-direction', 'storyboard-visual-state'].includes(workflowName) &&
|
||||
!!query.data.value &&
|
||||
active.value
|
||||
)
|
||||
/** 停止后接受原任务权威终态,并继续允许免费刷新在途回执。 */
|
||||
async function stop() {
|
||||
const record = query.data.value
|
||||
if (!record || !canStop.value || stopping.value) return
|
||||
const targetProject = projectId.value
|
||||
stopping.value = true
|
||||
try {
|
||||
const result = await workflowExecutionApi.stop(record.id, targetProject)
|
||||
if (projectId.value !== targetProject || executionId.value !== record.id) return
|
||||
if (result.id !== record.id || result.projectId !== targetProject || result.workflowName !== workflowName)
|
||||
throw new Error('停止回执与当前任务不一致,请重新读取。')
|
||||
receiveDiscovered(result)
|
||||
await query.refresh()
|
||||
} catch (cause) {
|
||||
message?.error(errorMessage(cause))
|
||||
} finally {
|
||||
stopping.value = false
|
||||
}
|
||||
}
|
||||
return {
|
||||
executionId,
|
||||
query,
|
||||
active,
|
||||
track,
|
||||
dismiss,
|
||||
discovering,
|
||||
discoveryError,
|
||||
discover,
|
||||
stopping,
|
||||
canStop,
|
||||
stop
|
||||
}
|
||||
}
|
||||
@@ -145,6 +145,13 @@ export function userFacingText(value: string | null | undefined, fallback = '暂
|
||||
QUALITY_POLICY_SNAPSHOT_UNKNOWN: '分镜缺少可信的质量规则记录,请重新生成拆解候选。',
|
||||
QUALITY_POLICY_SNAPSHOT_INVALID: '分镜的质量规则记录不完整,请重新生成拆解候选。',
|
||||
QUALITY_POLICY_SNAPSHOT_STALE: '分镜与质量规则版本不一致,请核对最新拆解结果。',
|
||||
STORYBOARD_SHOT_SCOPE_INVALID: '所选镜头不属于当前项目或剧集,请刷新目录后重新选择。',
|
||||
STORYBOARD_SOURCE_STALE: '正式分镜来源已变化,请重新读取后核对。',
|
||||
STORYBOARD_DIRECTION_STALE: '摄影来源已过期,请先核对当前摄影设计。',
|
||||
STORYBOARD_SUBJECT_SOURCE_STALE: '主体或形态来源已变化,请重新核对正式绑定。',
|
||||
STORYBOARD_DERIVED_STALE: '摄影或画面来源已变化,请重新预检,不能覆盖旧版本。',
|
||||
STORYBOARD_DERIVED_REQUEST_UNRESOLVED: '原请求结果尚未核清,请核对原任务和费用,不要重复生成。',
|
||||
STORYBOARD_DIRECTION_SCOPE_MISMATCH: '本镜摄影的可见范围与正式绑定冲突,请核对对应段落和镜头。',
|
||||
STORYBOARD_SOURCE_MISMATCH: '镜头与已提交分镜不一致,请刷新后核对。'
|
||||
}
|
||||
const code = Object.keys(codeLabels).find(
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>分阶段生产 · 隔离验收</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="./staged-production.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,299 @@
|
||||
import { createApp, computed, defineComponent, h, provide, ref } from 'vue'
|
||||
import { NButton, NConfigProvider, NGlobalStyle, NMessageProvider, zhCN, dateZhCN } from 'naive-ui'
|
||||
import { useTheme } from '../../src/composables/useTheme'
|
||||
import ActionMessageProvider from '../../src/components/ui/ActionMessageProvider.vue'
|
||||
import StoryboardPage from '../../src/features/storyboard/StoryboardPage.vue'
|
||||
import { projectContextKey, useProjectData } from '../../src/features/projects/context'
|
||||
import {
|
||||
directionsResult,
|
||||
visualStatesResult,
|
||||
storyboardCheckpoint
|
||||
} from '../../src/features/storyboard/testing/fixtures'
|
||||
import { preparationFixture } from '../features/storyboard-preparation/fixtures'
|
||||
import type { WorkflowExecution } from '../../src/features/workflows/execution.types'
|
||||
import { billingCatalog, billingProfile } from '../fixtures/billing'
|
||||
import '../../src/styles/styles.css'
|
||||
import '../../src/styles/admin.css'
|
||||
|
||||
/** 隔离场景,任何请求都不会进入本地真实 API。 */
|
||||
const scenario = new URLSearchParams(location.search).get('scenario') ?? 'direction'
|
||||
/** 固定隔离身份以验证刷新恢复,和正式项目完全分开。 */
|
||||
const projectId = `staged-browser-${scenario}`
|
||||
/** 显式显示模拟写入次数,便于 Chrome 验证没有自动生产。 */
|
||||
const calls = ref<Array<{ path: string; method: string; body: unknown }>>([])
|
||||
/** 当前正式模拟摄影,保留并发版本与原文。 */
|
||||
let directions = directionsResult(projectId)
|
||||
for (const row of directions.beats.flatMap(beat => beat.shots))
|
||||
row.direction = {
|
||||
...row.direction!,
|
||||
id: 'original-' + row.shotId,
|
||||
updatedAt: '2026-11-15T00:00:00.000Z',
|
||||
rawJson: '原摄影原文'
|
||||
}
|
||||
/** 尚无画面状态的镜头允许独立摄影修订。 */
|
||||
let visuals = visualStatesResult(projectId, 1, scenario === 'complete')
|
||||
/** 用于验证用户明确覆盖后的二次保护。 */
|
||||
let conflictNext = false
|
||||
/** 场景的正式质量确认。 */
|
||||
const approval = preparationFixture(projectId)
|
||||
/** 任务当前持久化投影,模拟停止后在途回执的保留。 */
|
||||
let task: WorkflowExecution = {
|
||||
id: 'mock-derived-task',
|
||||
projectId,
|
||||
workflowName: 'storyboard-direction',
|
||||
status: scenario === 'running' ? 'running' : 'completed',
|
||||
stage: scenario === 'running' ? 'storyboardDirection' : 'completed',
|
||||
current: 0,
|
||||
total: 2,
|
||||
currentResourceId: null,
|
||||
metadata: {
|
||||
derivedBatchVersion: 1,
|
||||
episodeNo: 1,
|
||||
shotIds: ['shot-db-1-1', 'shot-db-1-2'],
|
||||
claims: [{ state: 'submitted', episodeNo: 1, shotIds: ['shot-db-1-1', 'shot-db-1-2'] }]
|
||||
},
|
||||
result: null,
|
||||
error: null,
|
||||
startedAt: '2026-11-15T00:00:00Z',
|
||||
completedAt: null,
|
||||
createdAt: '2026-11-15T00:00:00Z',
|
||||
updatedAt: '2026-11-15T00:00:00Z'
|
||||
}
|
||||
if (scenario === 'running') {
|
||||
try {
|
||||
const saved = JSON.parse(localStorage.getItem('staged-browser:task') ?? 'null')
|
||||
if (saved?.projectId === projectId) task = saved
|
||||
} catch {
|
||||
/* 隔离数据损坏不构造正式任务。 */
|
||||
}
|
||||
localStorage.setItem(`short-drama:workflow-execution:${projectId}:storyboard-direction`, task.id)
|
||||
}
|
||||
/**
|
||||
* 全量拦截当前页面请求,未知接口拒绝,不连接正式项目、模型或资产。
|
||||
* @param input 原接口地址
|
||||
* @param init 原请求方法与正文
|
||||
* @returns 与原正式路由同形状的隔离数据
|
||||
*/
|
||||
window.fetch = async (input, init) => {
|
||||
const path = String(input),
|
||||
method = init?.method ?? 'GET'
|
||||
const body = init?.body ? JSON.parse(String(init.body)) : undefined
|
||||
calls.value.push({ path, method, body })
|
||||
let data: unknown
|
||||
if (path.endsWith(`/projects/${projectId}`))
|
||||
data = {
|
||||
id: projectId,
|
||||
title: '隔离验收剧本',
|
||||
status: 'completed',
|
||||
episodes: [{ episode: 1, title: '来信', content: '隔离内容' }],
|
||||
characters: []
|
||||
}
|
||||
else if (path.endsWith('/stage-readiness'))
|
||||
data = {
|
||||
projectId,
|
||||
...Object.fromEntries(
|
||||
['script', 'breakdown', 'preparation', 'visualStyle', 'identity', 'subjectAssets', 'storyboard'].map(
|
||||
key => [key, { ready: true, reason: null }]
|
||||
)
|
||||
)
|
||||
}
|
||||
else if (path.includes('/checkpoints')) data = path.includes('view=summary') ? [] : [storyboardCheckpoint()]
|
||||
else if (path.endsWith('/storyboard-quality-confirmation'))
|
||||
data = { ...approval.approval, valid: true, confirmation: approval.record }
|
||||
else if (path.endsWith('/storyboard-quality-confirmation/preflight'))
|
||||
data = {
|
||||
current: { ...approval.approval, valid: true, confirmation: approval.record },
|
||||
quality: approval.quality
|
||||
}
|
||||
else if (path.includes('/storyboard-directions?')) data = directions
|
||||
else if (path.includes('/storyboard-visual-states?')) data = visuals
|
||||
else if (path.endsWith('/storyboard/duration-audit')) data = { projectId, issues: [] }
|
||||
else if (path.endsWith('/duration-budget')) data = { projectId, episodes: [] }
|
||||
else if (path.endsWith('/production/entry-readiness'))
|
||||
data = {
|
||||
...approval.entry,
|
||||
derivedAssets: {
|
||||
...approval.entry.derivedAssets,
|
||||
shotCount: 2,
|
||||
directionCount: 2,
|
||||
visualStateCount: visuals.visualStateCount,
|
||||
staleDirectionCount: 0,
|
||||
staleVisualStateCount: 0
|
||||
}
|
||||
}
|
||||
else if (path.endsWith('/generation-models')) data = billingCatalog
|
||||
else if (path.endsWith('/creative-profile')) data = { ...billingProfile, projectId }
|
||||
else if (path.includes('/keyframe-review-draft')) data = null
|
||||
else if (path.endsWith('/storyboard-derived-reviews/confirm')) {
|
||||
if (conflictNext && body.preview === false) {
|
||||
conflictNext = false
|
||||
return new Response(
|
||||
JSON.stringify({ message: 'STORYBOARD_DERIVED_STALE: 原摄影已由另一审核人更新,请重新核对。' }),
|
||||
{ status: 409 }
|
||||
)
|
||||
}
|
||||
if (!body.preview)
|
||||
directions.beats[0]!.shots[0]!.direction = {
|
||||
...directions.beats[0]!.shots[0]!.direction!,
|
||||
...body.shots[0].direction
|
||||
}
|
||||
data = {
|
||||
projectId,
|
||||
phase: 'direction',
|
||||
preview: body.preview,
|
||||
sourceFingerprint: 'c'.repeat(64),
|
||||
changed: !body.preview,
|
||||
shots: [
|
||||
{
|
||||
shotId: body.shots[0].shotId,
|
||||
directionId: 'original-shot-db-1-1',
|
||||
updatedAt: '2026-11-15T00:00:00.000Z',
|
||||
changed: !body.preview,
|
||||
alreadyApplied: false
|
||||
}
|
||||
]
|
||||
}
|
||||
} else if (
|
||||
path.endsWith('/storyboard-directions/generate') ||
|
||||
path.endsWith('/storyboard-visual-states/generate')
|
||||
) {
|
||||
const visual = path.includes('visual-states')
|
||||
if (visual) visuals = visualStatesResult(projectId, 1, true)
|
||||
else directions = directionsResult(projectId)
|
||||
task = {
|
||||
...task,
|
||||
id: 'mock-' + calls.value.length,
|
||||
workflowName: visual ? 'storyboard-visual-state' : 'storyboard-direction',
|
||||
status: 'completed',
|
||||
stage: 'completed',
|
||||
metadata: { ...body, claims: [{ state: 'received' }] },
|
||||
result: {
|
||||
projectId,
|
||||
episodeCount: 1,
|
||||
completedEpisodes: 1,
|
||||
skippedEpisodes: 0,
|
||||
failedEpisodes: 0,
|
||||
episodes: [{ episodeNo: 1, status: 'completed' }]
|
||||
},
|
||||
updatedAt: new Date().toISOString()
|
||||
}
|
||||
data = { executionId: task.id, projectId, status: 'running' }
|
||||
} else if (path.endsWith('/stop')) {
|
||||
task = {
|
||||
...task,
|
||||
status: 'failed',
|
||||
stage: 'stopped',
|
||||
result: { stoppedByUser: true, retryAutomatically: false },
|
||||
updatedAt: new Date().toISOString()
|
||||
}
|
||||
localStorage.setItem('staged-browser:task', JSON.stringify(task))
|
||||
setTimeout(() => {
|
||||
task = {
|
||||
...task,
|
||||
metadata: { ...task.metadata, claims: [{ state: 'received' }] },
|
||||
updatedAt: new Date().toISOString()
|
||||
}
|
||||
localStorage.setItem('staged-browser:task', JSON.stringify(task))
|
||||
}, 1000)
|
||||
data = task
|
||||
} else if (path.includes('/workflow-executions/')) data = task
|
||||
else if (path.endsWith('/references')) data = { shotId: path.split('/').at(-2), references: [], missing: [] }
|
||||
else if (path.endsWith('/production/plan'))
|
||||
data = {
|
||||
projectId,
|
||||
configuration: { status: 'blocked', reason: '隔离项目尚未设置图片模型' },
|
||||
entryReadiness: { ready: false, reason: '仅所选镜头准备完成,项目未就绪' },
|
||||
stageReadiness: {
|
||||
referenceImages: { status: 'ready', reason: null },
|
||||
keyframes: { status: 'blocked', reason: '需要核对首帧预览' },
|
||||
videos: { status: 'blocked', reason: '尚无主视频' }
|
||||
},
|
||||
details: null
|
||||
}
|
||||
else if (path.endsWith('/production/status')) data = { projectId, completed: false }
|
||||
else return new Response(JSON.stringify({ message: '隔离页面拒绝未声明接口,不连接真实服务' }), { status: 403 })
|
||||
return new Response(JSON.stringify({ data }), { headers: { 'Content-Type': 'application/json' } })
|
||||
}
|
||||
/** 整页复用原上下文及分镜组件,只增加隔离控制栏。 */
|
||||
const Workspace = defineComponent({
|
||||
setup() {
|
||||
const id = ref(projectId)
|
||||
const context = useProjectData(id)
|
||||
provide(projectContextKey, context)
|
||||
return () => h(StoryboardPage)
|
||||
}
|
||||
})
|
||||
/** 主题只用于当前隔离页渲染,不更改用户存储偏好。 */
|
||||
const Preview = defineComponent({
|
||||
setup() {
|
||||
const theme = useTheme()
|
||||
const writes = computed(
|
||||
() => calls.value.filter(call => call.method === 'POST' && /generate|confirm|stop/.test(call.path)).length
|
||||
)
|
||||
return () =>
|
||||
h(
|
||||
NConfigProvider,
|
||||
{ locale: zhCN, dateLocale: dateZhCN, theme: theme.theme.value, themeOverrides: theme.overrides.value },
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
NMessageProvider,
|
||||
{},
|
||||
{
|
||||
default: () =>
|
||||
h(
|
||||
ActionMessageProvider,
|
||||
{},
|
||||
{
|
||||
default: () => [
|
||||
h(NGlobalStyle),
|
||||
h(
|
||||
'header',
|
||||
{
|
||||
style: 'height:70px;padding:12px;display:flex;gap:12px;flex-wrap:wrap;overflow:auto'
|
||||
},
|
||||
[
|
||||
...Object.entries({
|
||||
direction: '独立摄影',
|
||||
complete: '已有结果',
|
||||
running: '停止与刷新'
|
||||
}).map(([key, label]) =>
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
onClick: () => {
|
||||
location.href = `?scenario=${key}`
|
||||
}
|
||||
},
|
||||
() => label
|
||||
)
|
||||
),
|
||||
h(
|
||||
NButton,
|
||||
{
|
||||
onClick: () => {
|
||||
conflictNext = true
|
||||
}
|
||||
},
|
||||
() => '模拟一次并发冲突'
|
||||
),
|
||||
h(
|
||||
'span',
|
||||
{ role: 'status' },
|
||||
`模拟写入 ${writes.value} 次 · 真实模型请求 0 次`
|
||||
)
|
||||
]
|
||||
),
|
||||
h('div', { style: 'height:calc(100dvh - 70px);min-height:0' }, [
|
||||
h(Workspace)
|
||||
])
|
||||
]
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
createApp(Preview).mount('#app')
|
||||
@@ -1,3 +1,5 @@
|
||||
import { preparationApi } from '@/features/storyboard-preparation/api'
|
||||
import { preparationFixture } from '../storyboard-preparation/fixtures'
|
||||
import { h } from 'vue'
|
||||
import { createMemoryHistory, createRouter } from 'vue-router'
|
||||
import { DOMWrapper, flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
@@ -36,6 +38,7 @@ function readiness(id: string, ready = true): ProjectStageReadiness {
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.spyOn(preparationApi, 'approval').mockImplementation(async id => preparationFixture(id).approval)
|
||||
vi.spyOn(workflowExecutionApi, 'latest').mockResolvedValue(null)
|
||||
vi.spyOn(projectsApi, 'stageReadiness').mockImplementation(async id => readiness(id))
|
||||
})
|
||||
@@ -115,6 +118,24 @@ async function openProject(initialPath: string) {
|
||||
}
|
||||
|
||||
describe('剧本完成前的下游访问限制', () => {
|
||||
it('正式分镜存在时可读查看,完整生产与素材入口仍保留原门禁', async () => {
|
||||
const id = 'formal-read-only'
|
||||
const state = readiness(id, false)
|
||||
state.script.ready = true
|
||||
vi.mocked(projectsApi.stageReadiness).mockResolvedValue(state)
|
||||
vi.spyOn(projectsApi, 'detail').mockResolvedValue(project(id, 'completed'))
|
||||
vi.spyOn(projectsApi, 'checkpointSummaries').mockResolvedValue([])
|
||||
const fixture = preparationFixture(id)
|
||||
vi.mocked(preparationApi.approval).mockResolvedValue({
|
||||
...fixture.approval,
|
||||
valid: true,
|
||||
confirmation: fixture.record
|
||||
})
|
||||
const { mounted } = await openProject(`/projects/${id}/storyboard`)
|
||||
expect(mounted).toHaveBeenCalledWith('storyboard')
|
||||
expect(wrapper!.find(`.n-menu a[href="/projects/${id}/production"]`).exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('已知项目资产入口不受制作阶段拦截,未知工作区仍默认锁定', async () => {
|
||||
const id = 'independent-project-assets'
|
||||
vi.mocked(projectsApi.stageReadiness).mockResolvedValue(readiness(id, false))
|
||||
|
||||
@@ -0,0 +1,656 @@
|
||||
import { defineComponent, h } from 'vue'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NCheckbox, NInput, NTag } from 'naive-ui'
|
||||
import { testProjectContext } from '@/testing/project-context'
|
||||
import { projectContextKey } from '@/features/projects/context'
|
||||
import { useStoryboard } from '@/features/storyboard/useStoryboard'
|
||||
import { derivedBatchInput, derivedState, derivedTaskState } from '@/features/storyboard/staged-derived'
|
||||
import {
|
||||
designedShot,
|
||||
directionsResult,
|
||||
visualStatesResult,
|
||||
storyboardCheckpoint
|
||||
} from '@/features/storyboard/testing/fixtures'
|
||||
import { preparationFixture } from '../storyboard-preparation/fixtures'
|
||||
import ShotDerivedReview from '@/features/storyboard/components/ShotDerivedReview.vue'
|
||||
import { imagePreviewFixture } from '../../fixtures/image-preview'
|
||||
import { billingCatalog, billingProfile } from '../../fixtures/billing'
|
||||
import StagedShotPreparation from '@/features/storyboard/components/StagedShotPreparation.vue'
|
||||
import ConfirmAction from '@/features/workflows/ConfirmAction.vue'
|
||||
import DirectionStageReview from '@/features/storyboard/components/DirectionStageReview.vue'
|
||||
import WorkflowExecutionPanel from '@/features/workflows/WorkflowExecutionPanel.vue'
|
||||
import type { WorkflowExecution } from '@/features/workflows/execution.types'
|
||||
import { workflowExecutionApi } from '@/features/workflows/execution-api'
|
||||
|
||||
/** 每个用例独立项目,避免共享活动锁污染其它范围。 */
|
||||
let serial = 0
|
||||
/** 已挂载实例统一释放轮询与取消信号。 */
|
||||
const wrappers: VueWrapper[] = []
|
||||
afterEach(() => {
|
||||
wrappers.splice(0).forEach(wrapper => wrapper.unmount())
|
||||
localStorage.clear()
|
||||
})
|
||||
/**
|
||||
* 不接触真实数据的公开 API 响应。
|
||||
* @param data 隔离业务数据
|
||||
* @returns 公开接口形状的独立响应
|
||||
*/
|
||||
function response(data: unknown) {
|
||||
return new Response(JSON.stringify({ data }))
|
||||
}
|
||||
/**
|
||||
* 构造后端持久化任务,领取信息与业务结果分别保留。
|
||||
* @param projectId 隔离项目身份
|
||||
* @param overrides 当前用例的任务状态
|
||||
* @returns 独立任务记录
|
||||
*/
|
||||
function execution(projectId: string, overrides: Partial<WorkflowExecution> = {}): WorkflowExecution {
|
||||
return {
|
||||
id: 'execution-1',
|
||||
projectId,
|
||||
workflowName: 'storyboard-direction',
|
||||
status: 'completed',
|
||||
stage: 'completed',
|
||||
current: 1,
|
||||
total: 1,
|
||||
currentResourceId: null,
|
||||
metadata: { episodeNo: 1, shotIds: ['shot-db-1-1', 'shot-db-1-2'] },
|
||||
result: null,
|
||||
error: null,
|
||||
startedAt: null,
|
||||
completedAt: null,
|
||||
createdAt: '2026-11-15T00:00:00Z',
|
||||
updatedAt: '2026-11-15T00:00:00Z',
|
||||
...overrides
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 挂载真实编排 Hook,所有生产 POST 由内存模拟明确隔离。
|
||||
* @param projectId 隔离项目身份
|
||||
* @returns 编排状态与明确的模拟控制
|
||||
*/
|
||||
async function harness(projectId = `staged-${++serial}`) {
|
||||
const context = testProjectContext(projectId)
|
||||
context.data.value!.checkpoints = [storyboardCheckpoint()]
|
||||
const fixture = preparationFixture(projectId)
|
||||
let directions = directionsResult(projectId)
|
||||
directions.beats[1]!.shots[0]!.direction = null
|
||||
directions.directionCount = 1
|
||||
let visuals = visualStatesResult(projectId)
|
||||
let current = execution(projectId)
|
||||
let failTransport = false
|
||||
const fetcher = vi.fn<typeof fetch>(async (url, init) => {
|
||||
const path = String(url)
|
||||
if (path.endsWith('/storyboard-quality-confirmation'))
|
||||
return response({ ...fixture.approval, valid: true, confirmation: fixture.record })
|
||||
if (path.includes('/storyboard-directions?')) return response(directions)
|
||||
if (path.includes('/storyboard-visual-states?')) return response(visuals)
|
||||
if (path.endsWith('/production/entry-readiness'))
|
||||
return response({
|
||||
...fixture.entry,
|
||||
derivedAssets: {
|
||||
...fixture.entry.derivedAssets,
|
||||
shotCount: 2,
|
||||
directionCount: directions.directionCount,
|
||||
staleDirectionCount: directions.staleCount,
|
||||
staleVisualStateCount: visuals.staleCount
|
||||
}
|
||||
})
|
||||
if (path.endsWith('/stop')) {
|
||||
current = {
|
||||
...current,
|
||||
status: 'failed',
|
||||
stage: 'stopped',
|
||||
result: { stoppedByUser: true, retryAutomatically: false },
|
||||
updatedAt: '2026-11-15T00:02:00Z'
|
||||
}
|
||||
return response(current)
|
||||
}
|
||||
if (path.includes('/workflow-executions/latest')) return response(current)
|
||||
if (path.includes('/workflow-executions/')) return response(current)
|
||||
if (path.endsWith('/storyboard-directions/generate')) {
|
||||
if (failTransport) throw new Error('断线')
|
||||
directions = directionsResult(projectId)
|
||||
current = execution(projectId)
|
||||
return response({ executionId: current.id, projectId, status: 'running' })
|
||||
}
|
||||
if (path.endsWith('/storyboard-visual-states/generate')) {
|
||||
visuals = visualStatesResult(projectId, 1, true)
|
||||
current = execution(projectId, { id: 'execution-vs', workflowName: 'storyboard-visual-state' })
|
||||
return response({ executionId: current.id, projectId, status: 'running' })
|
||||
}
|
||||
throw new Error(`没有模拟 ${init?.method ?? 'GET'} ${path}`)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
let state!: ReturnType<typeof useStoryboard>
|
||||
const component = defineComponent({
|
||||
setup() {
|
||||
state = useStoryboard()
|
||||
return () => h('div')
|
||||
}
|
||||
})
|
||||
const options = { global: { provide: { [projectContextKey as symbol]: context } } }
|
||||
const wrapper = mount(component, options)
|
||||
wrappers.push(wrapper)
|
||||
await flushPromises()
|
||||
return {
|
||||
state,
|
||||
context,
|
||||
fetcher,
|
||||
wrapper,
|
||||
remount: async () => {
|
||||
const next = mount(component, options)
|
||||
wrappers.push(next)
|
||||
await flushPromises()
|
||||
return state
|
||||
},
|
||||
setTransportFailure: () => {
|
||||
failTransport = true
|
||||
},
|
||||
setCurrent: (record: WorkflowExecution) => {
|
||||
current = record
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 提取实际收费派生请求,免费读取不计入。
|
||||
* @param fetcher 隔离请求记录
|
||||
* @returns 模拟派生生成请求
|
||||
*/
|
||||
function posts(fetcher: ReturnType<typeof vi.fn<typeof fetch>>) {
|
||||
return fetcher.mock.calls.filter(
|
||||
([url, init]) => init?.method === 'POST' && /storyboard-(directions|visual-states)\/generate/.test(String(url))
|
||||
)
|
||||
}
|
||||
|
||||
describe('按正式镜头定向派生', () => {
|
||||
it.each([{ ids: [] }, { ids: ['one', 'one'] }, { ids: ['outside'] }])('拒绝空、重复和跨集范围 %j', ({ ids }) => {
|
||||
expect(() => derivedBatchInput('selected', ids, [designedShot('one')], 1, 1, false)).toThrow(/请选择|所选镜头/)
|
||||
})
|
||||
it('旧批量省略 shotIds,所选范围保留 force=false 与正式集号', () => {
|
||||
expect(derivedBatchInput('selected', ['one'], [designedShot('one')], 1, 1, false)).toEqual({
|
||||
episodeNo: 1,
|
||||
shotIds: ['one'],
|
||||
concurrency: 1,
|
||||
force: false
|
||||
})
|
||||
expect(derivedBatchInput('project', [], [], 1, 1, false)).toEqual({ concurrency: 1, force: false })
|
||||
expect(derivedBatchInput('episode', [], [], 1, 1, false)).toEqual({
|
||||
episodeNo: 1,
|
||||
concurrency: 1,
|
||||
force: false
|
||||
})
|
||||
})
|
||||
it('正式存在、缺失、过期与无法定位的过期来源分别显示', () => {
|
||||
const shot = designedShot('one')
|
||||
expect(derivedState(shot, 'direction', 0)).toBe('current')
|
||||
expect(derivedState({ ...shot, direction: null }, 'direction', 0)).toBe('missing')
|
||||
expect(derivedState(shot, 'direction', 1)).toBe('unknown')
|
||||
const entry = preparationFixture().entry
|
||||
entry.derivedAssetShotGaps = [{ episode: 1, shotId: 'one', direction: 'stale', visualState: 'current' }]
|
||||
expect(derivedState(shot, 'direction', 1, entry)).toBe('stale')
|
||||
expect(derivedState(shot, 'visualState', 1, entry)).toBe('current')
|
||||
})
|
||||
it('混合范围复用已有结果,摄影完成后仅显式提交画面状态,刷新不重复 POST', async () => {
|
||||
const { state, fetcher } = await harness()
|
||||
expect(state.allowed.value['direction-all']).toBe(false)
|
||||
state.toggleShots(['shot-db-1-1', 'shot-db-1-2'])
|
||||
expect(state.allowed.value['visual-all']).toBe(false)
|
||||
await state.run('visual-all')
|
||||
expect(posts(fetcher)).toHaveLength(0)
|
||||
await state.run('direction-all')
|
||||
await flushPromises()
|
||||
expect(posts(fetcher)).toHaveLength(1)
|
||||
expect(JSON.parse(String(posts(fetcher)[0]![1]?.body))).toEqual({
|
||||
episodeNo: 1,
|
||||
shotIds: ['shot-db-1-1', 'shot-db-1-2'],
|
||||
concurrency: 1,
|
||||
force: false
|
||||
})
|
||||
expect(state.allowed.value['visual-all']).toBe(true)
|
||||
await state.query.refresh()
|
||||
expect(posts(fetcher)).toHaveLength(1)
|
||||
await state.run('visual-all')
|
||||
expect(JSON.parse(String(posts(fetcher)[1]![1]?.body))).toMatchObject({
|
||||
maxRepairAttempts: 0,
|
||||
force: false,
|
||||
shotIds: ['shot-db-1-1', 'shot-db-1-2']
|
||||
})
|
||||
await state.run('visual-all')
|
||||
expect(posts(fetcher)).toHaveLength(2)
|
||||
})
|
||||
it('有效镜头默认禁用重复生成;覆盖是明确切换,切集清空选择及覆盖', async () => {
|
||||
const { state, fetcher } = await harness()
|
||||
state.toggleShots(['shot-db-1-1'])
|
||||
expect(state.allowed.value['direction-all']).toBe(false)
|
||||
state.force.value = true
|
||||
expect(state.allowed.value['direction-all']).toBe(true)
|
||||
await state.run('direction-all')
|
||||
expect(JSON.parse(String(posts(fetcher)[0]![1]?.body)).force).toBe(true)
|
||||
state.selectedEpisode.value = 2
|
||||
await flushPromises()
|
||||
expect(state.checkedShotIds.value).toEqual([])
|
||||
expect(state.force.value).toBe(false)
|
||||
})
|
||||
it('提交回执断线后持久保护,重新挂载只免费核对原范围,不重新 POST', async () => {
|
||||
const setup = await harness()
|
||||
setup.state.toggleShots(['shot-db-1-2'])
|
||||
setup.setTransportFailure()
|
||||
await setup.state.run('direction-all')
|
||||
expect(setup.state.submissionUnknown.value).toBe(true)
|
||||
setup.wrapper.unmount()
|
||||
const restored = await setup.remount()
|
||||
restored.toggleShots(['shot-db-1-2'])
|
||||
await restored.run('direction-all')
|
||||
expect(posts(setup.fetcher)).toHaveLength(1)
|
||||
setup.setCurrent(
|
||||
execution(restored.id.value, {
|
||||
id: 'accepted-original',
|
||||
metadata: { episodeNo: 1, shotIds: ['shot-db-1-2'] }
|
||||
})
|
||||
)
|
||||
await restored.inspectSubmission()
|
||||
expect(restored.submissionUnknown.value).toBe(false)
|
||||
expect(restored.executions[1]!.observer.executionId.value).toBe('accepted-original')
|
||||
expect(posts(setup.fetcher)).toHaveLength(1)
|
||||
})
|
||||
it('停止后保留终态,免费刷新接收在途回执,不重新发生成', async () => {
|
||||
const setup = await harness()
|
||||
const current = execution(setup.state.id.value, {
|
||||
status: 'running',
|
||||
metadata: {
|
||||
episodeNo: 1,
|
||||
shotIds: ['shot-db-1-1'],
|
||||
claims: [{ state: 'submitted', shotIds: ['shot-db-1-1'] }]
|
||||
}
|
||||
})
|
||||
setup.setCurrent(current)
|
||||
const observer = setup.state.executions[1]!.observer
|
||||
await observer.track(current.id, setup.state.id.value)
|
||||
expect(observer.canStop.value).toBe(true)
|
||||
await observer.stop()
|
||||
expect(observer.query.data.value?.stage).toBe('stopped')
|
||||
expect(observer.active.value).toBe(false)
|
||||
setup.setCurrent({
|
||||
...observer.query.data.value!,
|
||||
metadata: { claims: [{ state: 'received' }] },
|
||||
updatedAt: '2026-11-15T00:03:00Z'
|
||||
})
|
||||
await observer.query.refresh()
|
||||
expect(observer.query.data.value?.metadata?.claims).toEqual([{ state: 'received' }])
|
||||
expect(observer.query.data.value?.status).toBe('failed')
|
||||
expect(posts(setup.fetcher)).toHaveLength(0)
|
||||
expect(setup.fetcher.mock.calls.filter(([url]) => String(url).endsWith('/stop'))).toHaveLength(1)
|
||||
})
|
||||
it('已停止但原请求仍在途时,force也不能绕过所选范围费用核对', async () => {
|
||||
const setup = await harness()
|
||||
const record = execution(setup.state.id.value, {
|
||||
status: 'failed',
|
||||
stage: 'stopped',
|
||||
result: { stoppedByUser: true },
|
||||
metadata: {
|
||||
episodeNo: 1,
|
||||
shotIds: ['shot-db-1-1'],
|
||||
claims: [{ episodeNo: 1, shotIds: ['shot-db-1-1'], state: 'submitted' }]
|
||||
}
|
||||
})
|
||||
setup.setCurrent(record)
|
||||
await setup.state.executions[1]!.observer.track(record.id, setup.state.id.value)
|
||||
setup.state.toggleShots(['shot-db-1-1'])
|
||||
setup.state.force.value = true
|
||||
expect(setup.state.allowed.value['direction-all']).toBe(false)
|
||||
await setup.state.run('direction-all')
|
||||
expect(posts(setup.fetcher)).toHaveLength(0)
|
||||
setup.state.toggleShots(['shot-db-1-1', 'shot-db-1-2'])
|
||||
setup.state.toggleShots(['shot-db-1-1'])
|
||||
expect(setup.state.allowed.value['direction-all']).toBe(true)
|
||||
})
|
||||
it('停止按项目原执行 POST,未知请求与范围外镜头分开', async () => {
|
||||
const record = execution('p', {
|
||||
status: 'failed',
|
||||
stage: 'stopped',
|
||||
error: 'STORYBOARD_DERIVED_REQUEST_UNRESOLVED'
|
||||
})
|
||||
expect(derivedTaskState(record, 'shot-db-1-1', 1)).toBe('unresolved')
|
||||
expect(derivedTaskState(record, 'outside', 1)).toBeNull()
|
||||
vi.stubGlobal('fetch', vi.fn<typeof fetch>().mockResolvedValue(response(record)))
|
||||
await workflowExecutionApi.stop('original/1', 'p')
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
'/api/workflow-executions/original%2F1/stop',
|
||||
expect.objectContaining({ method: 'POST', body: '{"projectId":"p"}' })
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
describe('独立摄影沿原采用入口', () => {
|
||||
/**
|
||||
* 挂载原字段编辑与独立阶段,模拟端只返回正式契约。
|
||||
* @param conflict 是否制造正式采用并发冲突
|
||||
* @returns 真实编辑器与隔离请求记录
|
||||
*/
|
||||
async function editor(conflict = false) {
|
||||
const projectId = `direction-review-${++serial}`
|
||||
const fixture = preparationFixture(projectId)
|
||||
const directions = directionsResult(projectId)
|
||||
directions.beats[0]!.shots[0]!.direction = {
|
||||
...directions.beats[0]!.shots[0]!.direction!,
|
||||
id: 'direction-original',
|
||||
updatedAt: '2026-11-15T01:00:00.000Z',
|
||||
rawJson: null
|
||||
}
|
||||
const fetcher = vi.fn<typeof fetch>(async (url, init) => {
|
||||
const path = String(url)
|
||||
if (path.endsWith('/storyboard-quality-confirmation'))
|
||||
return response({ ...fixture.approval, valid: true, confirmation: fixture.record })
|
||||
if (path.includes('/storyboard-directions?')) return response(directions)
|
||||
if (path.includes('/storyboard-visual-states?')) return response(visualStatesResult(projectId))
|
||||
if (path.endsWith('/storyboard-derived-reviews/confirm')) {
|
||||
const body = JSON.parse(String(init?.body))
|
||||
if (conflict && !body.preview)
|
||||
return new Response(
|
||||
JSON.stringify({ message: 'STORYBOARD_DERIVED_STALE: 原摄影版本已变化,请重新读取。' }),
|
||||
{ status: 409 }
|
||||
)
|
||||
return response({
|
||||
projectId,
|
||||
phase: 'direction',
|
||||
preview: body.preview,
|
||||
sourceFingerprint: 'c'.repeat(64),
|
||||
changed: false,
|
||||
shots: [
|
||||
{
|
||||
shotId: 'shot-db-1-1',
|
||||
directionId: 'direction-original',
|
||||
updatedAt: '2026-11-15T01:00:00.000Z',
|
||||
changed: false,
|
||||
alreadyApplied: !body.preview
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
throw new Error('没有模拟 ' + path)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(DirectionStageReview, {
|
||||
props: { projectId, episodeNo: 1, shot: { ...designedShot(), visualState: null }, disabled: false }
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
await flushPromises()
|
||||
return { wrapper, fetcher }
|
||||
}
|
||||
it('免费预检冻结完整原版本,changed=false仍可采用,同草案支持幂等回执', async () => {
|
||||
const { wrapper, fetcher } = await editor()
|
||||
const inputs = wrapper.findAllComponents(NInput)
|
||||
inputs[0]!.vm.$emit('update:value', '修订构图,保持已绑定主体')
|
||||
inputs[2]!.vm.$emit('update:value', '实际审核人')
|
||||
await flushPromises()
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '免费预检摄影修改')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('预检通过')
|
||||
expect(wrapper.vm.canAdopt).toBe(false)
|
||||
wrapper.getComponent(NCheckbox).vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
expect(wrapper.vm.canAdopt).toBe(true)
|
||||
await wrapper.vm.adopt()
|
||||
const calls = fetcher.mock.calls.filter(([url]) => String(url).endsWith('/confirm'))
|
||||
expect(calls).toHaveLength(2)
|
||||
const preview = JSON.parse(String(calls[0]![1]?.body))
|
||||
const adopt = JSON.parse(String(calls[1]![1]?.body))
|
||||
expect(preview).toMatchObject({
|
||||
phase: 'direction',
|
||||
preview: true,
|
||||
reviewer: '实际审核人',
|
||||
expectedShotFingerprint: 'b'.repeat(64),
|
||||
shots: [
|
||||
{
|
||||
expectedDirectionId: 'direction-original',
|
||||
expectedDirectionRawJson: null,
|
||||
expectedDirectionUpdatedAt: '2026-11-15T01:00:00.000Z',
|
||||
direction: { shotSize: 'medium', cameraAngle: 'eye-level', composition: '修订构图,保持已绑定主体' }
|
||||
}
|
||||
]
|
||||
})
|
||||
expect(adopt).toEqual({ ...preview, preview: false, expectedSourceFingerprint: 'c'.repeat(64) })
|
||||
expect(preview.shots[0]).not.toHaveProperty('visualState')
|
||||
expect(wrapper.emitted('adopted')).toHaveLength(1)
|
||||
})
|
||||
it('修改署名或内容撤销预检;并发409保留输入且不自动覆盖', async () => {
|
||||
const { wrapper, fetcher } = await editor(true)
|
||||
const inputs = wrapper.findAllComponents(NInput)
|
||||
inputs[2]!.vm.$emit('update:value', '审核人')
|
||||
await flushPromises()
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '免费预检摄影修改')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
wrapper.getComponent(NCheckbox).vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
await wrapper.vm.adopt()
|
||||
expect(wrapper.vm.canAdopt).toBe(false)
|
||||
expect(wrapper.emitted('adopted')).toBeUndefined()
|
||||
expect(fetcher.mock.calls.filter(([url]) => String(url).endsWith('/confirm'))).toHaveLength(2)
|
||||
expect(inputs[2]!.props('value')).toBe('审核人')
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '重新读取正式来源')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
await wrapper
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '免费预检摄影修改')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
inputs[0]!.vm.$emit('update:value', '又一次修改')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).not.toContain('预检通过')
|
||||
})
|
||||
})
|
||||
|
||||
describe('已有下游的原组合摄影修订', () => {
|
||||
it('保留画面状态、原预览指纹和正式来源,不绕入独立摄影 phase', async () => {
|
||||
const projectId = `combined-${++serial}`
|
||||
const fixture = preparationFixture(projectId)
|
||||
const shot = designedShot()
|
||||
const fetcher = vi.fn<typeof fetch>(async (url, init) => {
|
||||
const path = String(url)
|
||||
if (path.includes('/keyframe-review-draft')) return response(null)
|
||||
if (path.endsWith('/preflight'))
|
||||
return response({
|
||||
current: { ...fixture.approval, valid: true, confirmation: fixture.record },
|
||||
quality: fixture.quality
|
||||
})
|
||||
if (path.includes('/keyframe-spec'))
|
||||
return response({ shotId: shot.shotId, formalSourceFingerprint: 'e'.repeat(64), references: [] })
|
||||
if (path.includes('/generation-spec')) return response({ shotId: shot.shotId, subjects: [] })
|
||||
if (path.includes('/storyboard-directions?')) return response(directionsResult(projectId))
|
||||
if (path.includes('/storyboard-visual-states?')) return response(visualStatesResult(projectId, 1, true))
|
||||
if (path.endsWith('/generation-models')) return response(billingCatalog)
|
||||
if (path.endsWith('/creative-profile')) return response({ ...billingProfile, projectId })
|
||||
if (path.includes('/keyframe/preview'))
|
||||
return response({
|
||||
...imagePreviewFixture(),
|
||||
shotId: shot.shotId,
|
||||
draftFingerprint: 'd'.repeat(64),
|
||||
productionReady: false,
|
||||
productionGate: { ready: false, reason: '项目尚未完成' },
|
||||
sceneSources: []
|
||||
})
|
||||
if (path.endsWith('/storyboard-derived-reviews/confirm'))
|
||||
return response({ shots: [{ shotId: shot.shotId }] })
|
||||
throw new Error(`未模拟 ${init?.method ?? 'GET'} ${path}`)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(ShotDerivedReview, {
|
||||
attachTo: document.body,
|
||||
props: { projectId, episodeNo: 1, shot, shots: [shot], disabled: false }
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.findComponent(DirectionStageReview).exists()).toBe(false)
|
||||
const preview = [...document.querySelectorAll<HTMLButtonElement>('.app-drawer button')].find(
|
||||
button => button.textContent?.trim() === '免费预览摄影草案'
|
||||
)!
|
||||
expect(preview.disabled).toBe(false)
|
||||
preview.click()
|
||||
await flushPromises()
|
||||
const reviewer = wrapper.findAllComponents(NInput).find(input => input.attributes('aria-label') === '审核人')!
|
||||
reviewer.vm.$emit('update:value', '组合审核人')
|
||||
wrapper.findAllComponents(NCheckbox).at(-1)!.vm.$emit('update:checked', true)
|
||||
await flushPromises()
|
||||
const adopt = [...document.querySelectorAll<HTMLButtonElement>('.app-drawer button')].find(
|
||||
button => button.textContent?.trim() === '正式采用本镜'
|
||||
)!
|
||||
expect(adopt.disabled).toBe(false)
|
||||
adopt.click()
|
||||
await flushPromises()
|
||||
const call = fetcher.mock.calls.find(([url]) => String(url).endsWith('/storyboard-derived-reviews/confirm'))!
|
||||
const body = JSON.parse(String(call[1]?.body))
|
||||
expect(body).not.toHaveProperty('phase')
|
||||
expect(body.shots[0]).toMatchObject({
|
||||
expectedDraftFingerprint: 'd'.repeat(64),
|
||||
expectedCurrentFormalSourceFingerprint: 'e'.repeat(64),
|
||||
draft: { visualState: { shotNo: shot.shotNo }, expectedShotFingerprint: 'b'.repeat(64) }
|
||||
})
|
||||
expect(wrapper.emitted('changed')).toHaveLength(1)
|
||||
})
|
||||
})
|
||||
|
||||
describe('原失败、停止及免费恢复展示', () => {
|
||||
it('停止不显示普通质量失败或成功,收到结果不暗示通过', () => {
|
||||
const wrapper = mount(WorkflowExecutionPanel, {
|
||||
props: {
|
||||
execution: execution('stopped-ui', {
|
||||
status: 'failed',
|
||||
stage: 'stopped',
|
||||
result: { stoppedByUser: true },
|
||||
metadata: { claims: [{ state: 'submitted' }, { state: 'received' }] }
|
||||
}),
|
||||
loading: false,
|
||||
error: ''
|
||||
}
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
expect(wrapper.getComponent(NTag).text()).toBe('已停止')
|
||||
expect(wrapper.getComponent(NTag).props('type')).toBe('default')
|
||||
expect(wrapper.text()).toContain('请求结果未知 1 步')
|
||||
expect(wrapper.text()).not.toContain('制作任务执行失败')
|
||||
})
|
||||
it('免费恢复关联原失败历史,只有免费 GET,不出现重新生成成功', async () => {
|
||||
const original = execution('recovery-ui', {
|
||||
id: 'failed-original',
|
||||
workflowName: 'storyboard-visual-state',
|
||||
status: 'failed',
|
||||
error: '原结果校验未通过'
|
||||
})
|
||||
const fetcher = vi.fn<typeof fetch>().mockResolvedValue(response(original))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(WorkflowExecutionPanel, {
|
||||
props: {
|
||||
execution: execution('recovery-ui', {
|
||||
workflowName: 'storyboard-visual-state',
|
||||
metadata: { recoveryOf: original.id },
|
||||
result: { recovered: true, actualModelRequests: 0 }
|
||||
}),
|
||||
loading: false,
|
||||
error: ''
|
||||
}
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('新增模型请求 0 次')
|
||||
expect(wrapper.text()).toContain('原失败执行仍保留为失败')
|
||||
expect(wrapper.text()).toContain('原结果校验未通过')
|
||||
expect(wrapper.text()).not.toContain('重新生成成功')
|
||||
expect(fetcher.mock.calls.every(([, options]) => options?.method === 'GET')).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('免费准备与精确范围确认', () => {
|
||||
it('未点击不请求,参考、计划和资产错误分开,不把失败当尚未生成', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>(async url => {
|
||||
if (String(url).endsWith('/references'))
|
||||
return new Response(JSON.stringify({ message: '参考数据读取失败' }), { status: 500 })
|
||||
if (String(url).endsWith('/production/plan'))
|
||||
return new Response(JSON.stringify({ message: '计划读取失败' }), { status: 500 })
|
||||
return response({ projectId: 'preparation-errors', completed: false })
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(StagedShotPreparation, {
|
||||
props: { projectId: 'preparation-errors', active: true, shots: [designedShot('one')] }
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
await flushPromises()
|
||||
expect(fetcher).not.toHaveBeenCalled()
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('参考数据读取失败')
|
||||
expect(wrapper.text()).toContain('计划读取失败')
|
||||
expect(wrapper.text()).toContain('尚未完成')
|
||||
expect(wrapper.text()).not.toContain('参考素材缺失')
|
||||
expect(fetcher.mock.calls.map(([url]) => String(url))).toEqual([
|
||||
'/api/storyboard-shots/one/references',
|
||||
'/api/projects/preparation-errors/production/plan',
|
||||
'/api/projects/preparation-errors/production/status'
|
||||
])
|
||||
expect(fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')).toHaveLength(1)
|
||||
expect(JSON.parse(String(fetcher.mock.calls[1]![1]?.body))).toEqual({})
|
||||
})
|
||||
it('关闭抽屉取消完整计划,迟到响应不回填也不再读取资产状态', async () => {
|
||||
let resolvePlan!: (value: Response) => void
|
||||
let planSignal: AbortSignal | null = null
|
||||
const fetcher = vi.fn<typeof fetch>(async (url, init) => {
|
||||
if (String(url).endsWith('/references')) return response({ shotId: 'one', references: [], missing: [] })
|
||||
planSignal = init?.signal as AbortSignal
|
||||
return new Promise(resolve => {
|
||||
resolvePlan = resolve
|
||||
})
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const wrapper = mount(StagedShotPreparation, {
|
||||
props: { projectId: 'cancel-plan', active: true, shots: [designedShot('one')] }
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
await flushPromises()
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(fetcher).toHaveBeenCalledTimes(2)
|
||||
await wrapper.setProps({ active: false })
|
||||
await flushPromises()
|
||||
expect((planSignal as AbortSignal | null)?.aborted).toBe(true)
|
||||
resolvePlan(response({ projectId: 'cancel-plan', entryReadiness: { ready: true }, stageReadiness: {} }))
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).not.toContain('项目生产入口:已就绪')
|
||||
expect(fetcher).toHaveBeenCalledTimes(2)
|
||||
})
|
||||
it('同镜头数量但身份改变时撤销旧费用确认', async () => {
|
||||
const wrapper = mount(ConfirmAction, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
label: '补齐所选 1 镜',
|
||||
description: '收费文本模型与覆盖影响说明',
|
||||
confirmationKey: 'shot-one',
|
||||
acknowledgement: true
|
||||
}
|
||||
})
|
||||
wrappers.push(wrapper)
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
const checkbox = document.querySelector<HTMLElement>('.app-dialog [role="checkbox"]')!
|
||||
checkbox.click()
|
||||
await flushPromises()
|
||||
const confirm = [...document.querySelectorAll<HTMLButtonElement>('.app-dialog button')].find(
|
||||
button => button.textContent?.trim() === '确认补齐所选 1 镜'
|
||||
)!
|
||||
expect(confirm.disabled).toBe(false)
|
||||
await wrapper.setProps({ confirmationKey: 'shot-two' })
|
||||
await flushPromises()
|
||||
expect(confirm.disabled).toBe(true)
|
||||
expect(wrapper.emitted('confirm')).toBeUndefined()
|
||||
})
|
||||
})
|
||||
@@ -117,6 +117,19 @@ function stubFetch(fetcher: Mock<typeof fetch>) {
|
||||
const current = preparationFixture(fixture.id)
|
||||
return jsonResponse({ ...current.approval, valid: true, confirmation: current.record })
|
||||
}
|
||||
if (path.endsWith('/production/entry-readiness'))
|
||||
return jsonResponse({
|
||||
...preparationFixture(fixture.id).entry,
|
||||
derivedAssets: {
|
||||
shotCount: 4,
|
||||
directionCount: 2,
|
||||
directionCoverage: 0.5,
|
||||
visualStateCount: 0,
|
||||
visualStateCoverage: 0,
|
||||
staleDirectionCount: 0,
|
||||
staleVisualStateCount: 0
|
||||
}
|
||||
})
|
||||
if (path.endsWith('/generation-models')) return jsonResponse(imageCatalog)
|
||||
if (path.endsWith('/creative-profile')) return jsonResponse(generationProfile(fixture.id))
|
||||
/** 主体与首帧表单使用原配置解析接口,不创建图片候选。 */
|
||||
@@ -284,6 +297,8 @@ async function mountStoryboard() {
|
||||
})
|
||||
await flushPromises()
|
||||
await expandSections()
|
||||
selectControl(wrapper!, 'aria-label', '派生生成范围').vm.$emit('update:value', 'project')
|
||||
await flushPromises()
|
||||
return provided
|
||||
}
|
||||
|
||||
@@ -1830,8 +1845,8 @@ describe('工作台页面交互', () => {
|
||||
stubFetch(fetcher)
|
||||
await mountStoryboard()
|
||||
await flushPromises()
|
||||
await confirmGeneration('补齐项目导演设计')
|
||||
expect(button('补齐项目导演设计').disabled).toBe(true)
|
||||
await confirmGeneration('补齐全项目摄影设计')
|
||||
expect(button('补齐全项目摄影设计').disabled).toBe(true)
|
||||
await drawerPanel().get('.app-drawer-footer button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper!.get('[data-workspace-tools]').attributes('aria-expanded')).toBe('false')
|
||||
@@ -1854,15 +1869,15 @@ describe('工作台页面交互', () => {
|
||||
await flushPromises()
|
||||
expect(getStoryboardSession(fixture.id).receipt).toMatchObject({
|
||||
kind: 'batch',
|
||||
title: '项目导演设计'
|
||||
title: '摄影设计任务'
|
||||
})
|
||||
expect(getOperation(fixture.id).pending).toBe(false)
|
||||
const posts = fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')
|
||||
expect(posts).toHaveLength(1)
|
||||
expect(JSON.parse(posts[0]![1]!.body as string)).toEqual({ concurrency: 2, force: false })
|
||||
expect(JSON.parse(posts[0]![1]!.body as string)).toEqual({ concurrency: 1, force: false })
|
||||
})
|
||||
|
||||
it('分镜只提供正式项目生成,逐集失败回执保留零次修复参数', async () => {
|
||||
it('分镜保留显式批量范围,逐集失败回执保留零次修复参数', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async (url, init) => {
|
||||
if (init?.method === 'POST')
|
||||
return new Response(
|
||||
@@ -1899,15 +1914,18 @@ describe('工作台页面交互', () => {
|
||||
await flushPromises()
|
||||
expect(wrapper!.text()).not.toContain('生成本集导演设计')
|
||||
expect(wrapper!.text()).not.toContain('生成本集即时状态')
|
||||
expect(button('补齐项目导演设计').disabled).toBe(false)
|
||||
expect(button('补齐项目即时状态').disabled).toBe(false)
|
||||
expect(button('补齐全项目摄影设计').disabled).toBe(false)
|
||||
selectControl(wrapper!, 'aria-label', '派生生成范围').vm.$emit('update:value', 'episode')
|
||||
await flushPromises()
|
||||
expect(button('补齐第 1 集画面状态').disabled).toBe(false)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method !== 'POST')).toBe(true)
|
||||
await drawerPanel().get('#storyboard-repairs').setValue('0')
|
||||
await confirmGeneration('补齐项目即时状态')
|
||||
await confirmGeneration('补齐第 1 集画面状态')
|
||||
const post = fetcher.mock.calls.find(([, init]) => init?.method === 'POST')!
|
||||
expect(JSON.parse(post[1]!.body as string)).toEqual({
|
||||
concurrency: 2,
|
||||
concurrency: 1,
|
||||
force: false,
|
||||
episodeNo: 1,
|
||||
maxRepairAttempts: 0
|
||||
})
|
||||
expect(drawerPanel().text()).toContain('本次有未完成项')
|
||||
@@ -1998,15 +2016,18 @@ describe('工作台页面交互', () => {
|
||||
stubFetch(fetcher)
|
||||
await mountStoryboard()
|
||||
await flushPromises()
|
||||
await confirmGeneration('补齐项目导演设计')
|
||||
await confirmGeneration('补齐全项目摄影设计')
|
||||
expect(drawerPanel().get('[aria-label="生成回执"] [role="alert"]').text()).toContain('本次有未完成项')
|
||||
expect(drawerPanel().text()).toContain('模型校验失败')
|
||||
await drawerPanel().get('[role="checkbox"]').trigger('click')
|
||||
await confirmGeneration('重生成全部导演设计')
|
||||
await drawerPanel()
|
||||
.findAll('[role="checkbox"]')
|
||||
.find(item => item.text().includes('覆盖本次范围已有结果'))!
|
||||
.trigger('click')
|
||||
await confirmGeneration('重生成全项目摄影设计')
|
||||
const posts = fetcher.mock.calls.filter(([, init]) => init?.method === 'POST')
|
||||
expect(posts.map(([, init]) => JSON.parse(init!.body as string))).toEqual([
|
||||
{ concurrency: 2, force: false },
|
||||
{ concurrency: 2, force: true }
|
||||
{ concurrency: 1, force: false },
|
||||
{ concurrency: 1, force: true }
|
||||
])
|
||||
})
|
||||
|
||||
@@ -2052,7 +2073,7 @@ describe('工作台页面交互', () => {
|
||||
/** 切换剧集只增加当前集查询,项目时长预算只在挂载时读取一次。 */
|
||||
expect(
|
||||
fetcher.mock.calls.filter(([url]) => !String(url).endsWith('/storyboard-quality-confirmation'))
|
||||
).toHaveLength(6)
|
||||
).toHaveLength(7)
|
||||
expect(
|
||||
fetcher.mock.calls.filter(([url]) => String(url).endsWith('/storyboard-quality-confirmation'))
|
||||
).toHaveLength(1)
|
||||
@@ -2076,11 +2097,11 @@ describe('工作台页面交互', () => {
|
||||
await mountStoryboard()
|
||||
await flushPromises()
|
||||
expect(wrapper!.text()).toContain('数据库暂不可用')
|
||||
expect(button('补齐项目导演设计').disabled).toBe(true)
|
||||
expect(button('补齐全项目摄影设计').disabled).toBe(true)
|
||||
fail = false
|
||||
button('重试查询').click()
|
||||
await flushPromises()
|
||||
expect(button('补齐项目导演设计').disabled).toBe(false)
|
||||
expect(button('补齐全项目摄影设计').disabled).toBe(false)
|
||||
/** 重试恢复正式镜头数据,内部编号仍用于业务选择。 */
|
||||
expect(wrapper!.getComponent(ShotDesign).props('shot').shotId).toBe('shot-db-1-1')
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user