feat(short-drama-agent-front): 新增诊断抽屉并优化项目弹窗
This commit is contained in:
1 parent
97dc784c8b
commit
49ad08a63e
21 files changed
+1479
-363
No files matched your search
@@ -13,7 +13,7 @@ import { Layers, LoaderCircle, ArrowRight, Settings2 } from '@lucide/vue'
|
||||
import { EmptyState, StatusBadge, WorkspaceTools } from '../../components/ui'
|
||||
import { useProjectContext } from '../projects/context'
|
||||
import { breakdownApi } from './api'
|
||||
import type { BreakdownAction, BreakdownInput, BreakdownModule, BreakdownPreview, StoryboardHandOccupancyDiagnostics, StoryboardHandRepairPreview, LegacyActionDiagnosisPreview, LegacyActionDiagnosisResults } from './types'
|
||||
import type { BreakdownAction, BreakdownInput, BreakdownModule, BreakdownPreview } from './types'
|
||||
import { breakdownSnapshot, recoveryOptions, workflowCheckpoints } from '../workflows/selectors'
|
||||
import { getOperation, isOperationRunning, runOperation } from '../workflows/operations'
|
||||
import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
@@ -21,6 +21,8 @@ import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
|
||||
import { useWorkflowExecution } from '../workflows/execution'
|
||||
import SubjectList from './components/SubjectList.vue'
|
||||
import StoryboardList from './components/StoryboardList.vue'
|
||||
import StoryboardDiagnosis from './components/StoryboardDiagnosis.vue'
|
||||
import type { DiagnosisLocation } from './diagnosis'
|
||||
import { errorMessage } from '../../lib/http'
|
||||
import { downloadText, nodeLabel } from '../../lib/format'
|
||||
|
||||
@@ -32,42 +34,6 @@ const preview = ref<BreakdownPreview | null>(null)
|
||||
const previewBusy = ref(false)
|
||||
const tab = ref('character')
|
||||
const toolsOpen = ref(false)
|
||||
/** 分镜诊断与拆解设置解耦,默认不占用列表空间。 */
|
||||
const qualityPanelOpen = ref(false)
|
||||
/** 仅打开设置面板时按需查询,不增加页面常驻提示或后台轮询。 */
|
||||
const handDiagnostics = ref<StoryboardHandOccupancyDiagnostics | null>(null)
|
||||
const handDiagnosticsBusy = ref(false)
|
||||
const handRepairPreview = ref<StoryboardHandRepairPreview | null>(null)
|
||||
const handRepairBusy = ref(false)
|
||||
/** 只在用户主动查看时加载修复候选,避免打开设置就请求额外接口。 */
|
||||
async function loadHandRepairPreview(id: string) {
|
||||
const version = handDiagnosticsVersion
|
||||
handRepairBusy.value = true
|
||||
try {
|
||||
const data = await breakdownApi.handRepairPreview(id)
|
||||
if (version === handDiagnosticsVersion && qualityPanelOpen.value && projectId.value === id) handRepairPreview.value = data
|
||||
} catch (cause) {
|
||||
if (version === handDiagnosticsVersion && qualityPanelOpen.value && projectId.value === id) actionMessage?.error(errorMessage(cause))
|
||||
} finally {
|
||||
if (version === handDiagnosticsVersion) handRepairBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
let handDiagnosticsVersion = 0
|
||||
async function loadHandDiagnostics(id: string) {
|
||||
const version = ++handDiagnosticsVersion
|
||||
handDiagnosticsBusy.value = true
|
||||
handDiagnostics.value = null
|
||||
try {
|
||||
const data = await breakdownApi.handOccupancyDiagnostics(id)
|
||||
if (version === handDiagnosticsVersion && qualityPanelOpen.value && projectId.value === id) handDiagnostics.value = data
|
||||
} catch (cause) {
|
||||
if (version === handDiagnosticsVersion && qualityPanelOpen.value && projectId.value === id) actionMessage?.error(errorMessage(cause))
|
||||
} finally {
|
||||
if (version === handDiagnosticsVersion) handDiagnosticsBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const moduleOptions: { value: BreakdownModule; label: string; description: string }[] = [
|
||||
{ value: 'character', label: '人物', description: '人物身份、外观与形态' },
|
||||
{ value: 'scene', label: '场景', description: '故事空间与环境特征' },
|
||||
@@ -84,101 +50,37 @@ const summary = computed(() => snapshot.value?.taskSummary)
|
||||
const validation = computed(() => result.value?.storyboardShotValidation ?? snapshot.value?.storyboardShotValidation)
|
||||
const projectId = computed(() => project.value?.id ?? '')
|
||||
const operation = computed(() => getOperation(projectId.value))
|
||||
watch([qualityPanelOpen, projectId], () => {
|
||||
++handDiagnosticsVersion
|
||||
handDiagnostics.value = null
|
||||
handDiagnosticsBusy.value = false
|
||||
handRepairPreview.value = null
|
||||
handRepairBusy.value = false
|
||||
++legacyResultsRequest
|
||||
legacyResultsBusy.value = false
|
||||
legacyResults.value = null
|
||||
/** 分镜阅读和诊断入口共用当前剧集,不维护独立的诊断集号输入。 */
|
||||
const selectedEpisodeNo = ref<number>()
|
||||
/** 按正式规划回退到首集,与分镜列表的默认选中保持一致。 */
|
||||
const currentEpisodeNo = computed(() => {
|
||||
const available = plans.value.length ? plans.value : shots.value.map(item => item.episodePlan)
|
||||
return (available.find(item => item.episodeNo === selectedEpisodeNo.value) ?? available[0])?.episodeNo
|
||||
})
|
||||
|
||||
/** 历史镜头 AI 诊断使用独立的持久化任务观察器,刷新后可恢复进度。 */
|
||||
const legacyDiagnosisExecution = useWorkflowExecution(projectId, 'storyboard-legacy-action-diagnosis')
|
||||
const legacyEpisodeNo = ref(3)
|
||||
const legacyConcurrency = ref(3)
|
||||
const legacyPreview = ref<LegacyActionDiagnosisPreview | null>(null)
|
||||
const legacyPreviewBusy = ref(false)
|
||||
const legacyStarting = ref(false)
|
||||
const legacyDiagnosisScope = ref<'episode' | 'project' | 'beat' | 'shot'>('episode')
|
||||
const legacyBeatNo = ref<number>()
|
||||
const legacyShotNo = ref<number>()
|
||||
const legacyResults = ref<LegacyActionDiagnosisResults | null>(null)
|
||||
const legacyResultsBusy = ref(false)
|
||||
let legacyResultsRequest = 0
|
||||
async function loadLegacyResults() {
|
||||
const id = projectId.value
|
||||
const version = handDiagnosticsVersion
|
||||
const requestVersion = ++legacyResultsRequest
|
||||
const episode = legacyDiagnosisScope.value === 'project' ? undefined : legacyEpisodeNo.value
|
||||
legacyResultsBusy.value = true
|
||||
try {
|
||||
const data = await breakdownApi.legacyActionDiagnosisResults(id, episode)
|
||||
if (requestVersion === legacyResultsRequest && version === handDiagnosticsVersion && projectId.value === id && qualityPanelOpen.value) legacyResults.value = data
|
||||
} catch (cause) {
|
||||
if (requestVersion === legacyResultsRequest && version === handDiagnosticsVersion && projectId.value === id && qualityPanelOpen.value) actionMessage?.error(errorMessage(cause))
|
||||
} finally {
|
||||
if (requestVersion === legacyResultsRequest) legacyResultsBusy.value = false
|
||||
}
|
||||
/** 项目预览涵盖正式剧集与已有分镜剧集,不遗漏已有分镜。 */
|
||||
const diagnosisEpisodeNos = computed(() => [
|
||||
...new Set([
|
||||
...(project.value?.episodes.map(item => item.episode) ?? []),
|
||||
...shots.value.map(item => item.episodeNo)
|
||||
])
|
||||
])
|
||||
/** 分镜列表仅暴露定位方法。 */
|
||||
const storyboardList = ref<InstanceType<typeof StoryboardList> | null>(null)
|
||||
/** 诊断组件仅暴露按范围打开方法。 */
|
||||
const diagnosisPanel = ref<InstanceType<typeof StoryboardDiagnosis> | null>(null)
|
||||
/**
|
||||
* 从分镜卡片直接打开对应的节拍或镜头诊断。
|
||||
* @param location 当前分镜坐标
|
||||
*/
|
||||
function openShotDiagnosis(location: DiagnosisLocation) {
|
||||
diagnosisPanel.value?.open(location)
|
||||
}
|
||||
watch(() => legacyDiagnosisExecution.query.data.value?.status, (status, previous) => {
|
||||
if (status && status !== previous && (status === 'completed' || status === 'failed') && qualityPanelOpen.value) {
|
||||
void loadLegacyResults()
|
||||
}
|
||||
})
|
||||
|
||||
watch([legacyEpisodeNo, legacyBeatNo, legacyShotNo, legacyDiagnosisScope, projectId], () => {
|
||||
++legacyResultsRequest
|
||||
legacyResultsBusy.value = false
|
||||
legacyPreview.value = null
|
||||
legacyResults.value = null
|
||||
})
|
||||
const legacyDiagnosisDescription = computed(() => legacyDiagnosisScope.value === 'project' ? '全项目历史镜头 AI 诊断,已有有效结果将跳过。会产生模型费用,不会修改镜头。' : `第 ${legacyEpisodeNo.value} 集,共 ${legacyPreview.value?.candidateCount ?? '未知'} 个镜头,并发 ${legacyConcurrency.value}。会产生模型费用,已有有效结果将跳过。`)
|
||||
|
||||
async function loadLegacyPreview() {
|
||||
const id = projectId.value
|
||||
const version = handDiagnosticsVersion
|
||||
legacyPreviewBusy.value = true
|
||||
try {
|
||||
const data = await breakdownApi.legacyActionDiagnosisPreview(id, legacyEpisodeNo.value,
|
||||
legacyDiagnosisScope.value === 'beat' || legacyDiagnosisScope.value === 'shot' ? legacyBeatNo.value : undefined,
|
||||
legacyDiagnosisScope.value === 'shot' ? legacyShotNo.value : undefined)
|
||||
if (version === handDiagnosticsVersion && projectId.value === id && qualityPanelOpen.value) legacyPreview.value = data
|
||||
} catch (cause) {
|
||||
if (version === handDiagnosticsVersion && projectId.value === id && qualityPanelOpen.value) actionMessage?.error(errorMessage(cause))
|
||||
} finally {
|
||||
if (version === handDiagnosticsVersion) legacyPreviewBusy.value = false
|
||||
}
|
||||
}
|
||||
/** 从 Beat / Shot 悬停入口定位诊断范围,并复用统一费用确认。 */
|
||||
async function openLegacyShotDiagnosis(scope: { episodeNo: number; beatNo: number; shotNo?: number }) {
|
||||
legacyEpisodeNo.value = scope.episodeNo
|
||||
legacyBeatNo.value = scope.beatNo
|
||||
legacyShotNo.value = scope.shotNo
|
||||
legacyDiagnosisScope.value = scope.shotNo === undefined ? 'beat' : 'shot'
|
||||
tab.value = 'storyboard'
|
||||
qualityPanelOpen.value = true
|
||||
await loadLegacyPreview()
|
||||
}
|
||||
async function startLegacyDiagnosis() {
|
||||
const id = projectId.value
|
||||
legacyStarting.value = true
|
||||
try {
|
||||
const diagnosisTask = await breakdownApi.startLegacyActionDiagnosis(id, {
|
||||
confirmed: true,
|
||||
...(legacyDiagnosisScope.value !== 'project' ? { episodeNo: legacyEpisodeNo.value } : {}),
|
||||
...(legacyDiagnosisScope.value === 'beat' || legacyDiagnosisScope.value === 'shot' ? { beatNo: legacyBeatNo.value } : {}),
|
||||
...(legacyDiagnosisScope.value === 'shot' ? { shotNo: legacyShotNo.value } : {}),
|
||||
concurrency: legacyConcurrency.value
|
||||
})
|
||||
await legacyDiagnosisExecution.track(diagnosisTask.executionId, id)
|
||||
} catch (cause) {
|
||||
actionMessage?.error(errorMessage(cause))
|
||||
} finally {
|
||||
legacyStarting.value = false
|
||||
}
|
||||
/**
|
||||
* 诊断问题定位到分镜正文,必要时切换到对应剧集。
|
||||
* @param location 待定位的分镜坐标
|
||||
*/
|
||||
function locateDiagnosisShot(location: DiagnosisLocation) {
|
||||
void storyboardList.value?.locate(location)
|
||||
}
|
||||
const backgroundExecution = useWorkflowExecution(projectId, 'breakdown')
|
||||
const recovery = computed(() => recoveryOptions(checkpoints.value))
|
||||
@@ -684,103 +586,23 @@ const rules = {
|
||||
/></div
|
||||
></template>
|
||||
<div v-if="tab === 'storyboard'" class="breakdown-result-pad">
|
||||
<div class="mb-3 flex justify-end">
|
||||
<NButton text @click="qualityPanelOpen = !qualityPanelOpen">{{ qualityPanelOpen ? '收起质量诊断' : '分镜质量诊断' }}</NButton>
|
||||
</div>
|
||||
<div v-if="qualityPanelOpen" class="mb-5 space-y-3">
|
||||
<div class="text-sm font-medium">分镜质量诊断</div>
|
||||
<!-- 手部动作诊断按需读取,历史镜头缺少证据时不误报为安全。 -->
|
||||
<section class="workspace-panel">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">结构化动作校验</h3>
|
||||
<NButton text :loading="handDiagnosticsBusy" :disabled="!projectId || handDiagnosticsBusy" @click="loadHandDiagnostics(projectId)">{{ handDiagnostics ? '刷新' : '查看诊断' }}</NButton>
|
||||
</div>
|
||||
<div v-if="handDiagnostics" class="mt-3 flex flex-wrap gap-x-4 gap-y-2 text-xs text-muted">
|
||||
<span>镜头 {{ handDiagnostics.shotCount }}</span>
|
||||
<span>有效证据 {{ handDiagnostics.evidenceShotCount }} / {{ handDiagnostics.shotCount }}</span>
|
||||
<span>冲突 {{ handDiagnostics.warningCount }}</span>
|
||||
<span v-if="handDiagnostics.assessment === 'insufficient_evidence'">证据不足</span>
|
||||
<span v-else-if="handDiagnostics.assessment === 'partial_evidence'">部分镜头缺少证据</span>
|
||||
</div>
|
||||
<div v-if="handDiagnostics?.diagnostics.length" class="mt-3 space-y-2 text-xs">
|
||||
<div v-for="(issue, index) in handDiagnostics.diagnostics" :key="index">
|
||||
第 {{ issue.episodeNo }} 集 / Beat {{ issue.beatNo }} / Shot {{ issue.shotNo }} / 阶段 {{ issue.phaseNo }}:{{ issue.suggestion }}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="workspace-panel">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">历史镜头 AI 诊断</h3>
|
||||
<NButton text :loading="legacyPreviewBusy" @click="loadLegacyPreview">预览范围</NButton>
|
||||
</div>
|
||||
<div class="mt-3 flex flex-wrap items-center gap-3">
|
||||
<NButton size="small" :type="legacyDiagnosisScope === 'episode' ? 'primary' : 'default'" @click="legacyDiagnosisScope = 'episode'">单集</NButton>
|
||||
<NButton size="small" :type="legacyDiagnosisScope === 'project' ? 'primary' : 'default'" @click="legacyDiagnosisScope = 'project'">全项目</NButton>
|
||||
<span v-if="legacyDiagnosisScope === 'beat' || legacyDiagnosisScope === 'shot'" class="text-xs text-muted">Beat {{ legacyBeatNo }}{{ legacyDiagnosisScope === 'shot' ? ` / Shot ${legacyShotNo}` : '' }}</span>
|
||||
<NInputNumber v-if="legacyDiagnosisScope !== 'project'" v-model:value="legacyEpisodeNo" :min="1" :precision="0" size="small" class="w-24" />
|
||||
<span class="text-xs text-muted">并发</span>
|
||||
<NInputNumber v-model:value="legacyConcurrency" :min="1" :max="5" :precision="0" size="small" class="w-20" />
|
||||
</div>
|
||||
<div v-if="legacyPreview" class="mt-3 text-xs text-muted">
|
||||
第 {{ legacyPreview.episodeNo }} 集:{{ legacyPreview.candidateCount }} 个镜头,{{ legacyPreview.needsEvidenceCount }} 个待补证据
|
||||
</div>
|
||||
<div class="mt-3 flex justify-end">
|
||||
<ConfirmAction label="启动 AI 诊断" :description="legacyDiagnosisDescription"
|
||||
:loading="legacyStarting" :disabled="legacyDiagnosisExecution.active.value || legacyStarting || (legacyDiagnosisScope !== 'project' && !legacyPreview)"
|
||||
primary @confirm="startLegacyDiagnosis" />
|
||||
</div>
|
||||
<div class="mt-3 flex flex-wrap items-center justify-between gap-3">
|
||||
<span class="text-xs text-muted">诊断结果</span>
|
||||
<NButton text :loading="legacyResultsBusy" @click="loadLegacyResults">查看结果</NButton>
|
||||
</div>
|
||||
<div v-if="legacyResults" class="mt-2 space-y-3 text-xs">
|
||||
<div class="flex flex-wrap gap-x-4 gap-y-2 text-muted">
|
||||
<span>总计 {{ legacyResults.counts.total }}</span>
|
||||
<span>冲突 {{ legacyResults.counts.conflict }}</span>
|
||||
<span>未发现冲突 {{ legacyResults.counts.clear }}</span>
|
||||
<span>证据不足 {{ legacyResults.counts.insufficient }}</span>
|
||||
<span>证据无效 {{ legacyResults.counts.invalid }}</span>
|
||||
<span>已过期 {{ legacyResults.counts.stale }}</span>
|
||||
<span>未诊断 {{ legacyResults.counts.pending }}</span>
|
||||
</div>
|
||||
<div v-for="item in legacyResults.shots.filter(shot => shot.status !== 'no_conflict_found')" :key="item.shotId" class="py-1">
|
||||
第 {{ item.episodeNo }} 集 / Beat {{ item.beatNo }} / Shot {{ item.shotNo }} · {{ item.title }}
|
||||
<span class="ml-2 text-muted">{{ ({
|
||||
conflict_found: '手部冲突',
|
||||
insufficient_evidence: '证据不足',
|
||||
invalid_evidence: '证据无效',
|
||||
stale: '诊断过期',
|
||||
not_diagnosed: '尚未诊断',
|
||||
no_conflict_found: '未发现冲突'
|
||||
} as const)[item.status] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<WorkflowExecutionPanel v-if="legacyDiagnosisExecution.executionId.value"
|
||||
title="历史动作诊断任务"
|
||||
:execution="legacyDiagnosisExecution.query.data.value ?? null"
|
||||
:loading="legacyDiagnosisExecution.query.loading.value"
|
||||
:error="legacyDiagnosisExecution.query.error.value ?? ''"
|
||||
@refresh="legacyDiagnosisExecution.query.refresh()"
|
||||
@dismiss="legacyDiagnosisExecution.dismiss()" />
|
||||
</section>
|
||||
<section v-if="handDiagnostics?.warningCount" class="workspace-panel">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">局部修复候选</h3>
|
||||
<NButton text :loading="handRepairBusy" :disabled="handRepairBusy" @click="loadHandRepairPreview(projectId)">
|
||||
{{ handRepairPreview ? '刷新候选' : '查看候选' }}
|
||||
</NButton>
|
||||
</div>
|
||||
<div v-if="handRepairPreview" class="mt-3 space-y-2 text-xs">
|
||||
<div v-for="(item, index) in handRepairPreview.candidates" :key="index" class="space-y-1">
|
||||
<p>第 {{ item.episodeNo }} 集 / Beat {{ item.beatNo }} / Shot {{ item.shotNo }} / 阶段 {{ item.phaseNo }}</p>
|
||||
<p class="text-muted">{{ item.suggestion }}</p>
|
||||
<p v-if="item.blockingReasons.length" class="text-muted">{{ item.blockingReasons.join(';') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
</div>
|
||||
<StoryboardList :plans="plans" :episodes="shots" @diagnose="openLegacyShotDiagnosis">
|
||||
<StoryboardList
|
||||
ref="storyboardList"
|
||||
v-model:episode-no="selectedEpisodeNo"
|
||||
:plans="plans"
|
||||
:episodes="shots"
|
||||
@diagnose="openShotDiagnosis"
|
||||
>
|
||||
<!-- 以下是跟随当前剧集的一行诊断摘要,抽屉独立于列表滚动 -->
|
||||
<template #diagnosis>
|
||||
<StoryboardDiagnosis
|
||||
ref="diagnosisPanel"
|
||||
:project-id="projectId"
|
||||
:episode-no="currentEpisodeNo"
|
||||
:episode-nos="diagnosisEpisodeNos"
|
||||
@locate="locateDiagnosisShot"
|
||||
/>
|
||||
</template>
|
||||
<template #actions>
|
||||
<RouterLink :to="`/projects/${project?.id}/storyboard`" class="text-button"
|
||||
>进入分镜设计<ArrowRight :size="14"
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import { optionalResource, request } from '../../lib/http'
|
||||
import type { BreakdownAction, BreakdownInput, BreakdownPreview, BreakdownState, StoryboardHandOccupancyDiagnostics, StoryboardHandRepairPreview, StoryboardHandRepairHistory, LegacyActionDiagnosisPreview, LegacyActionDiagnosisBatchStart, LegacyActionDiagnosisResults } from './types'
|
||||
import type {
|
||||
BreakdownAction,
|
||||
BreakdownInput,
|
||||
BreakdownPreview,
|
||||
BreakdownState,
|
||||
StoryboardHandOccupancyDiagnostics,
|
||||
StoryboardHandRepairPreview,
|
||||
StoryboardHandRepairHistory,
|
||||
LegacyActionDiagnosisPreview,
|
||||
LegacyActionDiagnosisBatchStart,
|
||||
LegacyActionDiagnosisResults
|
||||
} from './types'
|
||||
import type { WorkflowExecutionStart } from '../workflows/execution.types'
|
||||
|
||||
/** Breakdown API;预览为 GET,启动和恢复为等待完成的长 POST。 */
|
||||
@@ -9,30 +20,47 @@ export const breakdownApi = {
|
||||
return request<BreakdownPreview>(`/projects/${encodeURIComponent(id)}/breakdown-preview?${query}`, { signal })
|
||||
},
|
||||
handOccupancyDiagnostics: (id: string, signal?: AbortSignal) =>
|
||||
request<StoryboardHandOccupancyDiagnostics>(`/projects/${encodeURIComponent(id)}/breakdown/storyboard-hand-occupancy-diagnostics`, { signal }),
|
||||
request<StoryboardHandOccupancyDiagnostics>(
|
||||
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-hand-occupancy-diagnostics`,
|
||||
{ signal }
|
||||
),
|
||||
handRepairPreview: (id: string, signal?: AbortSignal) =>
|
||||
request<StoryboardHandRepairPreview>(`/projects/${encodeURIComponent(id)}/breakdown/storyboard-hand-occupancy-repair-preview`, { signal }),
|
||||
request<StoryboardHandRepairPreview>(
|
||||
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-hand-occupancy-repair-preview`,
|
||||
{ signal }
|
||||
),
|
||||
handRepairHistory: (id: string, shotId: string, signal?: AbortSignal) =>
|
||||
request<StoryboardHandRepairHistory>(`/projects/${encodeURIComponent(id)}/breakdown/storyboard-hand-occupancy-repair-history/${encodeURIComponent(shotId)}`, { signal }),
|
||||
request<StoryboardHandRepairHistory>(
|
||||
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-hand-occupancy-repair-history/${encodeURIComponent(shotId)}`,
|
||||
{ signal }
|
||||
),
|
||||
legacyActionDiagnosisPreview: (id: string, episodeNo: number, beatNo?: number, shotNo?: number) => {
|
||||
const query = new URLSearchParams({ episodeNo: String(episodeNo) })
|
||||
if (beatNo !== undefined) query.set('beatNo', String(beatNo))
|
||||
if (shotNo !== undefined) query.set('shotNo', String(shotNo))
|
||||
return request<LegacyActionDiagnosisPreview>(`/projects/${encodeURIComponent(id)}/breakdown/storyboard-legacy-action-diagnosis-preview?${query}`)
|
||||
return request<LegacyActionDiagnosisPreview>(
|
||||
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-legacy-action-diagnosis-preview?${query}`
|
||||
)
|
||||
},
|
||||
startLegacyActionDiagnosis: (id: string, input: {
|
||||
episodeNo?: number
|
||||
beatNo?: number
|
||||
shotNo?: number
|
||||
concurrency: number
|
||||
confirmed: true
|
||||
}) => request<LegacyActionDiagnosisBatchStart>(
|
||||
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-legacy-action-diagnose-batch`,
|
||||
{ method: 'POST', body: input }
|
||||
),
|
||||
startLegacyActionDiagnosis: (
|
||||
id: string,
|
||||
input: {
|
||||
episodeNo?: number
|
||||
beatNo?: number
|
||||
shotNo?: number
|
||||
concurrency: number
|
||||
confirmed: true
|
||||
}
|
||||
) =>
|
||||
request<LegacyActionDiagnosisBatchStart>(
|
||||
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-legacy-action-diagnose-batch`,
|
||||
{ method: 'POST', body: input }
|
||||
),
|
||||
legacyActionDiagnosisResults: (id: string, episodeNo?: number) => {
|
||||
const query = episodeNo === undefined ? '' : `?episodeNo=${episodeNo}`
|
||||
return request<LegacyActionDiagnosisResults>(`/projects/${encodeURIComponent(id)}/breakdown/storyboard-legacy-action-diagnosis-results${query}`)
|
||||
return request<LegacyActionDiagnosisResults>(
|
||||
`/projects/${encodeURIComponent(id)}/breakdown/storyboard-legacy-action-diagnosis-results${query}`
|
||||
)
|
||||
},
|
||||
latest: (id: string, signal?: AbortSignal) =>
|
||||
optionalResource(request<BreakdownState>(`/projects/${encodeURIComponent(id)}/breakdown/latest`, { signal })),
|
||||
|
||||
@@ -0,0 +1,766 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import {
|
||||
NButton,
|
||||
NCollapse,
|
||||
NCollapseItem,
|
||||
NDrawer,
|
||||
NDrawerContent,
|
||||
NInputNumber,
|
||||
NScrollbar,
|
||||
NSelect,
|
||||
NTag
|
||||
} from 'naive-ui'
|
||||
import { ScanLine } from '@lucide/vue'
|
||||
import { breakdownApi } from '../api'
|
||||
import { diagnosisInput, diagnosisStatusLabels, scopeDiagnosisShots, summarizeDiagnosis } from '../diagnosis'
|
||||
import type { DiagnosisLocation, DiagnosisScope } from '../diagnosis'
|
||||
import type {
|
||||
LegacyActionDiagnosisPreview,
|
||||
LegacyActionDiagnosisResults,
|
||||
StoryboardHandOccupancyDiagnostics,
|
||||
StoryboardHandRepairPreview
|
||||
} from '../types'
|
||||
import ConfirmAction from '../../workflows/ConfirmAction.vue'
|
||||
import WorkflowExecutionPanel from '../../workflows/WorkflowExecutionPanel.vue'
|
||||
import { useWorkflowExecution } from '../../workflows/execution'
|
||||
import { useActionMessage } from '../../../components/ui/useActionMessage'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
|
||||
/** 当前分镜上下文;诊断入口与列表共用同一个正式剧集。 */
|
||||
const props = defineProps<{
|
||||
/** 正式项目编号。 */
|
||||
projectId: string
|
||||
/** 当前阅读的剧集编号。 */
|
||||
episodeNo?: number
|
||||
/** 全项目预览所需的正式剧集编号。 */
|
||||
episodeNos: number[]
|
||||
}>()
|
||||
/** 关闭抽屉后定位对应镜头或节拍。 */
|
||||
const emit = defineEmits<{ locate: [location: DiagnosisLocation] }>()
|
||||
/** 统一操作消息层。 */
|
||||
const message = useActionMessage()
|
||||
/** 任务观察独立于抽屉显隐,关闭抽屉后继续跟踪真实进度。 */
|
||||
const execution = useWorkflowExecution(
|
||||
computed(() => props.projectId),
|
||||
'storyboard-legacy-action-diagnosis'
|
||||
)
|
||||
/** 右侧诊断抽屉是否展开。 */
|
||||
const drawerOpen = ref(false)
|
||||
/** 等待抽屉离场后再转移焦点,避免焦点陷阱把定位焦点拉回。 */
|
||||
const pendingLocation = ref<DiagnosisLocation | null>(null)
|
||||
/** 本次查看及提交的诊断范围。 */
|
||||
const scope = ref<DiagnosisScope>({ kind: 'project' })
|
||||
/** 当前集摘要与抽屉结果分开保存,切换抽屉范围不会改变摘要含义。 */
|
||||
const episodeResults = ref<LegacyActionDiagnosisResults | null>(null)
|
||||
/** 当前集摘要的读取状态。 */
|
||||
const summaryBusy = ref(false)
|
||||
/** 当前集摘要的读取错误。 */
|
||||
const summaryError = ref('')
|
||||
/** 抽屉范围对应的后端结果,节拍及镜头会再次筛选。 */
|
||||
const results = ref<LegacyActionDiagnosisResults | null>(null)
|
||||
/** 抽屉结果读取状态。 */
|
||||
const resultsBusy = ref(false)
|
||||
/** 抽屉结果读取错误。 */
|
||||
const resultsError = ref('')
|
||||
/** 只读范围预览;全项目按正式剧集汇总,任何一集失败都不能启动。 */
|
||||
const previews = ref<LegacyActionDiagnosisPreview[] | null>(null)
|
||||
/** 只读范围预览的读取状态。 */
|
||||
const previewBusy = ref(false)
|
||||
/** 范围预览的读取错误。 */
|
||||
const previewError = ref('')
|
||||
/** 模型任务并发数,默认值沿用原有能力。 */
|
||||
const concurrency = ref(3)
|
||||
/** 批量任务的启动状态。 */
|
||||
const starting = ref(false)
|
||||
/** 结果列表默认聚焦冲突、异常和过期,未诊断记录按需查看。 */
|
||||
const resultFilter = ref<'attention' | 'pending' | 'all'>('attention')
|
||||
/** 项目级结构化动作证据校验,明确区别于当前集 AI 诊断。 */
|
||||
const handDiagnostics = ref<StoryboardHandOccupancyDiagnostics | null>(null)
|
||||
/** 项目级校验的读取状态。 */
|
||||
const handBusy = ref(false)
|
||||
/** 项目级校验的读取错误。 */
|
||||
const handError = ref('')
|
||||
/** 当前主动展开修复建议的问题序号。 */
|
||||
const repairIssue = ref<number | null>(null)
|
||||
/** 只读修复建议,不提供自动写入操作。 */
|
||||
const repairPreview = ref<StoryboardHandRepairPreview | null>(null)
|
||||
/** 修复建议读取状态。 */
|
||||
const repairBusy = ref(false)
|
||||
/** 请求版本用于忽略范围变化、关闭抽屉及组件卸载后的迟到响应。 */
|
||||
let summaryVersion = 0
|
||||
/** 当前范围结果请求版本。 */
|
||||
let resultsVersion = 0
|
||||
/** 当前范围预览请求版本。 */
|
||||
let previewVersion = 0
|
||||
/** 项目级校验和修复建议的请求版本。 */
|
||||
let handVersion = 0
|
||||
|
||||
/** 当前查看范围的中文名称,同时用于费用确认。 */
|
||||
const scopeLabel = computed(() => {
|
||||
const target = scope.value
|
||||
if (target.kind === 'project') return '全项目'
|
||||
const episode = `第 ${target.episodeNo} 集`
|
||||
if (target.kind === 'episode') return episode
|
||||
return `${episode} / 节拍 ${target.beatNo}${target.kind === 'shot' ? ` / 镜头 ${target.shotNo}` : ''}`
|
||||
})
|
||||
/** 当前范围的稳定标识,范围切换立即使旧预览失效。 */
|
||||
const scopeKey = computed(() => JSON.stringify(scope.value))
|
||||
/** 当前集摘要根据真实诊断记录统计。 */
|
||||
const summaryCounts = computed(() => (episodeResults.value ? summarizeDiagnosis(episodeResults.value.shots) : null))
|
||||
/** 抽屉统计严格对应当前集、节拍或镜头范围。 */
|
||||
const scopedShots = computed(() => scopeDiagnosisShots(results.value?.shots ?? [], scope.value))
|
||||
/** 当前范围的状态计数。 */
|
||||
const counts = computed(() => summarizeDiagnosis(scopedShots.value))
|
||||
/** 按状态筛选的结果记录。 */
|
||||
const visibleShots = computed(() =>
|
||||
scopedShots.value.filter(
|
||||
shot =>
|
||||
resultFilter.value === 'all' ||
|
||||
(resultFilter.value === 'pending'
|
||||
? shot.status === 'not_diagnosed'
|
||||
: !['not_diagnosed', 'no_conflict_found'].includes(shot.status))
|
||||
)
|
||||
)
|
||||
/** 预览展示范围内的实际镜头总数,不把待补证据数量冒充付费数量。 */
|
||||
const previewCount = computed(() => previews.value?.reduce((sum, item) => sum + item.candidateCount, 0) ?? 0)
|
||||
/** 并发参数限制与后端请求契约一致。 */
|
||||
const concurrencyValid = computed(
|
||||
() => Number.isSafeInteger(concurrency.value) && concurrency.value >= 1 && concurrency.value <= 5
|
||||
)
|
||||
/** 启动前必须取得当前范围预览,并保证没有同项目同工作流活动任务。 */
|
||||
const canStart = computed(
|
||||
() =>
|
||||
!!previews.value &&
|
||||
previewCount.value > 0 &&
|
||||
concurrencyValid.value &&
|
||||
!previewBusy.value &&
|
||||
!execution.active.value &&
|
||||
!starting.value
|
||||
)
|
||||
/** 费用确认使用当前预览范围及并发,不虚构模型价格。 */
|
||||
const confirmation = computed(
|
||||
() =>
|
||||
`${scopeLabel.value},范围内共 ${previewCount.value} 个镜头,并发 ${concurrency.value}。会产生模型费用,已有当前版本有效诊断的镜头将跳过;仅保存诊断记录,不修改镜头。`
|
||||
)
|
||||
/** 顶部只显示当前集覆盖情况,未取得结果时不推断为安全或未诊断。 */
|
||||
const summaryText = computed(() => {
|
||||
const value = summaryCounts.value
|
||||
if (!props.episodeNo) return '尚无可诊断的剧集'
|
||||
if (summaryBusy.value) return '正在读取诊断记录…'
|
||||
if (summaryError.value) return '诊断记录读取失败'
|
||||
if (!value) return '尚未读取诊断记录'
|
||||
if (!value.total) return '本集尚无可诊断镜头'
|
||||
if (value.pending === value.total) return `${value.total} 个镜头尚未诊断`
|
||||
return `共 ${value.total} 镜 · 已发现冲突 ${value.conflict} · 待诊断 ${value.pending} · 证据不足/无效 ${value.insufficient + value.invalid} · 已过期 ${value.stale} · 未发现冲突 ${value.clear}`
|
||||
})
|
||||
|
||||
/** 读取当前集摘要,切换剧集后丢弃旧结果,不增加后台轮询。 */
|
||||
async function loadSummary() {
|
||||
const id = props.projectId
|
||||
const episodeNo = props.episodeNo
|
||||
const version = ++summaryVersion
|
||||
episodeResults.value = null
|
||||
summaryError.value = ''
|
||||
summaryBusy.value = !!id && episodeNo !== undefined
|
||||
if (!id || episodeNo === undefined) return
|
||||
try {
|
||||
const data = await breakdownApi.legacyActionDiagnosisResults(id, episodeNo)
|
||||
if (version === summaryVersion) episodeResults.value = data
|
||||
} catch (cause) {
|
||||
if (version === summaryVersion) summaryError.value = errorMessage(cause)
|
||||
} finally {
|
||||
if (version === summaryVersion) summaryBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取当前抽屉范围结果;同集结果同时更新顶部摘要。
|
||||
* @returns 当前结果读取结束
|
||||
*/
|
||||
async function loadResults() {
|
||||
const id = props.projectId
|
||||
const target = scope.value
|
||||
const version = ++resultsVersion
|
||||
resultsBusy.value = true
|
||||
resultsError.value = ''
|
||||
try {
|
||||
const data = await breakdownApi.legacyActionDiagnosisResults(
|
||||
id,
|
||||
target.kind === 'project' ? undefined : target.episodeNo
|
||||
)
|
||||
if (version !== resultsVersion) return
|
||||
results.value = data
|
||||
if (target.kind !== 'project' && target.episodeNo === props.episodeNo) {
|
||||
++summaryVersion
|
||||
summaryBusy.value = false
|
||||
summaryError.value = ''
|
||||
episodeResults.value = data
|
||||
}
|
||||
} catch (cause) {
|
||||
if (version === resultsVersion) resultsError.value = errorMessage(cause)
|
||||
} finally {
|
||||
if (version === resultsVersion) resultsBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 只读预览当前范围,全项目依照后端单集预览接口逐集汇总。 */
|
||||
async function loadPreview() {
|
||||
const id = props.projectId
|
||||
const target = scope.value
|
||||
const version = ++previewVersion
|
||||
previews.value = null
|
||||
previewBusy.value = true
|
||||
previewError.value = ''
|
||||
try {
|
||||
const episodes = target.kind === 'project' ? [...new Set(props.episodeNos)] : [target.episodeNo]
|
||||
if (!episodes.length) throw new Error('尚无可预览的剧集')
|
||||
const data = await Promise.all(
|
||||
episodes.map(episode =>
|
||||
breakdownApi.legacyActionDiagnosisPreview(
|
||||
id,
|
||||
episode,
|
||||
target.kind === 'beat' || target.kind === 'shot' ? target.beatNo : undefined,
|
||||
target.kind === 'shot' ? target.shotNo : undefined
|
||||
)
|
||||
)
|
||||
)
|
||||
if (version === previewVersion) previews.value = data
|
||||
} catch (cause) {
|
||||
if (version === previewVersion) previewError.value = errorMessage(cause)
|
||||
} finally {
|
||||
if (version === previewVersion) previewBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 读取全项目结构化证据;证据不足时不以零冲突暗示安全。 */
|
||||
async function loadHandDiagnostics() {
|
||||
const version = ++handVersion
|
||||
handBusy.value = true
|
||||
handError.value = ''
|
||||
handDiagnostics.value = null
|
||||
repairPreview.value = null
|
||||
repairIssue.value = null
|
||||
repairBusy.value = false
|
||||
try {
|
||||
const data = await breakdownApi.handOccupancyDiagnostics(props.projectId)
|
||||
if (version === handVersion) handDiagnostics.value = data
|
||||
} catch (cause) {
|
||||
if (version === handVersion) handError.value = errorMessage(cause)
|
||||
} finally {
|
||||
if (version === handVersion) handBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将只读修复候选放在对应问题下方,避免脱离问题单独罗列。
|
||||
* @param index 用户展开的问题序号
|
||||
* @returns 修复建议读取结束
|
||||
*/
|
||||
async function showRepair(index: number) {
|
||||
repairIssue.value = repairIssue.value === index ? null : index
|
||||
if (repairIssue.value === null || repairPreview.value || repairBusy.value) return
|
||||
const version = handVersion
|
||||
repairBusy.value = true
|
||||
try {
|
||||
const data = await breakdownApi.handRepairPreview(props.projectId)
|
||||
if (version === handVersion) repairPreview.value = data
|
||||
} catch (cause) {
|
||||
if (version === handVersion) message?.error(errorMessage(cause))
|
||||
} finally {
|
||||
if (version === handVersion) repairBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 筛选与当前结构化冲突相同镜头、阶段和角色的修复建议。
|
||||
* @param issue 当前结构化冲突
|
||||
* @returns 对应的人工修复候选
|
||||
*/
|
||||
function repairsFor(issue: StoryboardHandOccupancyDiagnostics['diagnostics'][number]) {
|
||||
return (
|
||||
repairPreview.value?.candidates.filter(
|
||||
item =>
|
||||
item.episodeNo === issue.episodeNo &&
|
||||
item.beatNo === issue.beatNo &&
|
||||
item.shotNo === issue.shotNo &&
|
||||
item.phaseNo === issue.phaseNo &&
|
||||
item.characterRef === issue.characterRef
|
||||
) ?? []
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅展示后端问题中明确提供的建议文本,不推断未知结构。
|
||||
* @param issues 后端诊断问题记录
|
||||
* @returns 可读的问题建议
|
||||
*/
|
||||
function issueDescriptions(issues: unknown[]) {
|
||||
return issues.flatMap(issue =>
|
||||
issue && typeof issue === 'object' && 'suggestion' in issue && typeof issue.suggestion === 'string'
|
||||
? [issue.suggestion]
|
||||
: []
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 从顶部或镜头入口打开抽屉;指定镜头时自动取得只读范围预览。
|
||||
* @param location 可选的节拍或镜头坐标
|
||||
*/
|
||||
function open(location?: DiagnosisLocation) {
|
||||
pendingLocation.value = null
|
||||
scope.value = location
|
||||
? location.shotNo === undefined
|
||||
? { kind: 'beat', episodeNo: location.episodeNo, beatNo: location.beatNo }
|
||||
: { kind: 'shot', ...location, shotNo: location.shotNo }
|
||||
: props.episodeNo === undefined
|
||||
? { kind: 'project' }
|
||||
: { kind: 'episode', episodeNo: props.episodeNo }
|
||||
drawerOpen.value = true
|
||||
if (location) void loadPreview()
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭抽屉后通知列表定位,保留当前任务观察。
|
||||
* @param location 待定位的镜头或节拍
|
||||
*/
|
||||
function locate(location: DiagnosisLocation) {
|
||||
pendingLocation.value = location
|
||||
drawerOpen.value = false
|
||||
}
|
||||
|
||||
/** 抽屉关闭动画结束后定位镜头,键盘焦点与正文高亮保持一致。 */
|
||||
function finishLocate() {
|
||||
if (!pendingLocation.value) return
|
||||
const location = pendingLocation.value
|
||||
pendingLocation.value = null
|
||||
emit('locate', location)
|
||||
}
|
||||
|
||||
/** 费用确认后提交固定范围,并保存后台任务句柄。 */
|
||||
async function startDiagnosis() {
|
||||
if (!canStart.value) return
|
||||
const id = props.projectId
|
||||
const input = diagnosisInput(scope.value, concurrency.value)
|
||||
starting.value = true
|
||||
try {
|
||||
const task = await breakdownApi.startLegacyActionDiagnosis(id, input)
|
||||
await execution.track(task.executionId, id)
|
||||
} catch (cause) {
|
||||
message?.error(errorMessage(cause))
|
||||
} finally {
|
||||
starting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 切换项目或当前剧集时清除旧范围,摘要读取只随上下文变化执行。 */
|
||||
watch(
|
||||
[() => props.projectId, () => props.episodeNo],
|
||||
() => {
|
||||
pendingLocation.value = null
|
||||
drawerOpen.value = false
|
||||
++handVersion
|
||||
handDiagnostics.value = null
|
||||
handBusy.value = false
|
||||
handError.value = ''
|
||||
void loadSummary()
|
||||
},
|
||||
{ immediate: true, flush: 'sync' }
|
||||
)
|
||||
/** 关闭或切换范围立即废弃预览及结果请求,禁止确认旧预览。 */
|
||||
watch(
|
||||
[drawerOpen, scopeKey],
|
||||
([shown]) => {
|
||||
++previewVersion
|
||||
++resultsVersion
|
||||
previews.value = null
|
||||
previewBusy.value = false
|
||||
previewError.value = ''
|
||||
results.value = null
|
||||
resultsBusy.value = false
|
||||
resultsError.value = ''
|
||||
resultFilter.value = 'attention'
|
||||
if (shown) {
|
||||
void loadResults()
|
||||
if (!handDiagnostics.value && !handBusy.value) void loadHandDiagnostics()
|
||||
} else {
|
||||
++handVersion
|
||||
handBusy.value = false
|
||||
repairBusy.value = false
|
||||
}
|
||||
},
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
/** 后台任务结束后更新摘要和已打开的结果,不因关闭抽屉停止跟踪。 */
|
||||
watch(
|
||||
() => execution.query.data.value?.status,
|
||||
(status, previous) => {
|
||||
if (status !== previous && (status === 'completed' || status === 'failed')) {
|
||||
void loadSummary()
|
||||
if (drawerOpen.value) void loadResults()
|
||||
}
|
||||
}
|
||||
)
|
||||
/** 离开分镜页面后所有在途只读响应失效。 */
|
||||
onScopeDispose(() => {
|
||||
++summaryVersion
|
||||
++resultsVersion
|
||||
++previewVersion
|
||||
++handVersion
|
||||
})
|
||||
/** 镜头入口只需要打开指定范围,不暴露组件内部状态。 */
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是紧凑的当前集诊断摘要模块,完整结果不挤占分镜正文 -->
|
||||
<div class="storyboard-diagnosis-summary" aria-live="polite">
|
||||
<div class="diagnosis-summary-text">
|
||||
<ScanLine :size="16" aria-hidden="true" />
|
||||
<span class="font-medium">动作诊断</span>
|
||||
<span class="text-muted"
|
||||
>{{ episodeNo === undefined ? '当前集' : `第 ${episodeNo} 集` }} · {{ summaryText }}</span
|
||||
>
|
||||
<NTag v-if="execution.active.value" type="info" size="small" :bordered="false">诊断中</NTag>
|
||||
</div>
|
||||
<NButton text :disabled="!projectId" aria-haspopup="dialog" :aria-expanded="drawerOpen" @click="open()"
|
||||
>查看诊断</NButton
|
||||
>
|
||||
</div>
|
||||
<!-- 以下是独立滚动的右侧诊断抽屉模块,手机自动使用全屏宽度 -->
|
||||
<NDrawer
|
||||
v-model:show="drawerOpen"
|
||||
placement="right"
|
||||
width="min(560px, 100vw)"
|
||||
class="storyboard-diagnosis-drawer"
|
||||
@after-leave="finishLocate"
|
||||
>
|
||||
<NDrawerContent title="动作诊断" closable :native-scrollbar="false">
|
||||
<p class="diagnosis-intro">检查手部动作占用与冲突,帮助定位需要处理的镜头。</p>
|
||||
<!-- 以下是当前范围模块,剧集编号始终与阅读列表一致 -->
|
||||
<section class="diagnosis-section">
|
||||
<h3>诊断范围</h3>
|
||||
<div class="diagnosis-scope-controls">
|
||||
<NButton
|
||||
size="small"
|
||||
:disabled="episodeNo === undefined"
|
||||
:type="scope.kind !== 'project' ? 'primary' : 'default'"
|
||||
@click="scope = { kind: 'episode', episodeNo: episodeNo! }"
|
||||
>当前集</NButton
|
||||
>
|
||||
<NButton
|
||||
size="small"
|
||||
:type="scope.kind === 'project' ? 'primary' : 'default'"
|
||||
@click="scope = { kind: 'project' }"
|
||||
>全项目</NButton
|
||||
>
|
||||
</div>
|
||||
<p class="diagnosis-scope-label">{{ scopeLabel }}</p>
|
||||
<p class="text-xs text-muted">当前支持手部动作冲突检查。</p>
|
||||
</section>
|
||||
<!-- 以下是诊断结果模块,默认隐藏未诊断长列表 -->
|
||||
<section class="diagnosis-section">
|
||||
<div class="diagnosis-section-heading">
|
||||
<h3>诊断结果</h3>
|
||||
<NButton text size="small" :loading="resultsBusy" @click="loadResults">刷新结果</NButton>
|
||||
</div>
|
||||
<p v-if="resultsError" class="text-danger" role="alert">{{ resultsError }}</p>
|
||||
<template v-else-if="results">
|
||||
<div class="diagnosis-counts">
|
||||
<span>范围内 {{ counts.total }} 镜</span
|
||||
><span :class="{ 'text-danger': counts.conflict }">冲突 {{ counts.conflict }}</span>
|
||||
<span>证据不足 {{ counts.insufficient }}</span
|
||||
><span>证据无效 {{ counts.invalid }}</span
|
||||
><span>已过期 {{ counts.stale }}</span> <span>未诊断 {{ counts.pending }}</span
|
||||
><span>未发现冲突 {{ counts.clear }}</span>
|
||||
</div>
|
||||
<NSelect
|
||||
v-model:value="resultFilter"
|
||||
aria-label="筛选诊断结果"
|
||||
size="small"
|
||||
class="diagnosis-result-filter"
|
||||
:options="[
|
||||
{ label: '需处理:冲突、证据异常与过期', value: 'attention' },
|
||||
{ label: `未诊断(${counts.pending})`, value: 'pending' },
|
||||
{ label: `全部镜头(${counts.total})`, value: 'all' }
|
||||
]"
|
||||
/>
|
||||
<div v-if="!visibleShots.length" class="diagnosis-empty">
|
||||
<p>
|
||||
{{
|
||||
counts.total === 0
|
||||
? '当前范围尚无镜头。'
|
||||
: counts.pending === counts.total
|
||||
? `${counts.pending} 个镜头尚未诊断,暂无法判断冲突情况。`
|
||||
: resultFilter === 'attention'
|
||||
? '当前没有需处理的诊断记录。'
|
||||
: '当前筛选下没有镜头。'
|
||||
}}
|
||||
</p>
|
||||
<NButton
|
||||
v-if="counts.pending && resultFilter !== 'pending'"
|
||||
text
|
||||
size="small"
|
||||
@click="resultFilter = 'pending'"
|
||||
>查看未诊断镜头</NButton
|
||||
>
|
||||
</div>
|
||||
<NScrollbar
|
||||
v-if="visibleShots.length"
|
||||
class="diagnosis-result-list"
|
||||
tabindex="0"
|
||||
aria-label="镜头诊断列表"
|
||||
>
|
||||
<article v-for="item in visibleShots" :key="item.shotId" class="diagnosis-result-item">
|
||||
<div class="diagnosis-section-heading">
|
||||
<span class="text-xs text-muted"
|
||||
>第 {{ item.episodeNo }} 集 / 节拍 {{ item.beatNo }} / 镜头 {{ item.shotNo }}</span
|
||||
>
|
||||
<NTag
|
||||
:type="
|
||||
item.status === 'conflict_found'
|
||||
? 'error'
|
||||
: item.status === 'no_conflict_found'
|
||||
? 'success'
|
||||
: 'default'
|
||||
"
|
||||
size="small"
|
||||
:bordered="false"
|
||||
>{{ diagnosisStatusLabels[item.status] }}</NTag
|
||||
>
|
||||
</div>
|
||||
<p class="font-medium">{{ item.title }}</p>
|
||||
<p
|
||||
v-for="(description, index) in issueDescriptions(item.issues)"
|
||||
:key="index"
|
||||
class="text-muted"
|
||||
>
|
||||
{{ description }}
|
||||
</p>
|
||||
<NButton text size="small" @click="locate(item)">定位镜头</NButton>
|
||||
</article>
|
||||
</NScrollbar>
|
||||
</template>
|
||||
<p v-else class="text-muted">{{ resultsBusy ? '正在读取当前范围结果…' : '尚未读取结果' }}</p>
|
||||
</section>
|
||||
<!-- 以下是使用 Naive UI 折叠组件的全项目结构化校验模块,默认收起 -->
|
||||
<section class="diagnosis-section">
|
||||
<NCollapse>
|
||||
<NCollapseItem name="hand-diagnostics">
|
||||
<template #header>
|
||||
<span class="diagnosis-evidence-title">结构化动作校验</span>
|
||||
<span class="ml-2 text-xs text-muted">全项目</span>
|
||||
</template>
|
||||
<div class="diagnosis-section-heading">
|
||||
<span class="text-xs text-muted">直接读取已有动作证据,不调用模型</span>
|
||||
<NButton text size="small" :loading="handBusy" @click="loadHandDiagnostics"
|
||||
>刷新校验</NButton
|
||||
>
|
||||
</div>
|
||||
<p v-if="handError" class="text-danger" role="alert">{{ handError }}</p>
|
||||
<template v-else-if="handDiagnostics">
|
||||
<p class="mt-2">
|
||||
有效动作证据 {{ handDiagnostics.evidenceShotCount }} /
|
||||
{{ handDiagnostics.shotCount }} 镜
|
||||
</p>
|
||||
<p class="text-muted">
|
||||
{{
|
||||
handDiagnostics.assessment === 'no_shots'
|
||||
? '全项目尚无镜头。'
|
||||
: handDiagnostics.assessment === 'insufficient_evidence'
|
||||
? '证据不足,暂无法判断冲突情况。'
|
||||
: handDiagnostics.assessment === 'partial_evidence'
|
||||
? `部分镜头缺少有效证据;现有证据发现 ${handDiagnostics.warningCount} 项冲突。`
|
||||
: `现有证据发现 ${handDiagnostics.warningCount} 项冲突。`
|
||||
}}
|
||||
</p>
|
||||
<article
|
||||
v-for="(issue, index) in handDiagnostics.diagnostics"
|
||||
:key="index"
|
||||
class="diagnosis-result-item"
|
||||
>
|
||||
<p class="text-xs text-muted">
|
||||
第 {{ issue.episodeNo }} 集 / 节拍 {{ issue.beatNo }} / 镜头 {{ issue.shotNo }} /
|
||||
阶段
|
||||
{{ issue.phaseNo }}
|
||||
</p>
|
||||
<p>{{ issue.suggestion }}</p>
|
||||
<div class="diagnosis-scope-controls">
|
||||
<NButton text size="small" @click="locate(issue)">定位镜头</NButton>
|
||||
<NButton
|
||||
text
|
||||
size="small"
|
||||
:loading="repairBusy && repairIssue === index"
|
||||
@click="showRepair(index)"
|
||||
>{{ repairIssue === index ? '收起修复建议' : '查看修复建议' }}</NButton
|
||||
>
|
||||
</div>
|
||||
<div v-if="repairIssue === index && repairPreview" class="diagnosis-repair">
|
||||
<div v-for="(repair, repairIndex) in repairsFor(issue)" :key="repairIndex">
|
||||
<p>{{ repair.suggestion }}</p>
|
||||
<p v-if="repair.blockingReasons.length" class="text-xs text-muted">
|
||||
{{ repair.blockingReasons.join(';') }}
|
||||
</p>
|
||||
</div>
|
||||
<p v-if="!repairsFor(issue).length" class="text-muted">当前没有可用修复建议。</p>
|
||||
</div>
|
||||
</article>
|
||||
</template>
|
||||
<p v-else class="text-muted">{{ handBusy ? '正在读取全项目校验…' : '尚未读取校验' }}</p>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
</section>
|
||||
<!-- 以下是统一的 AI 诊断启动模块,预览和费用确认集中展示 -->
|
||||
<section class="diagnosis-section">
|
||||
<h3>启动 AI 诊断</h3>
|
||||
<p class="text-muted mt-2">{{ scopeLabel }} · 已有当前版本有效结果的镜头将跳过。</p>
|
||||
<!-- 以下是使用 Naive UI 折叠组件的高级设置模块,默认收起 -->
|
||||
<NCollapse class="diagnosis-advanced">
|
||||
<NCollapseItem name="advanced-settings">
|
||||
<template #header><span class="text-xs text-muted">高级设置</span></template>
|
||||
<label class="diagnosis-concurrency"
|
||||
><span>任务并发</span
|
||||
><NInputNumber
|
||||
v-model:value="concurrency"
|
||||
aria-label="诊断任务并发"
|
||||
:min="1"
|
||||
:max="5"
|
||||
:precision="0"
|
||||
size="small"
|
||||
/></label>
|
||||
</NCollapseItem>
|
||||
</NCollapse>
|
||||
<div v-if="previews" class="diagnosis-preview" aria-live="polite">
|
||||
<p>{{ scopeLabel }} · 范围内 {{ previewCount }} 个镜头</p>
|
||||
<p class="text-xs text-muted">
|
||||
缺少结构化动作证据 {{ previews.reduce((sum, item) => sum + item.needsEvidenceCount, 0) }} 镜 ·
|
||||
快照无效 {{ previews.reduce((sum, item) => sum + item.invalidSnapshotCount, 0) }} 镜
|
||||
</p>
|
||||
</div>
|
||||
<p v-if="previewError" class="text-danger" role="alert">{{ previewError }}</p>
|
||||
<p class="text-xs text-muted mt-3">AI 诊断会产生模型费用,仅保存诊断记录,不修改镜头。</p>
|
||||
<div class="diagnosis-start-actions">
|
||||
<NButton
|
||||
:loading="previewBusy"
|
||||
:disabled="previewBusy || starting || execution.active.value"
|
||||
@click="loadPreview"
|
||||
>{{ previews ? '重新预览范围' : '预览诊断范围' }}</NButton
|
||||
>
|
||||
<ConfirmAction
|
||||
label="启动 AI 诊断"
|
||||
:description="confirmation"
|
||||
primary
|
||||
:disabled="!canStart"
|
||||
:loading="starting"
|
||||
@confirm="startDiagnosis"
|
||||
/>
|
||||
</div>
|
||||
<p v-if="execution.active.value" class="text-xs text-muted mt-3">
|
||||
诊断任务进行中,可关闭抽屉继续查看分镜。
|
||||
</p>
|
||||
</section>
|
||||
<!-- 以下是持久化诊断任务进度模块,刷新页面后仍可恢复 -->
|
||||
<WorkflowExecutionPanel
|
||||
v-if="execution.executionId.value"
|
||||
title="动作诊断任务"
|
||||
:execution="execution.query.data.value ?? null"
|
||||
:loading="execution.query.loading.value"
|
||||
:error="execution.query.error.value ?? ''"
|
||||
@refresh="execution.query.refresh()"
|
||||
@dismiss="execution.dismiss()"
|
||||
/>
|
||||
</NDrawerContent>
|
||||
</NDrawer>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
@reference "../../../styles/styles.css";
|
||||
/* 摘要保持一行信息密度,窄屏允许自然换行,入口始终可见。 */
|
||||
.storyboard-diagnosis-summary {
|
||||
@apply flex items-center justify-between gap-3 py-2.5 px-3 mb-5 bg-(--app-subtle) text-xs;
|
||||
}
|
||||
.diagnosis-summary-text {
|
||||
@apply flex min-w-0 items-center flex-wrap gap-x-2 gap-y-1;
|
||||
}
|
||||
.storyboard-diagnosis-summary > .n-button {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
/* 抽屉分区依靠留白和细线区分,避免再堆叠大面积面板。 */
|
||||
.storyboard-diagnosis-drawer .n-drawer-body-content-wrapper {
|
||||
padding: 20px 24px 32px;
|
||||
}
|
||||
.storyboard-diagnosis-drawer .n-drawer-header {
|
||||
padding: 20px 24px;
|
||||
}
|
||||
.diagnosis-intro {
|
||||
@apply text-sm text-muted leading-6;
|
||||
}
|
||||
.diagnosis-section {
|
||||
@apply py-5 border-b border-(--app-border) text-sm leading-6;
|
||||
}
|
||||
.diagnosis-section h3,
|
||||
.diagnosis-evidence-title {
|
||||
@apply font-semibold text-sm;
|
||||
}
|
||||
.diagnosis-section-heading {
|
||||
@apply flex items-center justify-between gap-3;
|
||||
}
|
||||
.diagnosis-scope-controls {
|
||||
@apply flex flex-wrap items-center gap-2 mt-3;
|
||||
}
|
||||
.diagnosis-scope-label {
|
||||
@apply mt-3 font-medium;
|
||||
}
|
||||
.diagnosis-counts {
|
||||
@apply flex flex-wrap gap-x-4 gap-y-1 mt-3 mb-4 text-xs text-muted;
|
||||
}
|
||||
/* 长结果列表独立滚动,避免把范围预览和启动操作推到列表末尾。 */
|
||||
.diagnosis-result-list {
|
||||
max-height: min(40dvh, 360px);
|
||||
}
|
||||
.diagnosis-result-filter {
|
||||
@apply mb-3;
|
||||
}
|
||||
.diagnosis-empty {
|
||||
@apply py-4 text-muted;
|
||||
}
|
||||
.diagnosis-result-item {
|
||||
@apply py-4 border-t border-(--app-border) space-y-2;
|
||||
}
|
||||
.diagnosis-result-item .n-tag {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.diagnosis-advanced {
|
||||
@apply mt-3 text-xs text-muted;
|
||||
}
|
||||
.diagnosis-concurrency {
|
||||
@apply flex items-center gap-3;
|
||||
}
|
||||
.diagnosis-concurrency .n-input-number {
|
||||
@apply w-28;
|
||||
}
|
||||
.diagnosis-preview,
|
||||
.diagnosis-repair {
|
||||
@apply bg-(--app-subtle) p-3 mt-3;
|
||||
}
|
||||
.diagnosis-start-actions {
|
||||
@apply flex flex-wrap justify-end gap-3 mt-4;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.n-drawer.storyboard-diagnosis-drawer {
|
||||
width: 100vw !important;
|
||||
}
|
||||
.storyboard-diagnosis-drawer .n-drawer-body-content-wrapper {
|
||||
padding: 16px 16px 28px;
|
||||
}
|
||||
.storyboard-diagnosis-drawer .n-drawer-header {
|
||||
padding: 16px;
|
||||
}
|
||||
.storyboard-diagnosis-summary {
|
||||
@apply items-start;
|
||||
}
|
||||
.diagnosis-summary-text > .text-muted {
|
||||
@apply basis-full;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -2,19 +2,32 @@
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
|
||||
import { NButton, NSelect, NTag } from 'naive-ui'
|
||||
import { computed, ref } from 'vue'
|
||||
import { computed, nextTick, ref } from 'vue'
|
||||
import { Clock3 } from '@lucide/vue'
|
||||
import { EmptyState } from '../../../components/ui'
|
||||
import type { EpisodePlan, EpisodeShots } from '../types'
|
||||
import type { DiagnosisLocation } from '../diagnosis'
|
||||
|
||||
/** Episode → Beat → Shot 的分层查看,不提前加入下一条 graph 的导演字段。 */
|
||||
const props = defineProps<{ plans: EpisodePlan[]; episodes: EpisodeShots[] }>()
|
||||
const props = defineProps<{
|
||||
/** 正式分集节拍规划。 */
|
||||
plans: EpisodePlan[]
|
||||
/** 正式分集镜头。 */
|
||||
episodes: EpisodeShots[]
|
||||
}>()
|
||||
/** 分镜卡片只负责发出诊断定位,确认及模型任务交由页面处理。 */
|
||||
const emit = defineEmits<{ diagnose: [scope: { episodeNo: number; beatNo: number; shotNo?: number }] }>()
|
||||
const selected = ref<number>()
|
||||
const emit = defineEmits<{ diagnose: [scope: DiagnosisLocation] }>()
|
||||
/** 阅读与诊断共用的当前剧集编号。 */
|
||||
const selected = defineModel<number>('episodeNo')
|
||||
/** 分镜正文根节点,用于定位问题镜头。 */
|
||||
const root = ref<HTMLElement | null>(null)
|
||||
/** 最近定位的镜头或节拍标识,用于保留可见高亮。 */
|
||||
const locatedPosition = ref('')
|
||||
/** 兼容只有正式镜头而没有单独规划的历史结果。 */
|
||||
const plans = computed(() => (props.plans.length ? props.plans : props.episodes.map(item => item.episodePlan)))
|
||||
/** 选择器与正文统一使用最终规划编号;初次读取或当前剧集被移除时回退到第一集。 */
|
||||
const plan = computed(() => plans.value.find(item => item.episodeNo === selected.value) ?? plans.value[0])
|
||||
/** 当前剧集对应的正式镜头。 */
|
||||
const episode = computed(() => props.episodes.find(item => item.episodeNo === plan.value?.episodeNo))
|
||||
const purposeLabels: Record<string, string> = {
|
||||
establish: '建立场景',
|
||||
@@ -28,10 +41,31 @@ const purposeLabels: Record<string, string> = {
|
||||
resolution: '收束',
|
||||
hook: '钩子'
|
||||
}
|
||||
/**
|
||||
* 切换剧集并定位问题镜头,尊重系统减少动画设置。
|
||||
* @param location 问题所在的正式剧集、节拍与镜头坐标
|
||||
* @returns 列表更新并完成定位
|
||||
*/
|
||||
async function locate(location: DiagnosisLocation) {
|
||||
selected.value = location.episodeNo
|
||||
await nextTick()
|
||||
const position = `${location.episodeNo}-${location.beatNo}${location.shotNo === undefined ? '' : `-${location.shotNo}`}`
|
||||
const element = root.value?.querySelector<HTMLElement>(`[data-shot-position="${position}"]`)
|
||||
if (!element) return
|
||||
locatedPosition.value = position
|
||||
element.focus({ preventScroll: true })
|
||||
element.scrollIntoView({
|
||||
block: 'center',
|
||||
behavior: window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth'
|
||||
})
|
||||
}
|
||||
/** 仅暴露诊断问题定位能力。 */
|
||||
defineExpose({ locate })
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="breakdown-storyboard">
|
||||
<div ref="root" class="breakdown-storyboard">
|
||||
<!-- 以下是分镜剧集选择与工作区入口模块 -->
|
||||
<div v-if="plan || $slots.actions" class="breakdown-storyboard-toolbar">
|
||||
<label v-if="plan" class="breakdown-episode-picker"
|
||||
><span>选择剧集</span
|
||||
@@ -55,6 +89,9 @@ const purposeLabels: Record<string, string> = {
|
||||
<slot name="actions" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- 以下是当前集诊断摘要插槽,完整结果在右侧抽屉展示 -->
|
||||
<slot name="diagnosis" />
|
||||
<!-- 以下是当前集节拍与分镜正文模块 -->
|
||||
<template v-if="plan">
|
||||
<div v-if="plan.storyGoal || plan.emotionalArc" class="mb-7 surface-inset p-4">
|
||||
<p v-if="plan.storyGoal" class="font-medium">{{ plan.storyGoal }}</p>
|
||||
@@ -65,12 +102,27 @@ const purposeLabels: Record<string, string> = {
|
||||
<ContextNotice v-if="!episode" type="info" :show-icon="false" class="mb-5">
|
||||
本集已完成节拍规划,镜头尚未生成。请等待进度更新,或在确认中断后使用“补齐缺失镜头”。
|
||||
</ContextNotice>
|
||||
<section v-for="beat in plan.beats" :key="beat.beatNo" class="beat-section">
|
||||
<section
|
||||
v-for="beat in plan.beats"
|
||||
:key="beat.beatNo"
|
||||
class="beat-section"
|
||||
tabindex="-1"
|
||||
:data-shot-position="`${plan.episodeNo}-${beat.beatNo}`"
|
||||
:class="{ 'diagnosis-located': locatedPosition === `${plan.episodeNo}-${beat.beatNo}` }"
|
||||
>
|
||||
<div class="beat-heading">
|
||||
<span class="beat-number">{{ String(beat.beatNo).padStart(2, '0') }}</span>
|
||||
<h3 class="text-sm font-semibold">{{ beat.title }}</h3>
|
||||
<NTag size="small" :bordered="false">{{ purposeLabels[beat.purpose] || beat.purpose }}</NTag>
|
||||
<NButton v-if="plan" size="tiny" text class="diagnose-hover-action ml-auto" aria-label="诊断当前节拍" @click="emit('diagnose', { episodeNo: plan.episodeNo, beatNo: beat.beatNo })">AI 诊断</NButton>
|
||||
<NButton
|
||||
v-if="plan"
|
||||
size="tiny"
|
||||
text
|
||||
class="diagnose-hover-action ml-auto"
|
||||
aria-label="诊断当前节拍"
|
||||
@click="emit('diagnose', { episodeNo: plan.episodeNo, beatNo: beat.beatNo })"
|
||||
>AI 诊断</NButton
|
||||
>
|
||||
</div>
|
||||
<p class="mb-4 mt-3 text-sm leading-6 text-muted">{{ beat.description }}</p>
|
||||
<div class="space-y-3">
|
||||
@@ -78,6 +130,11 @@ const purposeLabels: Record<string, string> = {
|
||||
v-for="shot in episode?.beatShots.find(item => item.beatNo === beat.beatNo)?.shots ?? []"
|
||||
:key="shot.shotNo"
|
||||
class="shot-row group"
|
||||
tabindex="-1"
|
||||
:data-shot-position="`${plan.episodeNo}-${beat.beatNo}-${shot.shotNo}`"
|
||||
:class="{
|
||||
'diagnosis-located': locatedPosition === `${plan.episodeNo}-${beat.beatNo}-${shot.shotNo}`
|
||||
}"
|
||||
>
|
||||
<div class="shot-label">
|
||||
镜头 {{ String(shot.shotNo).padStart(2, '0')
|
||||
@@ -86,8 +143,23 @@ const purposeLabels: Record<string, string> = {
|
||||
>
|
||||
</div>
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="flex items-center justify-between gap-3"><h4 class="text-sm font-medium">{{ shot.title }}</h4>
|
||||
<NButton v-if="plan" size="tiny" text class="diagnose-hover-action" aria-label="诊断当前镜头" @click="emit('diagnose', { episodeNo: plan.episodeNo, beatNo: beat.beatNo, shotNo: shot.shotNo })">AI 诊断</NButton>
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<h4 class="text-sm font-medium">{{ shot.title }}</h4>
|
||||
<NButton
|
||||
v-if="plan"
|
||||
size="tiny"
|
||||
text
|
||||
class="diagnose-hover-action"
|
||||
aria-label="诊断当前镜头"
|
||||
@click="
|
||||
emit('diagnose', {
|
||||
episodeNo: plan.episodeNo,
|
||||
beatNo: beat.beatNo,
|
||||
shotNo: shot.shotNo
|
||||
})
|
||||
"
|
||||
>AI 诊断</NButton
|
||||
>
|
||||
</div>
|
||||
<p class="mt-2 text-sm leading-7">{{ shot.description }}</p>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">视觉重点 · {{ shot.visualFocus }}</p>
|
||||
@@ -117,6 +189,11 @@ const purposeLabels: Record<string, string> = {
|
||||
<style>
|
||||
/* 本组件专属布局与 Naive 内部结构覆盖。 */
|
||||
@reference "../../../styles/styles.css";
|
||||
/* 问题定位保留轮廓提示,便于关闭抽屉后识别目标。 */
|
||||
.diagnosis-located {
|
||||
outline: 1px solid var(--app-accent);
|
||||
outline-offset: 3px;
|
||||
}
|
||||
.beat-section {
|
||||
@apply mt-[25px] pt-[23px];
|
||||
}
|
||||
@@ -136,7 +213,10 @@ const purposeLabels: Record<string, string> = {
|
||||
pointer-events: auto;
|
||||
}
|
||||
@media (hover: none) {
|
||||
.diagnose-hover-action { opacity: 1; pointer-events: auto; }
|
||||
.diagnose-hover-action {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
}
|
||||
.beat-number {
|
||||
@apply text-muted font-mono text-[11px];
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
import type { LegacyActionDiagnosisResults } from './types'
|
||||
|
||||
/** 诊断及定位共用的镜头坐标。 */
|
||||
export interface DiagnosisLocation {
|
||||
/** 正式剧集编号。 */
|
||||
episodeNo: number
|
||||
/** 集内节拍编号。 */
|
||||
beatNo: number
|
||||
/** 节拍内镜头编号;省略时表示整个节拍。 */
|
||||
shotNo?: number
|
||||
}
|
||||
|
||||
/** 诊断范围按层级约束,避免全项目请求遗留镜头条件。 */
|
||||
export type DiagnosisScope =
|
||||
| { /** 全项目范围。 */ kind: 'project' }
|
||||
| { /** 单集范围。 */ kind: 'episode'; /** 正式集号。 */ episodeNo: number }
|
||||
| ({ /** 单节拍范围。 */ kind: 'beat' } & Omit<DiagnosisLocation, 'shotNo'>)
|
||||
| ({ /** 单镜头范围,必须包含镜头编号。 */ kind: 'shot' } & Required<DiagnosisLocation>)
|
||||
|
||||
/**
|
||||
* 从后端整集或全项目结果中取得当前诊断范围。
|
||||
* @param shots 后端镜头诊断记录
|
||||
* @param scope 当前诊断范围
|
||||
* @returns 当前范围内的镜头记录
|
||||
*/
|
||||
export function scopeDiagnosisShots(shots: LegacyActionDiagnosisResults['shots'], scope: DiagnosisScope) {
|
||||
return shots.filter(
|
||||
shot =>
|
||||
scope.kind === 'project' ||
|
||||
(shot.episodeNo === scope.episodeNo &&
|
||||
(scope.kind === 'episode' ||
|
||||
(shot.beatNo === scope.beatNo && (scope.kind === 'beat' || shot.shotNo === scope.shotNo))))
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 按镜头真实诊断状态重新统计,缺少证据不能算作检查通过。
|
||||
* @param shots 当前范围镜头记录
|
||||
* @returns 各状态镜头数量
|
||||
*/
|
||||
export function summarizeDiagnosis(shots: LegacyActionDiagnosisResults['shots']) {
|
||||
const counts = { total: shots.length, conflict: 0, clear: 0, insufficient: 0, invalid: 0, stale: 0, pending: 0 }
|
||||
for (const shot of shots) counts[diagnosisCountKeys[shot.status]]++
|
||||
return counts
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成与已确认范围一致的批量诊断请求。
|
||||
* @param scope 已预览的诊断范围
|
||||
* @param concurrency 模型任务并发数
|
||||
* @returns 后端批量诊断请求参数
|
||||
*/
|
||||
export function diagnosisInput(scope: DiagnosisScope, concurrency: number) {
|
||||
return {
|
||||
confirmed: true as const,
|
||||
concurrency,
|
||||
...(scope.kind !== 'project' ? { episodeNo: scope.episodeNo } : {}),
|
||||
...(scope.kind === 'beat' || scope.kind === 'shot' ? { beatNo: scope.beatNo } : {}),
|
||||
...(scope.kind === 'shot' ? { shotNo: scope.shotNo } : {})
|
||||
}
|
||||
}
|
||||
|
||||
/** 后端诊断状态对应的统计字段。 */
|
||||
const diagnosisCountKeys = {
|
||||
conflict_found: 'conflict',
|
||||
no_conflict_found: 'clear',
|
||||
insufficient_evidence: 'insufficient',
|
||||
invalid_evidence: 'invalid',
|
||||
stale: 'stale',
|
||||
not_diagnosed: 'pending'
|
||||
} as const
|
||||
|
||||
/** 状态始终保留文字,避免仅通过颜色区分问题。 */
|
||||
export const diagnosisStatusLabels = {
|
||||
conflict_found: '手部冲突',
|
||||
no_conflict_found: '未发现冲突',
|
||||
insufficient_evidence: '证据不足',
|
||||
invalid_evidence: '证据无效',
|
||||
stale: '诊断过期',
|
||||
not_diagnosed: '尚未诊断'
|
||||
} as const
|
||||
@@ -269,7 +269,13 @@ export interface LegacyActionDiagnosisResults {
|
||||
shotNo: number
|
||||
title: string
|
||||
diagnosisId: string | null
|
||||
status: 'not_diagnosed' | 'stale' | 'conflict_found' | 'no_conflict_found' | 'insufficient_evidence' | 'invalid_evidence'
|
||||
status:
|
||||
| 'not_diagnosed'
|
||||
| 'stale'
|
||||
| 'conflict_found'
|
||||
| 'no_conflict_found'
|
||||
| 'insufficient_evidence'
|
||||
| 'invalid_evidence'
|
||||
issues: unknown[]
|
||||
createdAt: string | null
|
||||
}>
|
||||
|
||||
Reference in new issue
Block a user