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
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user