Files
short-drama-agent-front/src/features/breakdown/BreakdownPage.vue
T

1489 lines
74 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import AppForm from '../../components/ui/AppForm.vue'
import { NFormItem } from 'naive-ui'
import { integerRule, fieldRule } from '../../lib/form-rules'
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
import WorkspaceExportButton from '../../components/ui/WorkspaceExportButton.vue'
import WorkspaceActionTooltip from '../../components/ui/WorkspaceActionTooltip.vue'
import { NScrollbar, NButton, NCheckbox, NCollapse, NCollapseItem, NInputNumber, NTab, NTable, NTabs } from 'naive-ui'
import { computed, h, nextTick, onScopeDispose, ref, watch } from 'vue'
import { useActionMessage } from '../../components/ui/useActionMessage'
import { CircleAlert, Layers, LoaderCircle, Settings2, ShieldCheck } from '@lucide/vue'
import { AppDialog, EmptyState, StatusBadge, WorkspaceTools } from '../../components/ui'
import QualityPolicySettings from '../generation-config/components/QualityPolicySettings.vue'
import { useProjectContext } from '../projects/context'
import { breakdownApi } from './api'
import type { BreakdownAction, BreakdownInput, BreakdownModule, BreakdownPreview, ShotValidation } from './types'
import { breakdownSnapshot, recoveryOptions, workflowCheckpoints } from '../workflows/selectors'
import { getOperation, isOperationRunning, runOperation } from '../workflows/operations'
import ConfirmAction from '../workflows/ConfirmAction.vue'
import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
import { executionStageLabel, useWorkflowExecution } from '../workflows/execution'
import SubjectList from './components/SubjectList.vue'
import StoryboardList from './components/StoryboardList.vue'
import StoryboardDiagnosis from './components/StoryboardDiagnosis.vue'
import BreakdownCandidatePanel from './components/BreakdownCandidatePanel.vue'
import StoryboardQualityRepair from './components/StoryboardQualityRepair.vue'
import BreakdownDurationDiagnostics from './components/BreakdownDurationDiagnostics.vue'
import BreakdownIssuesDialog from './components/BreakdownIssuesDialog.vue'
import CandidateRepairs from './components/CandidateRepairs.vue'
import ActionExceptionRepair from './components/ActionExceptionRepair.vue'
import { useBreakdownQuality } from './useBreakdownQuality'
import { useBreakdownStartPolicy } from './useBreakdownStartPolicy'
import type { DiagnosisLocation } from './diagnosis'
import { ApiError, errorMessage } from '../../lib/http'
import { downloadText } from '../../lib/format'
/** 拆解工作区:先预览真实分组,再启动;恢复操作根据 checkpoint 分阶段展示。 */
const { project, checkpoints, refresh, refreshStageReadiness, stageReadiness, error } = useProjectContext()
const groupSize = ref(3)
const modules = ref<BreakdownModule[]>(['character', 'scene', 'prop'])
const preview = ref<BreakdownPreview | null>(null)
const previewBusy = ref(false)
/** 默认只生成候选,正式替换需单独确认。 */
const candidateOnly = ref(true)
const tab = ref('character')
const toolsOpen = ref(false)
/** 问题查看、人工修订和阶段恢复共用独立窗口。 */
const issuesOpen = ref(false)
/** 动作例外真实写入期间锁定问题抽屉的关闭,普通查询不锁定。 */
const exceptionSaving = ref(false)
/** 从设置切换时等待关闭动画结束,避免两层弹窗同时显示。 */
const pendingIssues = ref(false)
/** 候选安全预检与关系修复使用独立抽屉,不与拆解设置叠加。 */
const candidateSafetyOpen = ref(false)
/** 从设置交接时绑定项目,离场后禁止打开旧项目预检。 */
const pendingSafetyProject = ref('')
/** 问题入口统一使用红色文字、图标和柔和底色,交互时保持错误语义。 */
const issueButtonTheme = {
color: 'var(--app-danger-soft)',
colorHover: 'color-mix(in srgb, var(--app-danger-soft), var(--app-danger) 8%)',
colorPressed: 'color-mix(in srgb, var(--app-danger-soft), var(--app-danger) 14%)',
colorFocus: 'var(--app-danger-soft)',
textColor: 'var(--app-danger)',
textColorHover: 'var(--app-danger)',
textColorPressed: 'var(--app-danger)',
textColorFocus: 'var(--app-danger)'
}
const moduleOptions: { value: BreakdownModule; label: string; description: string }[] = [
{ value: 'character', label: '人物', description: '人物身份、外观与形态' },
{ value: 'scene', label: '场景', description: '故事空间与环境特征' },
{ value: 'prop', label: '道具', description: '关键物件与视觉描述' }
]
const records = computed(() => workflowCheckpoints(checkpoints.value, 'breakdown'))
/** 提交候选只读取最新原始记录,避免从旧快照恢复提交资格。 */
const latestCheckpoint = computed(() => records.value.at(-1))
/** 有旧结果后统一采用候选模式,不再从设置入口直接覆盖。 */
watch(
() => records.value.length,
count => {
if (count > 0) candidateOnly.value = true
},
{ immediate: true }
)
/** 当前项目用于候选审核及所有版本化写操作。 */
const projectId = computed(() => project.value?.id ?? '')
/** 候选、正式和历史来源及质量状态统一选择。 */
const qualityObservation = useBreakdownQuality(projectId, checkpoints)
/** 当前质量结论不使用历史嵌套错误,也不作为正式提交许可。 */
const quality = qualityObservation.quality
/** 仅结果展示可回看历史,历史质量不进入当前审核。 */
const snapshot = computed(() => qualityObservation.source.value.state ?? breakdownSnapshot(checkpoints.value))
/** 当前同版本归一化成果,顶层修复优先。 */
const result = computed(() => snapshot.value)
const subjects = computed(() => result.value?.subjectCandidates ?? [])
const forms = computed(() => result.value?.subjectForms ?? [])
const plans = computed(() => result.value?.storyboardPlans ?? [])
const shots = computed(() => result.value?.storyboardEpisodeShots ?? [])
/** 主体、分镜及任务记录构成已有结果,搜索筛选不影响是否存在数据。 */
const hasBreakdownResults = computed(
() => !!(subjects.value.length || plans.value.length || shots.value.length || snapshot.value?.tasks?.length)
)
const summary = computed(() => snapshot.value?.taskSummary)
/** 候选审核读取完成前不展示旧错误。 */
const validation = computed(() =>
quality.value.structureValid === null
? undefined
: { valid: quality.value.structureValid, issues: quality.value.structuralIssues }
)
/** 数据来源在桌面和移动端正文均明确显示,候选数量不冒充正式资产。 */
const sourceLabel = computed(
() =>
({
candidate: '拆解候选 · 尚未提交正式结果',
formal: '正式拆解结果',
history: '历史结果 · 仅供回看',
empty: ''
})[quality.value.source]
)
/** 从当前正式版本逐镜汇总,不沿用历史执行进度或候选统计。 */
const formalStoryboardSummary = computed(() => {
if (quality.value.source !== 'formal' || !quality.value.committed || !shots.value.length) return ''
const allShots = shots.value.flatMap(episode => episode.beatShots.flatMap(beat => beat.shots))
const bindingSummary = allShots.some(shot => shot.subjectRefs.length && !shot.subjectBindings)
? '绑定数量待确认'
: `${allShots.reduce((total, shot) => total + (shot.subjectBindings?.length ?? 0), 0)} 条绑定`
return `${shots.value.length} 集 · ${allShots.length} 镜 · ${bindingSummary}`
})
const operation = computed(() => getOperation(projectId.value))
/** 分镜阅读和诊断入口共用当前剧集,不维护独立的诊断集号输入。 */
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
})
/** 项目预览涵盖正式剧集与已有分镜剧集,不遗漏已有分镜。 */
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) {
if (quality.value.source !== 'formal' || breakdownBusy.value || backgroundExecution.discovering.value) return
diagnosisPanel.value?.open(location)
}
/**
* 诊断列表定位到分镜正文,只有实际问题才使用错误提示。
* @param location 待定位的分镜坐标
* @param problem 当前镜头是否有明确问题
*/
function locateDiagnosisShot(location: DiagnosisLocation, problem = false) {
void storyboardList.value?.locate(location, { problem })
}
const backgroundExecution = useWorkflowExecution(projectId, 'breakdown')
const recovery = computed(() => recoveryOptions(checkpoints.value))
/** 运行状态优先采用持久化任务;历史快照只作没有任务记录时的兼容来源。 */
const execution = computed(() => {
const record = backgroundExecution.query.data.value
return record
? {
executionId: record.id,
status: record.status === 'pending' ? ('running' as const) : record.status,
errorMessage: record.error ?? undefined,
startedAt: record.startedAt ?? record.createdAt,
completedAt: record.completedAt ?? undefined
}
: latestCheckpoint.value?.state.workflowExecution
})
/** 终态早于当前结果时归入历史,正式采用可以在原检查点上更新。 */
const executionHistorical = computed(() => {
const task = execution.value
const source = qualityObservation.source.value
const checkpoint = source.checkpoint
if (!task || task.status === 'running' || !checkpoint) return false
const record = backgroundExecution.query.data.value
const finishedAt = Date.parse(task.completedAt ?? record?.updatedAt ?? '')
const adoptedAt = quality.value.committed ? Date.parse(checkpoint.updatedAt ?? '') : NaN
const resultAt = Number.isFinite(adoptedAt) ? adoptedAt : Date.parse(checkpoint.createdAt)
if (Number.isFinite(finishedAt) && Number.isFinite(resultAt)) return resultAt > finishedAt
return !record && checkpoint === latestCheckpoint.value && !!checkpoint.metadata?.sourceCheckpointId
})
/** 当前失败与历史回执使用相同的判断,避免状态栏和详情展示相反结论。 */
const currentWorkflowError = computed(() =>
execution.value?.status === 'failed' && !executionHistorical.value ? execution.value.errorMessage || '' : ''
)
/** 拆解运行状态同时控制状态栏、诊断入口及所有恢复写操作。 */
const breakdownBusy = computed(
() =>
backgroundExecution.active.value ||
execution.value?.status === 'running' ||
(operation.value.pending &&
['正在拆解剧本', '正在重试失败抽取', '正在补齐镜头', '正在修复分镜绑定'].includes(operation.value.label))
)
/** 当前持久化任务对应的后端阶段标签。 */
const runningStage = computed(() => executionStageLabel(backgroundExecution.query.data.value?.stage ?? 'breakdown'))
/** 新任务尚未保存阶段快照时,已有内容只代表上一轮结果。 */
const previousSnapshot = computed(() => {
const startedAt = backgroundExecution.query.data.value?.startedAt
return (
breakdownBusy.value &&
!!startedAt &&
!!latestCheckpoint.value &&
Date.parse(latestCheckpoint.value.createdAt) < Date.parse(startedAt)
)
})
/** 当前保存结果中的具体问题,只显示后端明确返回的校验失败。 */
const storyboardIssues = computed(() => (validation.value?.valid === false ? validation.value.issues : []))
/** 打开独立问题弹窗,从设置进入时先释放原弹窗焦点。 */
function openIssues() {
if (toolsOpen.value) {
pendingIssues.value = true
toolsOpen.value = false
} else issuesOpen.value = true
}
/** 设置弹窗离场完成后打开问题详情。 */
function finishOpeningIssues() {
if (pendingIssues.value) {
pendingIssues.value = false
issuesOpen.value = true
}
if (pendingSafetyProject.value) {
const id = pendingSafetyProject.value
pendingSafetyProject.value = ''
if (id === projectId.value) candidateSafetyOpen.value = true
}
}
/** 打开同一个候选预检抽屉;从设置进入先释放原有焦点约束。 */
function openCandidateSafety() {
if (toolsOpen.value) {
pendingSafetyProject.value = projectId.value
toolsOpen.value = false
} else candidateSafetyOpen.value = true
}
/** 项目变化时撤销旧的抽屉交接,不回填旧项目预检。 */
watch(projectId, () => {
pendingSafetyProject.value = ''
candidateSafetyOpen.value = false
})
/**
* 切换到分镜结果并定位后端返回的真实问题坐标。
* @param issue 问题所属剧集、节拍和镜头
* @returns 分镜切换和定位完成
*/
async function locateIssue(issue: ShotValidation['issues'][number]) {
tab.value = 'storyboard'
selectedEpisodeNo.value = issue.episodeNo
await nextTick()
if (issue.beatNo)
await storyboardList.value?.locate(
{
episodeNo: issue.episodeNo,
beatNo: issue.beatNo,
...(issue.shotNo ? { shotNo: issue.shotNo } : {})
},
{ problem: true }
)
}
const taskStopped = computed(() => execution.value?.status === 'failed' || execution.value?.status === 'completed')
/** 后台拆解结束后自动刷新项目、Checkpoint 与正式主体/分镜数据。 */
watch(
() => backgroundExecution.query.data.value?.status,
(status, previous) => {
if ((status === 'completed' || status === 'failed') && status !== previous)
void Promise.all([refresh(), refreshStageReadiness()])
}
)
/** 结构校验通过后仍可能存在服务端明确标记的质量待审剧集。 */
const pendingQuality = computed(() => quality.value.actionStatus === 'blocked')
/** 只在已有拆解结果且任务中断或校验待处理时提供阶段恢复。 */
const showRecovery = computed(
() =>
records.value.length > 0 &&
!quality.value.needsRefresh &&
(!!currentWorkflowError.value || validation.value?.valid === false || pendingQuality.value)
)
/** 问题入口兼顾执行异常、结构错误、质量待审和已停止的恢复任务。 */
const hasBreakdownIssues = computed(() =>
Boolean(
currentWorkflowError.value ||
quality.value.problems.length ||
quality.value.error ||
(showRecovery.value && taskStopped.value)
)
)
/** 问题按钮按真实问题类型展示,不把质量待审或执行异常误称为结构校验失败。 */
const issueEntryLabel = computed(() =>
quality.value.error
? '候选审核待刷新'
: validation.value?.valid === false
? '分镜校验未通过'
: pendingQuality.value
? '分镜质量待修订'
: '拆解问题待处理'
)
/** 当前状态颜色只取当前质量和活动任务,不继承历史执行失败。 */
const qualityStatus = computed(() =>
breakdownBusy.value
? 'running'
: quality.value.loading
? 'pending'
: quality.value.needsRefresh
? 'unknown'
: currentWorkflowError.value
? 'failed'
: quality.value.problems.length
? 'blocked'
: quality.value.structureValid === true
? quality.value.isCandidate
? 'candidate_pending'
: 'completed'
: 'unknown'
)
/** 当前生命周期与审核文案集中展示。 */
const qualityLabel = computed(() => {
if (breakdownBusy.value) return '拆解进行中'
if (backgroundExecution.discovering.value) return '正在读取任务状态'
if (quality.value.loading) return '正在审核候选'
if (quality.value.needsRefresh) return '候选审核待确认'
if (validation.value?.valid === false) return '分镜校验未通过'
if (pendingQuality.value) return '分镜质量待修订'
if (currentWorkflowError.value) return '工作流失败'
if (quality.value.committed) return '已提交正式结果'
if (quality.value.isCandidate && quality.value.canRequestCommitPreview) return '候选审核通过 · 待安全预检查'
if (quality.value.source === 'history') return '历史结果 · 当前质量待确认'
if (quality.value.isCandidate) return '候选审核待处理'
return quality.value.structureValid === true ? '正式分镜校验通过' : '执行状态待确认'
})
/** 所有问题修改和恢复共用活动锁及后台状态读取限制,查看问题不受影响。 */
const issueActionsDisabled = computed(
() =>
project.value?.status !== 'completed' ||
!!error.value ||
operation.value.pending ||
breakdownBusy.value ||
backgroundExecution.discovering.value ||
!!backgroundExecution.discoveryError.value ||
quality.value.loading ||
!!quality.value.error
)
const configValid = computed(
() => Number.isSafeInteger(groupSize.value) && groupSize.value > 0 && modules.value.length > 0
)
/** 预览配置与明确选择的生成模式共用一次启动快照。 */
const input = computed<BreakdownInput>(() => ({
groupSize: groupSize.value,
modules: [...modules.value],
candidateOnly: candidateOnly.value
}))
/** 后端就绪状态用于拆解完成反馈。 */
const stageComplete = computed(() => stageReadiness.value?.breakdown.ready === true)
/** 拆解提示复用全局 NMessage,详细问题与修订操作放在独立问题窗口。 */
const actionMessage = useActionMessage()
/** 问题内容变化才通知,轮询取得相同快照时不会重复弹出。 */
const issueSignature = computed(() =>
JSON.stringify({
projectId: projectId.value,
checkpointId: quality.value.checkpointId,
error: currentWorkflowError.value,
problems: quality.value.problems
})
)
/** 首次读取或问题变化时只显示一条汇总,保留可操作的详情入口。 */
/** 当前会话同一版本的相同问题只通知一次,重审或切集不重复弹出。 */
const notifiedIssues = new Set<string>()
watch(
issueSignature,
() => {
const executionError = currentWorkflowError.value
const invalid = quality.value.issueCount > 0
if (
quality.value.needsRefresh ||
quality.value.loading ||
breakdownBusy.value ||
backgroundExecution.discovering.value
)
return
if ((!executionError && !invalid) || notifiedIssues.has(issueSignature.value)) return
notifiedIssues.add(issueSignature.value)
actionMessage?.warning(
() =>
h('div', { class: 'flex flex-wrap items-center gap-3' }, [
h(
'span',
invalid
? `当前${quality.value.isCandidate ? '候选' : '正式分镜'}待处理:结构 ${quality.value.structuralCount} 项,动作 ${quality.value.actionBlocks.length} 镜${quality.value.pendingEpisodeNos.length ? `,待审 ${quality.value.pendingEpisodeNos.length} 集` : ''}。`
: '拆解任务未完成,请查看错误详情。'
),
h(
NButton,
{
text: true,
onClick: () => {
openIssues()
}
},
() => '查看问题'
)
]),
{ duration: 6000, closable: true }
)
},
{ immediate: true }
)
/** 已加载的就绪状态由未完成变为完成时通知,不重放首次读取的历史结果。 */
watch([() => stageReadiness.value, stageComplete], ([, ready], [previousReadiness, previous]) => {
if (previousReadiness && ready && !previous)
actionMessage?.success('剧本拆解已准备完成,可以继续视觉风格。', { duration: 4000, closable: true })
})
const canStart = computed(
() =>
!!project.value?.episodes.length &&
project.value.status === 'completed' &&
!!preview.value &&
configValid.value &&
!operation.value.pending &&
!backgroundExecution.active.value &&
!backgroundExecution.discovering.value &&
!backgroundExecution.discoveryError.value &&
!error.value &&
(!records.value.length || taskStopped.value)
)
/** 质量确认始终绑定本次真实预览输入,修改设置后立即撤销未完成启动。 */
const startScope = computed(() => JSON.stringify(input.value))
/** 首次及规则变化时确认,已确认的相同内容不重复弹出规则表单。 */
const startPolicy = useBreakdownStartPolicy(projectId, startScope, canStart)
/** 复用全局质量表单的完整校验和独立草稿。 */
const qualityForm = ref<InstanceType<typeof QualityPolicySettings> | null>(null)
/** 仅由用户明确勾选形成规则确认,不能把默认配置当作已确认。 */
const rulesAcknowledged = ref(false)
/** 每次真实模型启动仍需核对后台任务是否停止。 */
const startAcknowledged = ref(false)
/** 规则、目标或步骤变化后重新确认,不沿用旧勾选。 */
watch([startPolicy.reviewOpen, startPolicy.editorKey, startScope], () => {
rulesAcknowledged.value = false
})
watch(startPolicy.startOpen, () => {
startAcknowledged.value = false
})
/** 关闭整个设置时中断只读确认,不能在关闭后打开迟到的弹窗。 */
watch(
toolsOpen,
shown => {
if (!shown) startPolicy.cancel()
},
{ flush: 'sync' }
)
/** 校验用户编辑的规则,成功后进入普通启动确认;此步骤不运行模型。 */
async function confirmStartRules() {
if (!rulesAcknowledged.value) return
const draft = qualityForm.value?.validatedDraft()
if (draft) await startPolicy.confirmRules(draft)
}
/** 最终确认费用与任务范围后重新读取规则,再消费本次启动许可。 */
async function confirmStart() {
if (records.value.length > 0 && !startAcknowledged.value) return
if (await startPolicy.verifyStart()) await run('start')
}
/**
* 普通启动弹窗只读核对期间仍允许用户取消。
* @param shown 弹窗目标显隐状态
*/
function updateStartOpen(shown: boolean) {
if (!shown) startPolicy.cancel()
}
let previewController: AbortController | undefined
let previewVersion = 0
/** 输入变化立即废弃旧预览,防止按新配置启动旧的任务清单。 */
function invalidatePreview() {
previewVersion++
previewController?.abort()
preview.value = null
previewBusy.value = false
}
watch(
[
groupSize,
candidateOnly,
projectId,
() => modules.value.join(','),
() => project.value?.episodes.map(item => item.episode + ':' + item.content).join('|')
],
invalidatePreview
)
onScopeDispose(invalidatePreview)
/** 只接受明确勾选状态,不把不确定值作为模块选择。 */
function toggleModule(module: BreakdownModule, checked: boolean | 'indeterminate') {
if (checked === true && !modules.value.includes(module)) modules.value.push(module)
else modules.value = modules.value.filter(item => item !== module)
}
/** 获取服务器生成的任务分组,不在浏览器伪造任务 ID。 */
async function loadPreview() {
if (!configValid.value || project.value?.status !== 'completed' || previewBusy.value) return
invalidatePreview()
const version = previewVersion
previewController = new AbortController()
previewBusy.value = true
try {
const data = await breakdownApi.preview(project.value.id, input.value, previewController.signal)
if (version === previewVersion) preview.value = data
} catch (cause) {
if (version === previewVersion) actionMessage?.error(errorMessage(cause), { duration: 6000, closable: true })
} finally {
if (version === previewVersion) previewBusy.value = false
}
}
/**
* 提交后台任务并观察真实状态,启动时固定当前候选模式。
* @param action 本次启动或恢复动作
*/
async function run(action: BreakdownAction) {
if (project.value?.status !== 'completed' || operation.value.pending || error.value) return
if (breakdownBusy.value || backgroundExecution.discovering.value || backgroundExecution.discoveryError.value) return
if (action === 'start' && !canStart.value) return
const permit = action === 'start' ? startPolicy.consumePermit() : null
if (action === 'start' && !permit) return
const labels: Record<BreakdownAction, string> = {
start: '正在拆解剧本',
retry: '正在重试失败抽取',
'resume-shots': '正在补齐镜头',
'resume-storyboard': '正在修复分镜绑定'
}
const id = project.value.id
const success = await runOperation(
id,
labels[action],
async () => {
const started = await breakdownApi.run(
id,
action,
action === 'start' ? { ...input.value, ...permit! } : undefined
)
await backgroundExecution.track(started.executionId)
return started
},
{ type: 'info', content: '拆解任务已提交,可在“拆解设置”中查看进度。' }
)
await refresh()
const cause = operation.value.cause
if (
!success &&
action === 'start' &&
id === projectId.value &&
cause instanceof ApiError &&
['QUALITY_POLICY_NOT_CONFIRMED', 'QUALITY_POLICY_VERSION_CONFLICT'].includes(cause.code ?? '')
)
await startPolicy.prepare()
}
/** 刷新候选和正式阶段状态,不重放候选生成请求。 */
async function refreshCandidate() {
const key = qualityObservation.key.value
await Promise.all([refresh(), refreshStageReadiness(), backgroundExecution.query.refresh()])
if (key === qualityObservation.key.value) await qualityObservation.refresh()
}
/** 导出当前拆解结果;阶段性数据也明确标记为 snapshot。 */
function exportResult() {
if (!snapshot.value) return
downloadText(
`breakdown-${project.value?.id}-snapshot.json`,
JSON.stringify(snapshot.value, null, 2),
'application/json'
)
}
const formModel = computed(() => ({ groupSize: groupSize.value, modules: modules.value }))
const rules = {
groupSize: integerRule('每组集数'),
modules: fieldRule(value => Array.isArray(value) && value.length > 0, '请至少选择一个抽取模块', true)
}
/** 首次空页面收起重复工具栏;存在任务、历史记录或读取错误时继续显示真实状态。 */
const isInitialEmpty = computed(
() =>
!hasBreakdownResults.value &&
!records.value.length &&
!backgroundExecution.query.data.value &&
!backgroundExecution.active.value &&
!backgroundExecution.discovering.value &&
!backgroundExecution.discoveryError.value &&
!backgroundExecution.query.error.value &&
!operation.value.pending &&
!error.value
)
</script>
<template>
<!-- 以下是手机完成提示自然滚走、分类导航与设置入口吸顶的拆解工作区 -->
<WorkspacePage split compact mobile-scroll class="breakdown-workspace-page" :header-visible="!isInitialEmpty">
<template #header>
<!-- 以下是拆解状态与设置 -->
<div class="workspace-toolbar">
<h2 class="font-semibold">剧本拆解</h2>
<div v-if="snapshot || execution || backgroundExecution.discovering.value" class="toolbar-summary">
<span v-if="previousSnapshot">上次结果</span>
<span v-if="summary"
>抽取 {{ summary.completed }} / {{ summary.total }} · 失败 {{ summary.failed }}</span
>
<span
>主体 {{ subjects.length
}}<template v-if="!formalStoryboardSummary">
· 分镜剧集 {{ shots.length }} / {{ plans.length }}</template
></span
>
<StatusBadge :status="qualityStatus" :label="qualityLabel" />
<span v-if="breakdownBusy" class="flex items-center gap-2" role="status"
><LoaderCircle :size="13" class="animate-spin" />最近阶段:{{ runningStage }}</span
>
</div>
<!-- 以下是独立的拆解入口与问题处理入口,避免混合生成和修订流程 -->
<div v-if="project?.episodes.length" class="toolbar-actions">
<NButton
v-if="hasBreakdownIssues"
class="breakdown-issues-trigger breakdown-desktop-issues"
:theme-overrides="issueButtonTheme"
:aria-label="issueEntryLabel"
:title="issueEntryLabel"
aria-haspopup="dialog"
:aria-expanded="issuesOpen"
@click="openIssues"
>
<template #icon><CircleAlert :size="15" aria-hidden="true" /></template>
<span class="breakdown-issues-label">{{ issueEntryLabel }}</span>
</NButton>
<WorkspaceTools
:pending="operation.pending"
:pending-label="operation.label"
v-model:open="toolsOpen"
:title="startPolicy.reviewOpen.value ? '拆解前确认质量规则' : '拆解设置'"
label="拆解设置"
:busy="startPolicy.saving.value"
fullscreen
@closed="finishOpeningIssues"
>
<!-- 以下是在同一全屏抽屉内核对真实质量规则的模块,不叠加第二个抽屉 -->
<div
v-if="startPolicy.reviewOpen.value && startPolicy.policy.value"
class="breakdown-policy-review"
>
<p class="text-sm leading-6 text-muted">
请核对动作与物理规则,修改将在继续时保存。确认会保存到当前项目,规则未变时不再重复提醒。
</p>
<QualityPolicySettings
ref="qualityForm"
:key="startPolicy.editorKey.value"
:project-id="projectId"
:initial-policy="startPolicy.policy.value"
:disabled="!canStart || startPolicy.busy.value"
/>
<NCheckbox
v-model:checked="rulesAcknowledged"
:disabled="startPolicy.busy.value || !canStart"
class="mt-5"
>
我已核对本次拆解使用的质量规则
</NCheckbox>
<p v-if="startPolicy.error.value" role="alert" class="mt-4 text-sm text-danger">
{{ startPolicy.error.value }}
</p>
</div>
<!-- 以下是拆解分组设置模块,规则确认时保留已有预览和草稿 -->
<section
v-show="!startPolicy.reviewOpen.value"
class="panel workspace-panel breakdown-settings-panel"
>
<p
v-if="backgroundExecution.discoveryError.value"
class="mb-4 text-xs leading-6 text-danger"
role="alert"
>
{{ backgroundExecution.discoveryError.value }}
<NButton text @click="backgroundExecution.discover">重新读取后台状态</NButton>
</p>
<div class="flex flex-wrap items-start justify-between gap-3">
<div>
<h2 class="flex items-center gap-2 font-semibold"><Layers :size="17" />拆解设置</h2>
<p class="mt-2 text-xs leading-5 text-muted">
按所选模块拆解已保存的 {{ project.episodes.length }} 集剧本。
</p>
</div>
</div>
<AppForm
class="breakdown-settings-form"
:model="formModel"
:rules="rules"
:disabled="operation.pending"
validate-on-change
@submit="loadPreview"
>
<div class="breakdown-config">
<NFormItem
class="breakdown-group-field"
path="groupSize"
label="每组集数"
:label-props="{ for: 'group-size' }"
>
<div class="breakdown-group-input">
<NInputNumber
:disabled="operation.pending"
:input-props="{ id: 'group-size' }"
class="breakdown-group-number"
:value="typeof groupSize === 'number' ? groupSize : null"
@update:value="groupSize = $event ?? 0"
:min="1"
:step="1"
></NInputNumber
><span class="breakdown-group-unit">集 / 组</span>
</div>
</NFormItem>
<NFormItem path="modules" label="抽取模块" class="breakdown-modules-field">
<div class="breakdown-module-options">
<div
v-for="option in moduleOptions"
:key="option.value"
class="breakdown-module-option"
>
<NCheckbox
:checked="modules.includes(option.value)"
:disabled="operation.pending"
:aria-label="option.label"
:aria-describedby="`breakdown-module-${option.value}-help`"
@update:checked="toggleModule(option.value, $event)"
class="control-row-checkbox"
><span class="text-sm font-medium">{{
option.label
}}</span></NCheckbox
>
<p
:id="`breakdown-module-${option.value}-help`"
class="breakdown-module-description"
>
{{ option.description }}
</p>
</div>
</div>
</NFormItem>
<NButton
:disabled="
project?.status !== 'completed' ||
previewBusy ||
operation.pending ||
!!error
"
attr-type="submit"
class="breakdown-preview-button"
><LoaderCircle v-if="previewBusy" :size="14" class="animate-spin" />预览分组
</NButton>
</div>
</AppForm>
<!-- 以下是候选生成模式,已有拆解结果统一通过安全提交替换 -->
<div class="mt-4 space-y-2">
<NCheckbox
v-model:checked="candidateOnly"
:disabled="operation.pending || records.length > 0"
>
仅生成候选,确认后再提交正式结果
</NCheckbox>
</div>
<div v-if="preview" class="group-preview">
<div class="mb-4 flex flex-wrap items-center justify-between gap-3">
<p class="text-sm">
<strong>{{ preview.groupCount }}</strong> 个分组
<span class="mx-2 text-faint">/</span>
<strong>{{ preview.estimatedTaskCount }}</strong> 个抽取任务
</p>
<NButton
:loading="
startPolicy.reading.value ||
isOperationRunning(operation, '正在拆解剧本') ||
backgroundExecution.active.value
"
type="primary"
:disabled="!canStart || startPolicy.busy.value"
@click="startPolicy.prepare"
><template #icon><ShieldCheck :size="16" aria-hidden="true" /></template
>{{ candidateOnly ? '生成拆解候选' : '开始拆解' }}</NButton
>
</div>
<div class="flex flex-wrap gap-2">
<div v-for="group in preview.groups" :key="group.groupId" class="group-chip">
<span class="text-muted">{{ String(group.groupNo).padStart(2, '0') }}</span
><span>第 {{ group.startEpisodeNo }}–{{ group.endEpisodeNo }} 集</span>
</div>
</div>
</div>
<p
v-if="startPolicy.error.value && !startPolicy.startOpen.value"
role="alert"
class="mt-4 text-sm text-danger"
>
{{ startPolicy.error.value }}
</p>
<p v-if="project.status === 'generating'" class="mt-4 text-xs text-danger">
剧本仍在生成,暂不允许启动拆解,避免读取到不完整的剧集。
</p>
<p v-if="breakdownBusy" class="mt-4 text-xs leading-5 text-muted">
拆解进行中,结束后自动更新结果。
</p>
<p v-else-if="records.length && !taskStopped" class="mt-4 text-xs leading-5 text-muted">
任务状态尚未确认,请重新读取后台状态后再操作。
</p>
</section>
<!-- 以下是候选确认交接入口,问题与预检在独立抽屉处理 -->
<section v-if="quality.isCandidate && !startPolicy.reviewOpen.value" class="space-y-3">
<h3 class="text-sm font-medium">待确认的拆解候选</h3>
<p class="text-sm text-muted">候选通过质量审核后,再核对安全预检并确认采用正式结果。</p>
<NButton
class="workspace-action-button"
:disabled="issueActionsDisabled || !quality.canRequestCommitPreview"
@click="openCandidateSafety"
>
<template #icon><ShieldCheck :size="15" aria-hidden="true" /></template>候选安全预检
</NButton>
</section>
<!-- 以下是明确标记的历史执行回执,旧任务结论不表示当前候选质量 -->
<component
:is="executionHistorical ? NCollapse : 'div'"
v-if="backgroundExecution.executionId.value"
v-show="!startPolicy.reviewOpen.value"
:class="{ 'breakdown-execution-history': executionHistorical }"
>
<component
:is="executionHistorical ? NCollapseItem : 'div'"
:name="executionHistorical ? 'history' : undefined"
:title="executionHistorical ? '历史拆解执行记录(不代表当前质量)' : undefined"
>
<WorkflowExecutionPanel
v-if="backgroundExecution.executionId.value"
:title="executionHistorical ? '历史拆解任务' : '剧本拆解任务'"
class="breakdown-execution-panel"
:show-status-hint="false"
:result-is-historical="executionHistorical"
:execution="backgroundExecution.query.data.value"
:loading="backgroundExecution.query.loading.value"
:error="backgroundExecution.query.error.value"
@refresh="backgroundExecution.query.refresh"
@dismiss="backgroundExecution.dismiss"
/>
</component>
</component>
<!-- 以下是固定的规则确认底栏,返回不记录确认,继续不会直接调用模型 -->
<template v-if="startPolicy.reviewOpen.value" #footer>
<NButton :disabled="startPolicy.saving.value" @click="startPolicy.cancel">取消</NButton>
<NButton
type="primary"
:loading="startPolicy.busy.value"
:disabled="
!rulesAcknowledged || !qualityForm?.canSave || startPolicy.busy.value || !canStart
"
@click="confirmStartRules"
><template #icon><ShieldCheck :size="16" aria-hidden="true" /></template
>确认规则并继续</NButton
>
</template>
</WorkspaceTools>
<!-- 以下是每次真实模型调用前的费用与任务确认,规则未变时直接进入此步骤 -->
<AppDialog
:open="startPolicy.startOpen.value"
:title="candidateOnly ? '生成拆解候选' : '开始拆解'"
:description="
candidateOnly
? '将按当前分组调用模型生成主体、形态与分镜候选,可能产生模型费用。现有正式数据会保留,候选需经独立确认后才提交。'
: '将按当前预览启动完整拆解并调用模型,可能产生模型费用。抽取结束后仍需完成主体整理、分镜生成与入库。'
"
:busy="operation.pending"
@update:open="updateStartOpen"
>
<NCheckbox
v-if="records.length > 0"
v-model:checked="startAcknowledged"
:disabled="startPolicy.busy.value"
>我已确认后台任务停止,当前没有同项目的生成或拆解任务在运行。</NCheckbox
>
<p v-if="startPolicy.error.value" role="alert" class="mt-4 text-sm text-danger">
{{ startPolicy.error.value }}
</p>
<template #footer>
<NButton :disabled="operation.pending" @click="startPolicy.cancel">取消</NButton>
<NButton
type="primary"
:loading="startPolicy.reading.value"
:disabled="
!canStart || startPolicy.busy.value || (records.length > 0 && !startAcknowledged)
"
@click="confirmStart"
><template #icon><ShieldCheck :size="16" aria-hidden="true" /></template>确认{{
candidateOnly ? '生成拆解候选' : '开始拆解'
}}</NButton
>
</template>
</AppDialog>
</div>
</div>
</template>
<NScrollbar v-if="!project?.episodes.length" class="panel-scroll panel">
<EmptyState
title="还没有可拆解的剧集"
description="先完成剧本创作。拆解会使用已保存的正式剧集,无需重新上传。"
/>
</NScrollbar>
<template v-else>
<section class="breakdown-results-section" :data-breakdown-source="quality.source">
<!-- 以下是候选与正式数据来源提示,手机也不隐藏,防止把候选镜头当作正式资产 -->
<p v-if="sourceLabel" class="text-xs text-muted" role="status">
{{ sourceLabel }}<span v-if="formalStoryboardSummary"> · {{ formalStoryboardSummary }}</span
><span v-if="quality.loading"> · 正在读取当前质量审核…</span>
</p>
<div v-if="!isInitialEmpty" class="result-toolbar tabs-toolbar">
<NTabs v-model:value="tab" class="workspace-tabs" type="line" size="small" aria-label="拆解结果"
><!-- 以下是仅显示分类名称的拆解标签模块,主体数量保留在搜索统计中 -->
<NTab v-for="option in moduleOptions" :key="option.value" :name="option.value">{{
option.label
}}</NTab
><NTab name="storyboard">分镜</NTab
><NTab name="tasks"
><span class="breakdown-task-label-desktop">任务明细</span
><span class="breakdown-task-label-mobile">任务</span></NTab
>
<template #suffix
><div class="tabs-toolbar-actions breakdown-toolbar-actions">
<!-- 以下是待安全预检候选的直接入口,桌面显示文字,手机保留图标与提示 -->
<WorkspaceActionTooltip
v-if="quality.isCandidate && quality.canRequestCommitPreview"
label="候选安全预检"
mobile-only
>
<NButton
class="workspace-action-button breakdown-safety-trigger"
aria-label="候选安全预检"
aria-haspopup="dialog"
:aria-expanded="candidateSafetyOpen"
:disabled="issueActionsDisabled"
@click="openCandidateSafety"
>
<template #icon><ShieldCheck :size="15" aria-hidden="true" /></template>
<span class="breakdown-safety-label">候选安全预检</span>
</NButton>
</WorkspaceActionTooltip>
<!-- 以下是移动端校验问题入口,与设置图标并排且共用问题详情 -->
<NButton
v-if="hasBreakdownIssues"
class="icon-button breakdown-issues-trigger breakdown-mobile-issues"
:theme-overrides="issueButtonTheme"
:aria-label="issueEntryLabel"
:title="issueEntryLabel"
aria-haspopup="dialog"
:aria-expanded="issuesOpen"
@click="openIssues"
>
<template #icon><CircleAlert :size="15" aria-hidden="true" /></template>
</NButton>
<!-- 以下是手机分类导航中的拆解设置入口,共用原有设置弹窗 -->
<WorkspaceActionTooltip label="拆解设置">
<NButton
quaternary
class="icon-button breakdown-mobile-tools"
aria-label="拆解设置"
aria-haspopup="dialog"
:aria-expanded="toolsOpen"
@click="toolsOpen = true"
>
<template #icon><Settings2 :size="15" aria-hidden="true" /></template>
</NButton>
</WorkspaceActionTooltip>
<!-- 以下是拆解快照直接导出模块,与剧本创作共用图标和悬浮说明 -->
<WorkspaceExportButton
label="导出拆解结果"
:disabled="!snapshot"
@export="exportResult"
/></div
></template>
</NTabs>
</div>
<div class="breakdown-content panel">
<main class="min-w-0 min-h-0 overflow-hidden">
<!-- 以下是首次无任务空页面的居中入口,已有任务时恢复原分类内容 -->
<NScrollbar
v-if="isInitialEmpty"
class="panel-scroll breakdown-results-scroll"
content-class="breakdown-empty-scroll-content"
>
<EmptyState
class="breakdown-initial-empty"
title="还没有拆解结果"
description="点击“拆解设置”,选择需要的模块和分组,预览后再确认生成。"
>
<NButton
type="primary"
aria-label="拆解设置"
aria-haspopup="dialog"
:aria-expanded="toolsOpen"
@click="toolsOpen = true"
><template #icon><Settings2 :size="16" aria-hidden="true" /></template
>拆解设置</NButton
>
</EmptyState>
</NScrollbar>
<!-- 所有结果标签共用有界的内容滚动;切换标签回到顶部,不继承上一列表的位置。 -->
<NScrollbar v-else :key="tab" class="panel-scroll breakdown-results-scroll">
<template v-for="option in moduleOptions" :key="option.value"
><div v-if="tab === option.value" class="breakdown-result-pad">
<SubjectList
:project-id="quality.source === 'formal' ? project?.id : undefined"
:subjects="subjects.filter(item => item.module === option.value)"
:forms="forms"
/></div
></template>
<div v-if="tab === 'storyboard'" class="breakdown-result-pad">
<StoryboardList
ref="storyboardList"
v-model:episode-no="selectedEpisodeNo"
:plans="plans"
:episodes="shots"
:diagnosis-disabled="
quality.source !== 'formal' ||
breakdownBusy ||
backgroundExecution.discovering.value
"
@diagnose="openShotDiagnosis"
>
<!-- 以下是跟随当前剧集的一行诊断摘要,诊断弹窗独立于列表滚动 -->
<template #diagnosis>
<StoryboardDiagnosis
v-if="
quality.source === 'formal' &&
!breakdownBusy &&
!backgroundExecution.discovering.value
"
ref="diagnosisPanel"
:project-id="projectId"
:episode-no="currentEpisodeNo"
:episode-nos="diagnosisEpisodeNos"
@locate="locateDiagnosisShot"
/>
</template>
</StoryboardList>
</div>
<div v-if="tab === 'tasks'" class="breakdown-result-pad">
<NScrollbar x-scrollable v-if="snapshot?.tasks?.length" class="table-scroll">
<NTable :bordered="false" :single-line="true" striped class="project-table"
><thead>
<tr>
<th>分组</th>
<th>模块</th>
<th>状态</th>
<th>尝试</th>
</tr>
</thead>
<tbody>
<template v-for="task in snapshot.tasks" :key="task.taskId"
><tr>
<td>
第 {{ task.group.startEpisodeNo }}–{{ task.group.endEpisodeNo }}
集
</td>
<td>
{{
moduleOptions.find(item => item.value === task.module)
?.label
}}
</td>
<td>
<StatusBadge
:status="task.status"
:label="
{
pending: '等待中',
running: '执行中',
completed: '完成',
failed: '失败'
}[task.status]
"
/>
</td>
<td>{{ task.attempt }}</td>
</tr>
<tr v-if="task.errorMessage">
<td colspan="4" class="text-danger">{{ task.errorMessage }}</td>
</tr></template
>
</tbody></NTable
>
</NScrollbar>
<EmptyState
v-else
title="尚无抽取任务记录"
description="启动拆解后会持续保存进度;预览只展示本次处理范围,不会直接开始执行。"
/>
</div>
</NScrollbar>
</main>
</div>
</section>
</template>
</WorkspacePage>
<!-- 以下是独立的安全预检、单条关系修复和最终采用流程,共用真实状态刷新 -->
<BreakdownCandidatePanel
v-model:open="candidateSafetyOpen"
:project-id="projectId"
:state="qualityObservation.source.value.state || undefined"
:quality="quality"
:checkpoint-id="latestCheckpoint?.checkpointId"
:disabled="issueActionsDisabled"
:episodes="project?.episodes ?? []"
@refresh="refreshCandidate"
/>
<!-- 以下是与拆解设置分离的全屏问题详情抽屉 -->
<BreakdownIssuesDialog
v-model:open="issuesOpen"
:issues="storyboardIssues"
:quality="quality"
:busy="exceptionSaving"
:workflow-error="currentWorkflowError"
:locatable="!breakdownBusy && !!shots.length"
@locate="locateIssue"
@refresh="refreshCandidate"
>
<!-- 以下是失败候选与正式时长来源的只读核对 -->
<template #duration>
<BreakdownDurationDiagnostics
v-if="issuesOpen && projectId"
:project-id="projectId"
:checkpoint-id="latestCheckpoint?.checkpointId"
/>
</template>
<!-- 以下是只属于问题处理的人工修订与阶段恢复,不混入拆解启动配置 -->
<template #repair>
<p v-if="breakdownBusy || operation.pending" role="status" class="text-xs leading-6 text-muted">
任务执行中,可查看问题,结束后再修订或恢复。
</p>
<p
v-else-if="backgroundExecution.discovering.value || backgroundExecution.discoveryError.value || error"
role="status"
class="text-xs leading-6 text-muted"
>
任务状态或结果尚未确认,请先重新读取状态与结果。
</p>
<!-- 以下是从当前动作冲突带入角色和动作的例外入口,独立保存规则且保留旧例外 -->
<ActionExceptionRepair
v-if="
issuesOpen &&
qualityObservation.source.value.state &&
quality.source !== 'history' &&
quality.actionBlocks.some(block =>
[...block.blockingCodes, ...block.warningCodes].includes('action_resource_conflict')
)
"
:project-id="projectId"
:checkpoint-id="latestCheckpoint?.checkpointId || ''"
:state="qualityObservation.source.value.state"
:quality="quality"
:disabled="issueActionsDisabled"
@busy="exceptionSaving = $event"
@refresh="refreshCandidate"
/>
<CandidateRepairs
v-if="issuesOpen && quality.isCandidate && snapshot"
:project-id="projectId"
:checkpoint-id="latestCheckpoint?.checkpointId || ''"
:state="snapshot"
:review="qualityObservation.review.value"
:disabled="issueActionsDisabled"
@refresh="refreshCandidate"
/>
<StoryboardQualityRepair
v-else-if="issuesOpen && snapshot && !quality.isCandidate"
:project-id="projectId"
:checkpoint="latestCheckpoint"
:disabled="issueActionsDisabled"
@refresh="refreshCandidate"
/>
<div v-if="snapshot && showRecovery" class="recovery-strip">
<div>
<p class="text-sm font-medium">从中断处继续</p>
</div>
<div class="flex flex-wrap gap-2">
<ConfirmAction
:loading="isOperationRunning(operation, '正在重试失败抽取')"
label="重试失败抽取"
description="只重新提取失败的人物、场景或道具,不重做已完成内容。镜头问题请使用对应修复操作。"
acknowledgement
:disabled="issueActionsDisabled || !recovery.retry"
@confirm="run('retry')"
/><ConfirmAction
:loading="isOperationRunning(operation, '正在补齐镜头')"
label="继续整理镜头"
description="复用已生成内容,修正可确定的状态标记并补齐缺失镜头,再执行完整质量检查。"
acknowledgement
:disabled="issueActionsDisabled || !recovery.shots"
@confirm="run('resume-shots')"
/><ConfirmAction
:loading="isOperationRunning(operation, '正在修复分镜绑定')"
label="修复分镜绑定"
description="保留已有镜头,补齐人物、场景、道具及其形态的对应关系,然后检查并保存。"
acknowledgement
:disabled="issueActionsDisabled || !recovery.storyboard"
@confirm="run('resume-storyboard')"
/>
</div>
</div>
</template>
</BreakdownIssuesDialog>
</template>
<style>
/* 历史折叠只保留一层内容留白,避免 Naive 内容间距叠加任务卡片的 mt-4。 */
.breakdown-execution-history.n-collapse
.n-collapse-item
.n-collapse-item__content-wrapper
.n-collapse-item__content-inner {
padding-top: 8px;
}
.breakdown-execution-history .breakdown-execution-panel {
margin-top: 0;
}
/* 键盘聚焦仍有清晰提示,并与问题入口的红色语义保持一致。 */
.breakdown-workspace-page .breakdown-issues-trigger.n-button:focus-visible {
outline-color: var(--app-danger);
}
/* 本组件专属布局与 Naive 内部结构覆盖。 */
@reference "../../styles/styles.css";
.group-preview {
@apply mt-6 pt-5;
}
.group-chip {
@apply flex items-center gap-2.5 bg-(--app-subtle) rounded-none py-2 px-[11px] text-[11px];
}
.recovery-strip {
@apply bg-(--app-subtle) flex justify-between flex-wrap items-center gap-[15px] p-[17px] rounded-none;
}
.breakdown-settings-panel {
container: breakdown-settings / inline-size;
}
/* 同一抽屉切换步骤时首个可见模块不继承隐藏设置区域的兄弟间距。 */
.workspace-tools-body > .breakdown-policy-review + .breakdown-settings-panel {
margin-top: 0;
}
/* 说明与表单留出 16px,避免移除来源标签后紧贴首个字段。 */
.breakdown-settings-form {
margin-top: 16px;
}
.breakdown-config {
@apply grid grid-cols-[180px_minmax(0,_1fr)_auto] items-start gap-y-4 gap-x-6;
--breakdown-label-offset: 29px;
}
.breakdown-group-field,
.breakdown-modules-field,
.breakdown-module-option {
@apply min-w-0;
}
.breakdown-group-input {
@apply w-full flex items-center gap-3;
}
.breakdown-group-number.n-input-number {
@apply flex-[0_0_120px] w-[120px];
}
.breakdown-group-unit {
@apply shrink-0 whitespace-nowrap text-muted text-sm;
}
.breakdown-modules-field {
@apply m-0 p-0 border-0;
}
.breakdown-module-options {
/* 模块内部收紧为 8px,说明到字段和字段之间仍保持 16px 的层级间距。 */
@apply w-full grid grid-cols-[repeat(3,_minmax(0,_1fr))] gap-y-2 gap-x-4;
}
.breakdown-module-description {
@apply mt-1 mx-0 mb-0 pl-6 text-muted text-[11px] leading-[18px] wrap-anywhere;
}
.breakdown-preview-button.n-button {
@apply self-start mt-[var(--breakdown-label-offset)] whitespace-nowrap;
}
@container breakdown-settings (max-width: 780px) {
.breakdown-config {
@apply grid-cols-[180px_minmax(0,_1fr)];
}
.breakdown-preview-button.n-button {
@apply col-[2] justify-self-end mt-0;
}
}
@container breakdown-settings (max-width: 560px) {
.breakdown-config {
@apply grid-cols-[minmax(0,_1fr)];
}
.breakdown-module-options {
@apply grid-cols-[repeat(auto-fit,_minmax(min(100%,_160px),_1fr))];
}
.breakdown-preview-button.n-button {
@apply col-[1];
}
}
.result-toolbar .n-tabs-tab__label {
@apply inline-flex gap-1.5;
}
.breakdown-results-section {
@apply flex flex-col flex-1 min-h-0 min-w-0;
/* 提示到导航、导航到搜索、搜索到列表共用同一个模块间距。 */
gap: var(--app-content-gap);
}
.breakdown-results-section > .result-toolbar {
@apply shrink-0;
}
.breakdown-results-section > .breakdown-content {
/* 移除执行记录分栏,结果独占剩余宽高。 */
@apply grid flex-1 h-auto min-h-0 grid-cols-[minmax(0,_1fr)] grid-rows-[minmax(0,_1fr)];
/* 外层透明,搜索框和各条目使用自身背景,模块间距不再铺底色。 */
background: transparent;
}
.breakdown-results-scroll .n-scrollbar-content {
@apply wrap-anywhere;
}
/* 空数据引导使用正文剩余高度居中,短视口仍由原有滚动容器承接。 */
.breakdown-empty-scroll-content {
min-height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
.breakdown-result-pad {
/* 条目保留自身背景和内边距,外层不再重复缩进搜索和结果。 */
@apply p-0;
}
.breakdown-result-pad .subject-list-toolbar {
margin-bottom: var(--app-content-gap);
}
.breakdown-workspace-page .workspace-tabs .n-tabs-nav__suffix,
.breakdown-workspace-page .breakdown-toolbar-actions {
/* 设置与导出入口共用标签栏高度,导出按钮保持正方形。 */
align-items: stretch;
}
.breakdown-workspace-page .breakdown-toolbar-actions {
gap: 0;
}
.breakdown-workspace-page .breakdown-mobile-tools.n-button,
.breakdown-workspace-page .breakdown-mobile-issues.n-button {
display: none;
}
.breakdown-task-label-mobile {
display: none;
}
@media (max-width: 760px) {
/* 手机隐藏整行统计和旧设置入口,设置功能移到分类导航右侧。 */
.breakdown-workspace-page .workspace-heading-scroll.n-scrollbar {
display: none;
}
.breakdown-task-label-desktop {
display: none;
}
.breakdown-task-label-mobile {
display: inline;
}
/* 缩短标签文字并收紧间距,让手机分类与设置图标完整显示在同一行。 */
.breakdown-workspace-page .workspace-tabs.n-tabs .n-tabs-nav .n-tabs-tab {
padding-inline: 8px;
}
.breakdown-workspace-page .breakdown-mobile-tools.n-button,
.breakdown-workspace-page .breakdown-mobile-issues.n-button {
display: inline-flex;
width: var(--app-toolbar-icon-size, 44px);
min-width: var(--app-toolbar-icon-size, 44px);
height: var(--app-toolbar-icon-size, 44px);
padding: 0;
}
/* 上下两组手机工具栏采用相同间距,保持两列图标对齐。 */
.breakdown-workspace-page .breakdown-toolbar-actions {
align-items: center;
gap: 8px;
}
/* 分类导航与设置共用完整吸顶背景,正文不会从导航区域透出。 */
.breakdown-workspace-page .breakdown-results-section > .result-toolbar {
position: sticky;
top: 0;
z-index: 19;
background: var(--app-body);
}
/* 正文交给项目内容区滚动,绿色提示随页面位置自然移出,不做透明度收起。 */
.breakdown-workspace-page .breakdown-results-section {
flex: none;
overflow: visible;
}
.breakdown-workspace-page .breakdown-content,
.breakdown-workspace-page .breakdown-content > main,
.breakdown-workspace-page .breakdown-results-scroll,
.breakdown-workspace-page .breakdown-results-scroll > .n-scrollbar-container {
height: auto;
max-height: none;
overflow: visible;
}
/* 手机正文自然滚动,同时为首次操作保留清晰的居中区域。 */
.breakdown-empty-scroll-content {
min-height: min(55dvh, 420px);
}
}
@media (max-width: 800px) {
.breakdown-workspace-page .workspace-toolbar {
@apply min-h-0 flex-nowrap gap-2;
}
.breakdown-workspace-page .workspace-toolbar h2 {
@apply hidden;
}
.breakdown-workspace-page .toolbar-summary {
@apply min-w-0 flex-1 flex-nowrap overflow-x-auto overflow-y-hidden overscroll-x-contain;
scrollbar-width: none;
mask-image: linear-gradient(to right, #000 calc(100% - 12px), transparent);
}
.breakdown-workspace-page .toolbar-summary::-webkit-scrollbar {
display: none;
}
.breakdown-workspace-page .toolbar-summary > * {
@apply shrink-0;
}
.breakdown-workspace-page .toolbar-actions {
@apply ml-0 shrink-0;
}
.breakdown-workspace-page .toolbar-actions > * {
@apply shrink-0;
}
.breakdown-workspace-page .workspace-tools-label {
@apply hidden;
}
/* 窄屏问题入口与设置按钮保持同样的方形尺寸,仅隐藏可见文案。 */
.breakdown-workspace-page .breakdown-issues-label {
display: none;
}
.breakdown-workspace-page .breakdown-desktop-issues.n-button {
width: 32px;
min-width: 32px;
height: 32px;
padding: 0;
}
.breakdown-workspace-page .breakdown-issues-trigger .n-button__icon {
margin: 0;
}
.breakdown-workspace-page .workspace-tools-trigger {
@apply h-8 w-8 p-0;
min-width: 32px;
}
.breakdown-workspace-page .workspace-tools-trigger .n-button__icon {
@apply m-0;
}
.breakdown-results-section .tabs-toolbar {
container-type: normal;
}
.breakdown-results-section .workspace-tabs > .n-tabs-nav {
@apply flex-nowrap;
}
.breakdown-results-section .workspace-tabs .n-tabs-nav-scroll-wrapper {
@apply min-w-0 flex-1;
flex-basis: auto;
}
.breakdown-results-section .workspace-tabs .n-tabs-nav__suffix {
@apply w-auto pl-2;
}
.breakdown-results-section .tabs-toolbar-actions {
@apply min-h-0 flex-nowrap;
}
}
/* 工具栏在手机仅保留预检图标,正文与底栏的确认操作继续显示完整文字。 */
@media (max-width: 639px) {
.breakdown-safety-label {
display: none;
}
.breakdown-safety-trigger {
width: 34px;
height: 34px;
padding: 0;
}
.breakdown-safety-trigger .n-button__icon {
margin: 0;
}
}
</style>