feat(short-drama-agent-front): 接入关系修复并优化配置与弹窗
This commit is contained in:
1 parent
2db8549818
commit
41d1cfe3ed
15 files changed
+1134
-323
No files matched your search
@@ -1,5 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { NButton, NModal, NScrollbar } from 'naive-ui'
|
||||
import { NButton, NModal, NScrollbar, useThemeVars } from 'naive-ui'
|
||||
import { CircleAlert, CircleCheck, CircleX } from '@lucide/vue'
|
||||
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
||||
|
||||
/** 公共弹窗的标题、说明、操作状态和宽度。 */
|
||||
@@ -7,8 +8,10 @@ withDefaults(
|
||||
defineProps<{
|
||||
/** 弹窗标题,同时作为可访问名称。 */
|
||||
title: string
|
||||
/** 标题下的默认说明,可使用 description slot 覆盖。 */
|
||||
/** 可选的简短标题补充,尽量一句话;完整说明与操作影响应放入默认正文插槽。 */
|
||||
description?: string
|
||||
/** 展示语义状态;默认保持中性,警告、成功和错误仅在标题旁显示对应图标。 */
|
||||
status?: 'default' | 'warning' | 'success' | 'error'
|
||||
/** 提交期间锁定关闭操作。 */
|
||||
busy?: boolean
|
||||
/** 使用宽弹窗布局。 */
|
||||
@@ -16,8 +19,10 @@ withDefaults(
|
||||
/** 指定弹窗宽度,单位为像素;实际宽度仍受视口限制。 */
|
||||
width?: number
|
||||
}>(),
|
||||
{ description: '', busy: false, wide: false }
|
||||
{ description: '', busy: false, wide: false, status: 'default' }
|
||||
)
|
||||
/** 状态图标使用当前 Naive 主题颜色,随深浅主题切换,不改变弹窗和按钮配色。 */
|
||||
const themeVars = useThemeVars()
|
||||
/** 关闭动画结束后通知调用方,便于在焦点陷阱释放后定位正文。 */
|
||||
const emit = defineEmits<{ closed: [] }>()
|
||||
/** 弹窗显隐状态,关闭行为由 Naive 管理。 */
|
||||
@@ -100,7 +105,34 @@ onBeforeUnmount(() => {
|
||||
<!-- 以下是固定标题与说明模块,无说明时标题与关闭按钮垂直居中对齐 -->
|
||||
<template #header>
|
||||
<div class="min-w-0">
|
||||
<div class="text-lg font-semibold">{{ title }}</div>
|
||||
<div class="flex items-center gap-2 text-lg font-semibold">
|
||||
<!-- 以下是可被读屏识别的状态提示,颜色之外保留不同图形 -->
|
||||
<CircleAlert
|
||||
v-if="status === 'warning'"
|
||||
:size="20"
|
||||
class="shrink-0"
|
||||
role="img"
|
||||
aria-label="警告"
|
||||
:style="{ color: themeVars.warningColor }"
|
||||
/>
|
||||
<CircleCheck
|
||||
v-else-if="status === 'success'"
|
||||
:size="20"
|
||||
class="shrink-0"
|
||||
role="img"
|
||||
aria-label="成功"
|
||||
:style="{ color: themeVars.successColor }"
|
||||
/>
|
||||
<CircleX
|
||||
v-else-if="status === 'error'"
|
||||
:size="20"
|
||||
class="shrink-0"
|
||||
role="img"
|
||||
aria-label="错误"
|
||||
:style="{ color: themeVars.errorColor }"
|
||||
/>
|
||||
<span class="min-w-0 wrap-anywhere">{{ title }}</span>
|
||||
</div>
|
||||
<div v-if="description || $slots.description" class="mt-[2px] text-sm leading-6 font-normal text-muted">
|
||||
<slot name="description">{{ description }}</slot>
|
||||
</div>
|
||||
|
||||
@@ -49,6 +49,10 @@ 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)',
|
||||
@@ -209,7 +213,24 @@ function finishOpeningIssues() {
|
||||
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 问题所属剧集、节拍和镜头
|
||||
@@ -785,15 +806,18 @@ const isInitialEmpty = computed(
|
||||
任务状态尚未确认,请重新读取后台状态后再操作。
|
||||
</p>
|
||||
</section>
|
||||
<BreakdownCandidatePanel
|
||||
v-show="!startPolicy.reviewOpen.value"
|
||||
:project-id="projectId"
|
||||
:state="qualityObservation.source.value.state || undefined"
|
||||
:quality="quality"
|
||||
:checkpoint-id="latestCheckpoint?.checkpointId"
|
||||
:disabled="issueActionsDisabled"
|
||||
@refresh="refreshCandidate"
|
||||
/>
|
||||
<!-- 以下是候选确认交接入口,问题与预检在独立抽屉处理 -->
|
||||
<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'"
|
||||
@@ -898,6 +922,24 @@ const isInitialEmpty = computed(
|
||||
>
|
||||
<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"
|
||||
@@ -1055,6 +1097,17 @@ const isInitialEmpty = computed(
|
||||
</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"
|
||||
@@ -1398,4 +1451,18 @@ const isInitialEmpty = computed(
|
||||
@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>
|
||||
@@ -20,7 +20,9 @@ import type {
|
||||
CandidateSubjectRepairInput,
|
||||
CandidateSubjectRepairResult,
|
||||
CandidateActionRepairInput,
|
||||
CandidateActionRepairResult
|
||||
CandidateActionRepairResult,
|
||||
CandidateRelationRepairInput,
|
||||
CandidateRelationRepairResult
|
||||
} from './candidate.types'
|
||||
import type {
|
||||
QualityRepairPlan,
|
||||
@@ -89,6 +91,20 @@ export const breakdownApi = {
|
||||
request<CandidateCommitPreview>(`/projects/${encodeURIComponent(id)}/breakdown/candidate-commit-preview`, {
|
||||
signal
|
||||
}),
|
||||
/**
|
||||
* 用户明确确认后移除预检中的单条无来源关系,只创建候选新版本。
|
||||
* @param id 当前项目
|
||||
* @param input 用户选定的原始关系、确认与保存记录
|
||||
* @returns 新候选版本和实际移除数量
|
||||
*/
|
||||
repairCandidateRelation: (id: string, input: CandidateRelationRepairInput) =>
|
||||
request<CandidateRelationRepairResult>(
|
||||
`/projects/${encodeURIComponent(id)}/breakdown/candidate-relation-repair`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: input
|
||||
}
|
||||
),
|
||||
/**
|
||||
* 用户确认后补齐候选主体引用与真实形态。
|
||||
* @param id 当前项目
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { BreakdownState } from './types'
|
||||
import type { CandidateCommitPreview } from './candidate.types'
|
||||
import type { CandidateCommitPreview, CandidateCommitCheckPreview } from './candidate.types'
|
||||
|
||||
/** 安全检查项与用户可理解的阻断原因共用一份映射。 */
|
||||
export const candidateCheckLabels: Record<keyof CandidateCommitPreview['checks'], string> = {
|
||||
export const candidateCheckLabels: Record<keyof CandidateCommitCheckPreview['checks'], string> = {
|
||||
qualityPolicyMatches: '质量规则与当前已确认版本一致',
|
||||
episodeNumbersMatch: '剧集范围与候选一致',
|
||||
episodeFingerprintsMatch: '剧本正文版本未变化',
|
||||
@@ -10,7 +10,8 @@ export const candidateCheckLabels: Record<keyof CandidateCommitPreview['checks']
|
||||
noActiveVideos: '没有正在生成的视频',
|
||||
noSubjectIdentities: '没有需要保护的主体身份',
|
||||
noSubjectImages: '没有需要保护的主体图片',
|
||||
noProtectedShots: '没有需要保护的镜头资产'
|
||||
noProtectedShots: '没有需要保护的镜头资产',
|
||||
relationEvidenceValid: '场景、道具关系的来源证据有效'
|
||||
}
|
||||
/** 必须逐项校验的固定安全门禁,不根据响应动态减少检查项。 */
|
||||
export const candidateCheckKeys = [
|
||||
@@ -21,7 +22,8 @@ export const candidateCheckKeys = [
|
||||
'noActiveVideos',
|
||||
'noSubjectIdentities',
|
||||
'noSubjectImages',
|
||||
'noProtectedShots'
|
||||
'noProtectedShots',
|
||||
'relationEvidenceValid'
|
||||
] as const
|
||||
|
||||
/**
|
||||
@@ -36,7 +38,13 @@ export function candidatePreviewReady(
|
||||
projectId: string,
|
||||
checkpointId?: string
|
||||
): boolean {
|
||||
if (!preview || preview.projectId !== projectId || preview.checkpointId !== checkpointId) return false
|
||||
if (
|
||||
!preview ||
|
||||
preview.status === 'already_committed' ||
|
||||
preview.projectId !== projectId ||
|
||||
preview.checkpointId !== checkpointId
|
||||
)
|
||||
return false
|
||||
// 外部 JSON 的布尔值必须严格为 true,不接受缺失值或字符串等真值。
|
||||
const flags: unknown[] = [preview.readOnly, preview.ready, ...candidateCheckKeys.map(key => preview.checks?.[key])]
|
||||
return flags.every(value => value === true)
|
||||
|
||||
@@ -114,14 +114,39 @@ export interface CandidateRevalidation {
|
||||
canCommit: false
|
||||
}
|
||||
|
||||
/** 候选提交安全预检查响应,正式提交仍会在事务内复查。 */
|
||||
export interface CandidateCommitPreview {
|
||||
/** 预检返回的单条无来源关系,所有定位字段均须原样提交。 */
|
||||
export interface CandidateRelationTarget {
|
||||
/** 候选主体引用。 */ subjectRef: string
|
||||
/** 候选主体名称。 */ subjectName: string
|
||||
/** 原始关系。 */ relation: string
|
||||
/** 原始关系目标。 */ target: string
|
||||
/** 原始来源证据。 */ evidence: string
|
||||
}
|
||||
|
||||
/** 人工明确移除单条关系的版本化请求,不允许删除主体或改写证据。 */
|
||||
export interface CandidateRelationRepairInput extends Omit<CandidateRelationTarget, 'subjectName'> {
|
||||
/** 必须由用户明确确认。 */ confirmed: true
|
||||
/** 本次预检对应的保存记录。 */ expectedCheckpointId: string
|
||||
}
|
||||
|
||||
/** 关系修复只保存新的候选版本,不代表候选已正式采用。 */
|
||||
export interface CandidateRelationRepairResult {
|
||||
/** 新保存记录。 */ checkpointId: string
|
||||
/** 已处理的主体引用。 */ subjectRef: string
|
||||
/** 本次仅移除一条。 */ removed: 1
|
||||
}
|
||||
|
||||
/** 未提交候选的安全预检查响应,正式提交仍会在事务内复查。 */
|
||||
export interface CandidateCommitCheckPreview {
|
||||
/** 所属项目。 */
|
||||
projectId: string
|
||||
/** 被检查的候选版本。 */
|
||||
checkpointId: string
|
||||
/** 所有检查是否通过。 */
|
||||
ready: boolean
|
||||
/** 未提交分支不携带已提交状态。 */ status?: never
|
||||
/** 关系来源阻断的原始说明。 */ relationIssues: string[]
|
||||
/** 可供人工核对的原始关系,不代表已经确认删除。 */ relationRepairTargets: CandidateRelationTarget[]
|
||||
/** 剧本版本、活动任务及下游资产保护。 */
|
||||
checks: {
|
||||
/** 候选使用的质量规则与当前明确确认版本一致。 */
|
||||
@@ -140,6 +165,8 @@ export interface CandidateCommitPreview {
|
||||
noSubjectImages: boolean
|
||||
/** 没有受保护镜头资产。 */
|
||||
noProtectedShots: boolean
|
||||
/** 场景、道具关系的证据可在正式剧本中找到。 */
|
||||
relationEvidenceValid: boolean
|
||||
}
|
||||
/** 真实数据数量。 */
|
||||
counts: {
|
||||
@@ -162,6 +189,19 @@ export interface CandidateCommitPreview {
|
||||
readOnly: true
|
||||
}
|
||||
|
||||
/** 已采用的候选没有 checks 和 counts,不能按预检失败处理。 */
|
||||
export interface CandidateAlreadyCommitted {
|
||||
/** 所属项目。 */ projectId: string
|
||||
/** 最新保存记录。 */ checkpointId: string
|
||||
/** 已提交结果不再提供提交许可。 */ ready: false
|
||||
/** 后端明确的已提交状态。 */ status: 'already_committed'
|
||||
/** 原始说明只用于展示转换。 */ reason: string
|
||||
/** 此操作只读。 */ readOnly: true
|
||||
}
|
||||
|
||||
/** 安全预检按后端真实响应区分未提交和已提交结果。 */
|
||||
export type CandidateCommitPreview = CandidateCommitCheckPreview | CandidateAlreadyCommitted
|
||||
|
||||
/** 人工确认的候选主体补齐请求。 */
|
||||
export interface CandidateSubjectRepairInput extends CandidateShotLocation {
|
||||
/** 乐观版本锁。 */
|
||||
|
||||
@@ -1,182 +1,342 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox } from 'naive-ui'
|
||||
import { AppDialog, WorkspaceRefreshButton } from '../../../components/ui'
|
||||
import { NButton, NCheckbox, NCollapse, NCollapseItem, NRadio, NSelect, NTag } from 'naive-ui'
|
||||
import { Trash2 } from '@lucide/vue'
|
||||
import { AppDrawer, WorkspaceRefreshButton, WorkspaceSectionHeading } from '../../../components/ui'
|
||||
import type { BreakdownState } from '../types'
|
||||
import type { BreakdownQuality } from '../quality'
|
||||
import type { CandidateCommitPreview } from '../candidate.types'
|
||||
import type { CandidateCommitPreview, CandidateRelationTarget } from '../candidate.types'
|
||||
import type { Episode } from '../../projects/types'
|
||||
import { candidateCheckKeys, candidateCheckLabels, candidatePreviewReady } from '../candidate'
|
||||
import { breakdownApi } from '../api'
|
||||
import { runOperation, getOperation } from '../../workflows/operations'
|
||||
import { projectsApi } from '../../projects/api'
|
||||
import { workflowCheckpoints } from '../../workflows/selectors'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import { ApiError, errorMessage } from '../../../lib/http'
|
||||
import { showActionFeedback, useActionMessage } from '../../../components/ui/useActionMessage'
|
||||
|
||||
/** 当前原始版本与集中审核结论共同决定安全检查入口。 */
|
||||
const props = defineProps<{
|
||||
/** 当前项目。 */
|
||||
projectId: string
|
||||
/** 当前版本归一化候选。 */
|
||||
state?: BreakdownState
|
||||
/** 当前检查点。 */
|
||||
checkpointId?: string
|
||||
/** 页面统一质量结论。 */
|
||||
quality: BreakdownQuality
|
||||
/** 活动任务或读取失败时禁止写入。 */
|
||||
disabled: boolean
|
||||
}>()
|
||||
/** 只在真实写回后刷新服务端资产及阶段状态。 */
|
||||
/** 安全预检与单条关系人工处理复用独立全屏抽屉,不承载拆解启动配置。 */
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** 当前项目。 */ projectId: string
|
||||
/** 最新原始候选。 */ state?: BreakdownState
|
||||
/** 最新保存记录。 */ checkpointId?: string
|
||||
/** 集中的候选质量结论。 */ quality: BreakdownQuality
|
||||
/** 活动任务或读取异常时禁止写入。 */ disabled: boolean
|
||||
/** 项目详情已读取的正式原文,仅用于人工核对。 */ episodes?: Pick<Episode, 'episode' | 'content'>[]
|
||||
}>(),
|
||||
{ episodes: () => [] }
|
||||
)
|
||||
/** 抽屉关闭后立即废弃只读请求,不保留提交许可。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 真实写回、发现旧版本或已提交结果后刷新项目、审核和阶段。 */
|
||||
const emit = defineEmits<{ refresh: [] }>()
|
||||
/** 应用消息层。 */
|
||||
/** 全局消息反馈。 */
|
||||
const message = useActionMessage()
|
||||
/** 项目级写操作锁。 */
|
||||
/** 当前项目的活动任务及短请求锁。 */
|
||||
const operation = computed(() => getOperation(props.projectId))
|
||||
/** 当前预检查回执。 */
|
||||
/** 当前只读预检原始回执。 */
|
||||
const preview = ref<CandidateCommitPreview | null>(null)
|
||||
/** 只读安全检查加载状态。 */
|
||||
/** 预检只读加载,允许关闭。 */
|
||||
const checking = ref(false)
|
||||
/** 本面板正式提交状态。 */
|
||||
const committing = ref(false)
|
||||
/** 预检查请求失败原因。 */
|
||||
const checkError = ref('')
|
||||
/** 仅通过预检查才能打开最终确认。 */
|
||||
const confirmOpen = ref(false)
|
||||
/** 用户对替换正式资产的明确确认。 */
|
||||
/** 真实写入期间锁定关闭与重复操作。 */
|
||||
const writing = ref(false)
|
||||
/** 读取或本次写入失败,保留可操作的中文原因。 */
|
||||
const actionError = ref('')
|
||||
/** 默认不选关系,每次只允许人工处理一条。 */
|
||||
const selectedIndex = ref<number | null>(null)
|
||||
/** 人工勾选仅针对当前关系或最终提交,切换操作时清空。 */
|
||||
const acknowledged = ref(false)
|
||||
/** 已收到成功回执的版本,服务端刷新前也不允许重复写入。 */
|
||||
const submittedId = ref('')
|
||||
/** 过期、关闭和卸载时取消只读预检查。 */
|
||||
/** 写入成功后等待页面拿到新版本,不能再次使用旧预检。 */
|
||||
const awaitingRefresh = ref(false)
|
||||
/** 正式原文核对的集号,不推断关系所属剧集。 */
|
||||
const sourceEpisode = ref<number | null>(null)
|
||||
/** 只读请求可取消,写操作不做自动重试。 */
|
||||
let controller: AbortController | undefined
|
||||
/** 拒绝忽略取消信号后返回的旧响应。 */
|
||||
/** 丢弃关闭、换项目、换版本后的异步回填。 */
|
||||
let version = 0
|
||||
/** 当前候选生成或提交后的面板。 */
|
||||
const isCandidate = computed(
|
||||
() => props.state?.candidateOnly === true && (props.quality.isCandidate || props.quality.committed)
|
||||
)
|
||||
/** 后端持久化标记优先,成功回执只在当前会话补充防重复锁。 */
|
||||
const committed = computed(
|
||||
() => props.quality.committed || submittedId.value === `${props.projectId}:${props.checkpointId}`
|
||||
)
|
||||
/** 审核通过后只允许请求预检查,绝不直接允许写入。 */
|
||||
/** 已提交状态以服务端当前标记为准,不虚构失败检查。 */
|
||||
const committed = computed(() => props.quality.committed || preview.value?.status === 'already_committed')
|
||||
/** 质量审核通过只是读取预检的前置条件。 */
|
||||
const canCheck = computed(
|
||||
() =>
|
||||
!props.disabled &&
|
||||
!operation.value.pending &&
|
||||
!committed.value &&
|
||||
!awaitingRefresh.value &&
|
||||
props.quality.canRequestCommitPreview &&
|
||||
props.quality.checkpointId === props.checkpointId
|
||||
)
|
||||
/** 逐项与版本确认后的预检查结果。 */
|
||||
/** 自身写入期间保留原按钮与加载反馈,其余操作仍遵守项目锁。 */
|
||||
const actionsVisible = computed(() => canCheck.value || writing.value)
|
||||
/** 只使用当前项目、当前版本且只读标记有效的未提交预检。 */
|
||||
const current = computed(() => {
|
||||
const result = preview.value
|
||||
return result &&
|
||||
result.status !== 'already_committed' &&
|
||||
result.readOnly === true &&
|
||||
result.projectId === props.projectId &&
|
||||
result.checkpointId === props.checkpointId
|
||||
? result
|
||||
: null
|
||||
})
|
||||
/** 全部门禁通过才能显示正式提交操作。 */
|
||||
const ready = computed(() => candidatePreviewReady(preview.value, props.projectId, props.checkpointId))
|
||||
/** 仅展示具体未通过的安全检查。 */
|
||||
/** 固定检查项缺失也视为未通过,不从返回字段动态缩减门禁。 */
|
||||
const failedChecks = computed(() =>
|
||||
preview.value
|
||||
? candidateCheckKeys.filter(key => preview.value!.checks?.[key] !== true).map(key => candidateCheckLabels[key])
|
||||
: []
|
||||
current.value ? candidateCheckKeys.filter(key => current.value!.checks?.[key] !== true) : []
|
||||
)
|
||||
/** 当前候选规模与正式资产区别标注。 */
|
||||
/** 原始关系只能来自本次安全预检,不解析问题字符串构造删除参数。 */
|
||||
const targets = computed(() => current.value?.relationRepairTargets ?? [])
|
||||
/** 用户选择的关系仍需校验完整且定位唯一。 */
|
||||
const selected = computed(() => (selectedIndex.value === null ? null : (targets.value[selectedIndex.value] ?? null)))
|
||||
/** 非空字段与唯一关系是写入前提,不裁剪原始提交值。 */
|
||||
const selectionIssue = computed(() => {
|
||||
const target = selected.value
|
||||
if (!target) return ''
|
||||
if (
|
||||
![target.subjectRef, target.relation, target.target, target.evidence].every(
|
||||
value => typeof value === 'string' && value.trim()
|
||||
)
|
||||
)
|
||||
return '这条关系缺少完整定位信息,请刷新预检。'
|
||||
return targets.value.filter(item => sameRelation(item, target)).length === 1
|
||||
? ''
|
||||
: '关系定位不唯一,请重新读取并核对。'
|
||||
})
|
||||
/** 修复只在当前剧本和规则未变、无活动任务时开放;资产保护仍由最终提交独立检查。 */
|
||||
const repairSafe = computed(() => !!current.value && repairConditions(current.value))
|
||||
/** 读取项目详情中的正式正文,不调用模型,也不虚构剧集查询接口。 */
|
||||
const episodeOptions = computed(() =>
|
||||
props.episodes.map(item => ({ value: item.episode, label: `第 ${item.episode} 集` }))
|
||||
)
|
||||
/** 用户选集后按原样显示完整正文。 */
|
||||
const sourceContent = computed(() => props.episodes.find(item => item.episode === sourceEpisode.value)?.content ?? '')
|
||||
/** 候选规模只用于说明替换范围。 */
|
||||
const counts = computed(() => ({
|
||||
subjects: props.state?.subjectCandidates?.length ?? 0,
|
||||
episodes: props.state?.storyboardEpisodeShots?.length ?? 0,
|
||||
shots:
|
||||
props.state?.storyboardEpisodeShots?.reduce(
|
||||
(sum, episode) => sum + episode.beatShots.reduce((total, beat) => total + beat.shots.length, 0),
|
||||
(sum, episode) => sum + episode.beatShots.reduce((n, beat) => n + beat.shots.length, 0),
|
||||
0
|
||||
) ?? 0
|
||||
}))
|
||||
|
||||
/** 撤销旧检查与确认,版本变化后不能复用提交许可。 */
|
||||
/**
|
||||
* 按后端四个精确定位字段比较关系,不改写证据。
|
||||
* @param left 待检查关系
|
||||
* @param right 用户核对的关系
|
||||
* @returns 是否为同一原始关系
|
||||
*/
|
||||
function sameRelation(left: CandidateRelationTarget, right: CandidateRelationTarget): boolean {
|
||||
return (
|
||||
left.subjectRef === right.subjectRef &&
|
||||
left.relation === right.relation &&
|
||||
left.target === right.target &&
|
||||
left.evidence === right.evidence
|
||||
)
|
||||
}
|
||||
/**
|
||||
* 关系修复依赖来源一致及无活动任务,不能以资产未生成代替任务锁。
|
||||
* @param result 最新只读预检
|
||||
* @returns 是否具备关系修复的来源与任务条件
|
||||
*/
|
||||
function repairConditions(result: CandidateCommitPreview): boolean {
|
||||
return (
|
||||
result.status !== 'already_committed' &&
|
||||
result.readOnly === true &&
|
||||
[
|
||||
'qualityPolicyMatches',
|
||||
'episodeNumbersMatch',
|
||||
'episodeFingerprintsMatch',
|
||||
'noActiveExecutions',
|
||||
'noActiveVideos'
|
||||
].every(key => result.checks?.[key as keyof typeof result.checks] === true)
|
||||
)
|
||||
}
|
||||
/** 撤销旧回执与人工勾选,关闭或版本改变后不能复用。 */
|
||||
function invalidate() {
|
||||
version++
|
||||
controller?.abort()
|
||||
checking.value = false
|
||||
preview.value = null
|
||||
confirmOpen.value = false
|
||||
selectedIndex.value = null
|
||||
acknowledged.value = false
|
||||
checkError.value = ''
|
||||
actionError.value = ''
|
||||
}
|
||||
/** 打开、换项目、换版本后重新读取;关闭时仅取消只读请求。 */
|
||||
watch(
|
||||
[
|
||||
() => props.projectId,
|
||||
() => props.checkpointId,
|
||||
() => props.quality.canRequestCommitPreview,
|
||||
() => props.quality.committed
|
||||
],
|
||||
invalidate,
|
||||
{ flush: 'sync' }
|
||||
)
|
||||
watch(
|
||||
() => props.disabled,
|
||||
disabled => {
|
||||
if (disabled && !committing.value) invalidate()
|
||||
}
|
||||
[open, () => props.projectId, () => props.checkpointId],
|
||||
([shown, id, cp], old) => {
|
||||
invalidate()
|
||||
if (!old || id !== old[1] || cp !== old[2]) {
|
||||
awaitingRefresh.value = false
|
||||
sourceEpisode.value = null
|
||||
}
|
||||
if (shown && canCheck.value) void check()
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
/** 外部任务或质量变化立即撤销旧许可,自身写入造成的锁不清空人工选择。 */
|
||||
watch([() => props.disabled, () => props.quality.canRequestCommitPreview, () => props.quality.committed], () => {
|
||||
if (writing.value) return
|
||||
if (!canCheck.value) invalidate()
|
||||
else if (open.value && !preview.value && !checking.value) void check()
|
||||
})
|
||||
/** 用户切换关系后必须重新明确勾选。 */
|
||||
watch(selectedIndex, () => {
|
||||
acknowledged.value = false
|
||||
})
|
||||
onScopeDispose(invalidate)
|
||||
|
||||
/** 安全检查通过后才展示最终确认;不调用任何写接口。 */
|
||||
/** 只读刷新安全预检,不自动删除关系或提交候选。 */
|
||||
async function check() {
|
||||
if (!canCheck.value || checking.value) return
|
||||
if (!open.value || !canCheck.value || writing.value || checking.value) return
|
||||
invalidate()
|
||||
const current = version
|
||||
const id = props.projectId
|
||||
const checkpointId = props.checkpointId
|
||||
const stamp = version,
|
||||
id = props.projectId,
|
||||
cp = props.checkpointId
|
||||
controller = new AbortController()
|
||||
checking.value = true
|
||||
try {
|
||||
const result = await breakdownApi.candidateCommitPreview(id, controller.signal)
|
||||
if (current !== version) return
|
||||
if (result.projectId !== id || result.checkpointId !== checkpointId || result.readOnly !== true)
|
||||
throw new Error('候选安全预检查已过期,请刷新后重新检查。')
|
||||
if (stamp !== version) return
|
||||
if (
|
||||
result.projectId !== id ||
|
||||
result.readOnly !== true ||
|
||||
(result.status !== 'already_committed' && result.checkpointId !== cp)
|
||||
)
|
||||
throw new Error('候选安全预检已过期,请刷新项目后重新检查。')
|
||||
preview.value = result
|
||||
if (candidatePreviewReady(result, id, checkpointId)) confirmOpen.value = true
|
||||
else showActionFeedback(message, '候选暂不能提交,请处理未通过的安全检查。', 'warning')
|
||||
if (result.status === 'already_committed') emit('refresh')
|
||||
} catch (cause) {
|
||||
if (current === version) {
|
||||
checkError.value = errorMessage(cause)
|
||||
showActionFeedback(message, checkError.value, 'error')
|
||||
if (stamp === version) {
|
||||
actionError.value = errorMessage(cause)
|
||||
showActionFeedback(message, actionError.value, 'error')
|
||||
}
|
||||
} finally {
|
||||
if (current === version) checking.value = false
|
||||
if (stamp === version) checking.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 取消最终确认时关闭弹窗并清除勾选,保留本次安全预检查结果。 */
|
||||
function cancelConfirmation() {
|
||||
confirmOpen.value = false
|
||||
acknowledged.value = false
|
||||
/** 刷新按钮同时恢复页面最新质量结论;等待新版本时不再检查旧保存记录。 */
|
||||
function refreshPreview() {
|
||||
if (writing.value) return
|
||||
emit('refresh')
|
||||
if (!awaitingRefresh.value) void check()
|
||||
}
|
||||
|
||||
/** 最终确认时重新核对版本和全部安全门禁,随后交由后端事务提交。 */
|
||||
/**
|
||||
* 写入前读取最新原始保存记录,避免历史回退和跨项目写入。
|
||||
* @param id 当前操作绑定的项目
|
||||
* @param cp 用户核对过的保存记录
|
||||
* @returns 当前版本核对完成
|
||||
*/
|
||||
async function assertCheckpoint(id: string, cp: string | undefined): Promise<void> {
|
||||
const records = await projectsApi.checkpoints(id)
|
||||
const latest = workflowCheckpoints(records, 'breakdown').at(-1)
|
||||
if (
|
||||
!cp ||
|
||||
latest?.checkpointId !== cp ||
|
||||
latest.state.storyboardPersisted ||
|
||||
latest.state.candidateCommitted ||
|
||||
props.projectId !== id ||
|
||||
props.checkpointId !== cp ||
|
||||
!open.value
|
||||
)
|
||||
throw new Error('拆解候选版本已变化或已经提交,请刷新后重新确认。')
|
||||
}
|
||||
/** 用户明确确认后只移除一条当前仍无来源的关系,成功后等待新版本重新预检。 */
|
||||
async function repairRelation() {
|
||||
if (
|
||||
!canCheck.value ||
|
||||
!repairSafe.value ||
|
||||
!selected.value ||
|
||||
selectionIssue.value ||
|
||||
!acknowledged.value ||
|
||||
writing.value ||
|
||||
checking.value
|
||||
)
|
||||
return
|
||||
const id = props.projectId,
|
||||
cp = props.checkpointId,
|
||||
target = { ...selected.value },
|
||||
stamp = version
|
||||
let stale = false
|
||||
writing.value = true
|
||||
actionError.value = ''
|
||||
const ok = await runOperation(
|
||||
id,
|
||||
'正在移除无来源关系',
|
||||
async () => {
|
||||
try {
|
||||
await assertCheckpoint(id, cp)
|
||||
} catch (cause) {
|
||||
stale = true
|
||||
throw cause
|
||||
}
|
||||
const checked = await breakdownApi.candidateCommitPreview(id)
|
||||
if (
|
||||
stamp !== version ||
|
||||
checked.projectId !== id ||
|
||||
checked.checkpointId !== cp ||
|
||||
!props.quality.canRequestCommitPreview ||
|
||||
!repairConditions(checked) ||
|
||||
checked.status === 'already_committed' ||
|
||||
checked.relationRepairTargets?.filter(item => sameRelation(item, target)).length !== 1 ||
|
||||
props.projectId !== id ||
|
||||
props.checkpointId !== cp ||
|
||||
!open.value
|
||||
) {
|
||||
stale = true
|
||||
throw new Error('关系、来源或任务状态已变化,请重新预检后确认。')
|
||||
}
|
||||
const result = await breakdownApi.repairCandidateRelation(id, {
|
||||
confirmed: true,
|
||||
expectedCheckpointId: cp!,
|
||||
subjectRef: target.subjectRef,
|
||||
relation: target.relation,
|
||||
target: target.target,
|
||||
evidence: target.evidence
|
||||
})
|
||||
if (
|
||||
result.removed !== 1 ||
|
||||
result.subjectRef !== target.subjectRef ||
|
||||
!result.checkpointId ||
|
||||
result.checkpointId === cp
|
||||
)
|
||||
throw new Error('关系处理结果尚未确认,请重新读取最新结果。')
|
||||
return result
|
||||
},
|
||||
{ type: 'info', content: '已移除这条候选关系,正在重新读取预检;正式结果尚未提交。' }
|
||||
)
|
||||
writing.value = false
|
||||
if (props.projectId !== id || stamp !== version) return
|
||||
const failure = operation.value.error
|
||||
const conflict = operation.value.cause instanceof ApiError && operation.value.cause.status === 409
|
||||
acknowledged.value = false
|
||||
if (ok || stale || conflict) {
|
||||
invalidate()
|
||||
awaitingRefresh.value = ok
|
||||
emit('refresh')
|
||||
}
|
||||
actionError.value = failure
|
||||
}
|
||||
/** 全部门禁通过且用户单独确认后,再次核对版本与预检,随后正式采用候选。 */
|
||||
async function commit() {
|
||||
if (!canCheck.value || !ready.value || !confirmOpen.value || !acknowledged.value || committing.value) return
|
||||
const id = props.projectId
|
||||
const checkpointId = props.checkpointId
|
||||
const checkedVersion = version
|
||||
committing.value = true
|
||||
if (!canCheck.value || !ready.value || selected.value || !acknowledged.value || writing.value || checking.value)
|
||||
return
|
||||
const id = props.projectId,
|
||||
cp = props.checkpointId,
|
||||
stamp = version
|
||||
writing.value = true
|
||||
actionError.value = ''
|
||||
const ok = await runOperation(
|
||||
id,
|
||||
'正在提交拆解候选',
|
||||
async () => {
|
||||
const records = await projectsApi.checkpoints(id)
|
||||
const latest = workflowCheckpoints(records, 'breakdown').at(-1)
|
||||
if (
|
||||
!checkpointId ||
|
||||
latest?.checkpointId !== checkpointId ||
|
||||
latest.state.storyboardPersisted ||
|
||||
latest.state.candidateCommitted ||
|
||||
props.projectId !== id ||
|
||||
props.checkpointId !== checkpointId
|
||||
)
|
||||
throw new Error('拆解候选版本已变化或已经提交,请刷新后重新确认。')
|
||||
await assertCheckpoint(id, cp)
|
||||
const checked = await breakdownApi.candidateCommitPreview(id)
|
||||
if (
|
||||
checkedVersion !== version ||
|
||||
!props.quality.canRequestCommitPreview ||
|
||||
!candidatePreviewReady(checked, id, checkpointId) ||
|
||||
props.projectId !== id ||
|
||||
props.checkpointId !== checkpointId
|
||||
)
|
||||
if (stamp !== version || !props.quality.canRequestCommitPreview || !candidatePreviewReady(checked, id, cp))
|
||||
throw new Error('提交安全条件已变化,请重新检查候选。')
|
||||
const receipt = await breakdownApi.commitCandidate(id)
|
||||
if (receipt.projectId !== id) throw new Error('提交回执所属项目不一致,请刷新确认。')
|
||||
@@ -187,95 +347,174 @@ async function commit() {
|
||||
content: `拆解结果已保存并采用:${receipt.subjectCount} 个主体、${receipt.episodeCount} 集、${receipt.shotCount} 个镜头。`
|
||||
})
|
||||
)
|
||||
if (props.projectId === id) {
|
||||
if (ok) submittedId.value = `${id}:${checkpointId}`
|
||||
invalidate()
|
||||
emit('refresh')
|
||||
}
|
||||
committing.value = false
|
||||
writing.value = false
|
||||
if (props.projectId !== id || stamp !== version) return
|
||||
const failure = operation.value.error
|
||||
invalidate()
|
||||
awaitingRefresh.value = false
|
||||
actionError.value = failure
|
||||
if (ok) open.value = false
|
||||
emit('refresh')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是候选质量与安全提交模块,不使用只读审核结果替代事务门禁 -->
|
||||
<section
|
||||
v-if="isCandidate"
|
||||
class="workspace-panel space-y-4"
|
||||
:class="{ 'breakdown-candidate-committed': committed }"
|
||||
aria-label="拆解候选"
|
||||
<!-- 以下是与拆解设置分离的安全预检及关系问题处理全屏抽屉 -->
|
||||
<AppDrawer
|
||||
v-model:open="open"
|
||||
title="候选安全预检"
|
||||
:busy="writing"
|
||||
description="核对剧本来源、活动任务和已有制作成果。无来源关系需逐条人工确认;全部预检通过后再确认采用正式结果。"
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">{{ committed ? '拆解结果已保存并采用' : '待确认的拆解候选' }}</h3>
|
||||
<span class="text-xs text-muted"
|
||||
>{{ committed ? '正式主体' : '候选主体' }} {{ counts.subjects }} · {{ counts.episodes }} 集 ·
|
||||
{{ counts.shots }} 镜</span
|
||||
>
|
||||
</div>
|
||||
<p class="text-xs leading-6 text-muted">
|
||||
{{
|
||||
committed
|
||||
? '本次拆解出的人物、场景、道具和分镜已保存,后续制作会使用这份结果。'
|
||||
: '候选尚未写入正式资产,质量审核后还需通过安全预检查。'
|
||||
}}
|
||||
</p>
|
||||
<p v-if="!committed" class="text-xs text-muted" role="status">
|
||||
{{
|
||||
quality.loading
|
||||
? '正在重新审核当前候选…'
|
||||
: quality.needsRefresh
|
||||
? '这份拆解结果的检查状态尚未确认,请点击“重新检查”。'
|
||||
: quality.canRequestCommitPreview
|
||||
? '候选质量审核通过,可执行提交安全预检查。'
|
||||
: '候选仍有待处理问题,请先修订。'
|
||||
}}
|
||||
</p>
|
||||
<!-- 以下是尚未采用结果的检查与确认操作,采用后不再显示操作区域 -->
|
||||
<div v-if="!committed" class="flex flex-wrap items-center gap-3">
|
||||
<NButton :disabled="!canCheck" :loading="checking || committing" @click="check">提交候选为正式结果</NButton>
|
||||
<WorkspaceRefreshButton
|
||||
label="重新检查"
|
||||
:loading="quality.loading"
|
||||
:disabled="operation.pending || checking"
|
||||
@refresh="emit('refresh')"
|
||||
/>
|
||||
</div>
|
||||
<section v-if="failedChecks.length" class="problem-surface p-4" aria-label="未通过的提交安全检查">
|
||||
<p class="mb-2 text-sm">提交安全检查未通过</p>
|
||||
<ul class="list-inside list-disc space-y-2 text-xs">
|
||||
<li v-for="label in failedChecks" :key="label">{{ label }}</li>
|
||||
</ul>
|
||||
</section>
|
||||
<p v-if="checkError" class="text-xs text-danger" role="alert">{{ checkError }}</p>
|
||||
<!-- 以下是通过只读预检查后才出现的最终确认,取消和关闭撤销确认 -->
|
||||
<AppDialog
|
||||
v-model:open="confirmOpen"
|
||||
title="确认提交候选为正式结果"
|
||||
:busy="committing"
|
||||
description="将替换正式主体、形态与分镜。保存时还会检查剧本是否变化,以及已有制作成果是否受到影响。"
|
||||
>
|
||||
<p class="text-sm">
|
||||
本次候选:{{ counts.subjects }} 个主体、{{ counts.episodes }} 集、{{ counts.shots }} 个镜头。
|
||||
<div class="space-y-6" :aria-busy="checking">
|
||||
<p v-if="checking" role="status" class="text-sm text-muted">正在读取安全预检…</p>
|
||||
<p v-else-if="committed" role="status" class="text-sm">已提交正式结果,请以页面最新结果为准。</p>
|
||||
<p v-else-if="awaitingRefresh" role="status" class="text-sm text-muted">
|
||||
正在等待最新保存记录,请刷新状态后继续核对。
|
||||
</p>
|
||||
<NCheckbox v-model:checked="acknowledged" class="mt-5"
|
||||
>我已确认替换正式结果,当前没有同项目的制作任务在运行。</NCheckbox
|
||||
>
|
||||
<template #footer
|
||||
><NButton :disabled="committing" @click="cancelConfirmation">取消</NButton
|
||||
><NButton
|
||||
type="primary"
|
||||
:loading="committing"
|
||||
:disabled="!acknowledged || !ready || !canCheck"
|
||||
@click="commit"
|
||||
>确认提交候选为正式结果</NButton
|
||||
></template
|
||||
>
|
||||
</AppDialog>
|
||||
</section>
|
||||
<p v-else-if="!canCheck && !current" role="status" class="text-sm text-muted">
|
||||
当前任务或候选审核状态尚未满足预检条件,请刷新状态。
|
||||
</p>
|
||||
<p v-if="actionError" role="alert" class="text-sm text-danger">{{ actionError }}</p>
|
||||
<template v-if="current && !committed">
|
||||
<!-- 以下是当前候选规模与后端逐项预检结果,不把候选审核当作提交许可 -->
|
||||
<section class="space-y-4" aria-label="候选提交预检">
|
||||
<WorkspaceSectionHeading
|
||||
title="提交安全检查"
|
||||
:description="`候选主体 ${counts.subjects} · ${counts.episodes} 集 · ${counts.shots} 个镜头`"
|
||||
/>
|
||||
<NTag :type="ready ? 'success' : 'warning'" :bordered="false">{{
|
||||
ready ? '安全预检通过,等待人工确认采用' : '安全预检未通过'
|
||||
}}</NTag>
|
||||
<section
|
||||
v-if="failedChecks.length"
|
||||
class="problem-surface p-4 space-y-3"
|
||||
aria-label="未通过的提交安全检查"
|
||||
>
|
||||
<p class="text-sm">以下条件尚未满足:</p>
|
||||
<ul class="list-inside list-disc space-y-2 text-sm">
|
||||
<li v-for="key in failedChecks" :key="key">{{ candidateCheckLabels[key] }}</li>
|
||||
</ul>
|
||||
</section>
|
||||
</section>
|
||||
<!-- 以下是后端返回的关系问题与正式原文,窄屏自然改为单列 -->
|
||||
<div v-if="targets.length || current.relationIssues?.length" class="grid min-w-0 gap-6 lg:grid-cols-2">
|
||||
<section class="min-w-0 space-y-4" aria-label="无来源关系">
|
||||
<WorkspaceSectionHeading
|
||||
title="核对关系来源"
|
||||
description="移除仅影响这条候选关系,不删除主体或镜头,也不会改写剧本。每次处理一条。"
|
||||
/>
|
||||
<article
|
||||
v-for="(item, index) in targets"
|
||||
:key="index"
|
||||
class="problem-surface p-4 space-y-3 min-w-0 wrap-anywhere"
|
||||
>
|
||||
<h3 class="text-sm font-medium">
|
||||
{{ item.subjectName }} · {{ item.relation }} → {{ item.target }}
|
||||
</h3>
|
||||
<p class="text-xs text-muted">候选引用:{{ item.subjectRef }}</p>
|
||||
<p class="text-sm text-muted">原始来源证据</p>
|
||||
<blockquote class="whitespace-pre-wrap text-sm leading-7">{{ item.evidence }}</blockquote>
|
||||
<NRadio
|
||||
:checked="selectedIndex === index"
|
||||
:disabled="writing || checking || !canCheck || !repairSafe"
|
||||
@update:checked="selectedIndex = index"
|
||||
>核对后移除这条无来源关系</NRadio
|
||||
>
|
||||
</article>
|
||||
<p v-if="!targets.length" class="text-sm text-muted">当前未提供可定位的关系,请刷新预检。</p>
|
||||
<NCollapse v-if="current.relationIssues?.length"
|
||||
><NCollapseItem name="details" title="关系检查详情">
|
||||
<p
|
||||
v-for="(issue, index) in current.relationIssues"
|
||||
:key="index"
|
||||
class="text-sm leading-7 wrap-anywhere"
|
||||
>
|
||||
{{ issue }}
|
||||
</p>
|
||||
</NCollapseItem></NCollapse
|
||||
>
|
||||
<p v-if="selectionIssue" role="alert" class="text-sm text-danger">{{ selectionIssue }}</p>
|
||||
<NButton
|
||||
v-if="selected"
|
||||
class="workspace-action-button"
|
||||
:disabled="writing"
|
||||
@click="selectedIndex = null"
|
||||
>取消选择</NButton
|
||||
>
|
||||
</section>
|
||||
<!-- 以下是复用项目详情的正式原文,不推断问题所属集数 -->
|
||||
<section class="min-w-0 space-y-4" aria-label="正式剧本核对">
|
||||
<NCollapse :default-expanded-names="['source']"
|
||||
><NCollapseItem name="source" title="正式剧本原文">
|
||||
<div class="space-y-4">
|
||||
<NSelect
|
||||
v-model:value="sourceEpisode"
|
||||
:options="episodeOptions"
|
||||
aria-label="选择核对剧集"
|
||||
placeholder="选择需要核对的剧集"
|
||||
:disabled="!episodeOptions.length"
|
||||
/>
|
||||
<pre
|
||||
class="max-h-[60dvh] overflow-auto whitespace-pre-wrap wrap-anywhere p-4 text-sm leading-7 bg-(--app-control)"
|
||||
>{{
|
||||
sourceContent ||
|
||||
(episodeOptions.length
|
||||
? '请选择需要核对的剧集。'
|
||||
: '当前没有可核对的正式正文。')
|
||||
}}</pre>
|
||||
</div>
|
||||
</NCollapseItem></NCollapse
|
||||
>
|
||||
</section>
|
||||
</div>
|
||||
<p v-if="ready" class="text-sm leading-7 text-muted">
|
||||
采用候选将替换正式主体、形态与分镜。保存时还会检查剧本变化及已有制作成果,关系修复不会自动执行这一步。
|
||||
</p>
|
||||
</template>
|
||||
</div>
|
||||
<!-- 以下是固定底栏:关系移除与正式采用分别明确确认,禁止重复写入 -->
|
||||
<template #footer>
|
||||
<div class="flex w-full flex-wrap items-center justify-between gap-4">
|
||||
<NCheckbox
|
||||
v-if="actionsVisible && !checking && ((selected && !selectionIssue && repairSafe) || ready)"
|
||||
v-model:checked="acknowledged"
|
||||
:disabled="writing"
|
||||
class="min-w-0 flex-[1_1_360px]"
|
||||
>
|
||||
{{
|
||||
selected
|
||||
? '我已核对原文,确认仅移除所选候选关系。'
|
||||
: '我已核对预检结果,确认替换正式主体、形态与分镜。'
|
||||
}}
|
||||
</NCheckbox>
|
||||
<div class="ml-auto flex flex-wrap items-center justify-end gap-2">
|
||||
<NButton :disabled="writing" @click="open = false">关闭</NButton>
|
||||
<WorkspaceRefreshButton
|
||||
label="刷新预检"
|
||||
:loading="checking"
|
||||
:disabled="writing || operation.pending"
|
||||
@refresh="refreshPreview"
|
||||
/>
|
||||
<NButton
|
||||
v-if="selected && !selectionIssue && repairSafe && actionsVisible"
|
||||
type="primary"
|
||||
:loading="writing"
|
||||
:disabled="!acknowledged || checking || writing"
|
||||
@click="repairRelation"
|
||||
>
|
||||
<template #icon><Trash2 :size="15" aria-hidden="true" /></template>确认移除这条关系
|
||||
</NButton>
|
||||
<NButton
|
||||
v-else-if="ready && actionsVisible"
|
||||
type="primary"
|
||||
:loading="writing"
|
||||
:disabled="!acknowledged || checking || writing"
|
||||
@click="commit"
|
||||
>确认提交候选为正式结果</NButton
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 只表达结果已成功保存并采用,未采用时保留默认底色,质量审核结论仍独立展示。 */
|
||||
.workspace-panel.breakdown-candidate-committed {
|
||||
background: var(--app-success-soft);
|
||||
}
|
||||
</style>
|
||||
@@ -22,10 +22,11 @@ import {
|
||||
NTag,
|
||||
type ScrollbarInst
|
||||
} from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { computed, inject, ref, watch } from 'vue'
|
||||
import { useRoute, useRouter, type LocationQueryRaw } from 'vue-router'
|
||||
import { Check, Circle, UserCheck } from '@lucide/vue'
|
||||
import { DirectoryItem, EmptyState, StatusBadge } from '../../components/ui'
|
||||
import { AppDialog, DirectoryItem, EmptyState, StatusBadge } from '../../components/ui'
|
||||
import { projectSettingsOpenKey } from '../generation-config/context'
|
||||
import { downloadText } from '../../lib/format'
|
||||
import ConfirmAction from '../workflows/ConfirmAction.vue'
|
||||
import { castingStatusLabel, currentAnchor } from './model'
|
||||
@@ -74,6 +75,8 @@ const {
|
||||
canGenerateText,
|
||||
canGenerateImage,
|
||||
canGenerateCandidate,
|
||||
canRequestImage,
|
||||
canRequestCandidate,
|
||||
activeIdentityGeneration,
|
||||
batchValid,
|
||||
candidateLimitValid,
|
||||
@@ -294,6 +297,59 @@ function retryIdentityImage(imageId: string) {
|
||||
}
|
||||
/** 批量操作抽屉显隐状态,新回执到达时自动打开以展示结果。 */
|
||||
const toolsOpen = ref(false)
|
||||
/** 缺少模型时只展示轻量引导,不保存配置或启动生成。 */
|
||||
const modelPromptOpen = ref(false)
|
||||
/** 复用右上角已有项目配置抽屉。 */
|
||||
const openProjectSettings = inject(projectSettingsOpenKey, undefined)
|
||||
/** 从批量抽屉交接到提示弹窗时绑定当前项目。 */
|
||||
const pendingModelProject = ref('')
|
||||
/** 提示关闭后才打开现有配置抽屉,避免焦点叠加。 */
|
||||
const pendingConfigProject = ref('')
|
||||
/** 批量生图同样等待真实配置读取,读取失败不能当作尚未配置。 */
|
||||
const modelQueryBlocked = computed(
|
||||
() => !profileQuery.data.value || profileQuery.loading.value || !!profileQuery.error.value
|
||||
)
|
||||
/**
|
||||
* 共用的生图前置检查,仅缺少配置时显示引导,不默认接受费用。
|
||||
* @returns 是否可以继续打开生成参数或费用确认
|
||||
*/
|
||||
function ensureGenerationProfile(): boolean {
|
||||
if (blocked.value || modelQueryBlocked.value) return false
|
||||
if (hasCreativeProfile.value) return true
|
||||
if (toolsOpen.value) {
|
||||
pendingModelProject.value = projectId.value
|
||||
toolsOpen.value = false
|
||||
} else modelPromptOpen.value = true
|
||||
return false
|
||||
}
|
||||
/**
|
||||
* 单主体共用生图入口,先检查配置,再显示原有生成表单。
|
||||
* @param target 当前用户选择的图片生成类型
|
||||
*/
|
||||
function requestImage(target: 'image' | 'casting' | 'quality') {
|
||||
if (!(target === 'casting' ? canRequestCandidate.value : canRequestImage.value) || !ensureGenerationProfile())
|
||||
return
|
||||
if (target === 'casting') castingOpen.value = true
|
||||
else if (target === 'quality') qualityOpen.value = true
|
||||
else imageOpen.value = true
|
||||
}
|
||||
/** 用户主动前往配置,先关闭当前提示,原操作不会自动恢复执行。 */
|
||||
function requestProjectConfig() {
|
||||
pendingConfigProject.value = projectId.value
|
||||
modelPromptOpen.value = false
|
||||
}
|
||||
/** 提示完全离场后交给右上角同一个项目配置抽屉。 */
|
||||
function finishModelPrompt() {
|
||||
const id = pendingConfigProject.value
|
||||
pendingConfigProject.value = ''
|
||||
if (id && id === projectId.value) openProjectSettings?.('generation')
|
||||
}
|
||||
/** 切项目时废弃旧的配置交接。 */
|
||||
watch(projectId, () => {
|
||||
modelPromptOpen.value = false
|
||||
pendingModelProject.value = ''
|
||||
pendingConfigProject.value = ''
|
||||
})
|
||||
/** 角色卡片的切换目标,等抽屉离场后再交给详情页处理草稿确认。 */
|
||||
const overviewSelection = ref('')
|
||||
/**
|
||||
@@ -306,6 +362,11 @@ function selectFromOverview(id: string) {
|
||||
}
|
||||
/** 抽屉关闭后显示目标角色,清除可能隐藏该角色的目录筛选并保留草稿确认。 */
|
||||
function finishOverviewSelection() {
|
||||
if (pendingModelProject.value) {
|
||||
const project = pendingModelProject.value
|
||||
pendingModelProject.value = ''
|
||||
if (project === projectId.value) modelPromptOpen.value = true
|
||||
}
|
||||
const id = overviewSelection.value
|
||||
overviewSelection.value = ''
|
||||
if (!subjects.value.some(item => item.id === id && item.module === 'character')) return
|
||||
@@ -365,7 +426,7 @@ const nextAction = computed<{ action: IdentityFlowAction; title: string; descrip
|
||||
return {
|
||||
action: 'profile',
|
||||
title: '先配置生成模型',
|
||||
description: '选择项目图片与视频模型后才能生图。',
|
||||
description: '请点击右上角“项目配置”,选择图片与视频模型后再生成身份图。',
|
||||
label: '配置生成模型'
|
||||
}
|
||||
if (!identityTextReady.value)
|
||||
@@ -414,18 +475,11 @@ const nextAction = computed<{ action: IdentityFlowAction; title: string; descrip
|
||||
}
|
||||
})
|
||||
|
||||
/** 原配置恢复入口打开标题栏共用的全局配置弹窗。 */
|
||||
function openProfileSettings() {
|
||||
if (route.query.configure !== 'profile') void router.replace({ query: { ...route.query, configure: 'profile' } })
|
||||
}
|
||||
|
||||
/** 下一步引导定位单张图片或打开多候选管理,形态图片跳转遵守项目准入规则。 */
|
||||
function runNextAction() {
|
||||
if (nextAction.value.action === 'style') void router.push(`/projects/${projectId.value}/visual-style`)
|
||||
else if (nextAction.value.action === 'profile') openProfileSettings()
|
||||
else if (nextAction.value.action === 'candidate') {
|
||||
if (subject.value?.module === 'character') castingOpen.value = true
|
||||
else imageOpen.value = true
|
||||
requestImage(subject.value?.module === 'character' ? 'casting' : 'image')
|
||||
} else if (nextAction.value.action === 'confirm') {
|
||||
document.querySelector('#identity-reference-gallery')?.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||
} else if (nextAction.value.action === 'lock') {
|
||||
@@ -568,8 +622,10 @@ function runNextAction() {
|
||||
<ConfirmAction
|
||||
:loading="isOperationRunning(operation, '批量生成角色选角候选')"
|
||||
label="批量生成角色候选图"
|
||||
:before-open="ensureGenerationProfile"
|
||||
:disabled="
|
||||
castingBlocked ||
|
||||
modelQueryBlocked ||
|
||||
!hasStyle ||
|
||||
!batchValid ||
|
||||
!candidateLimitValid ||
|
||||
@@ -619,8 +675,10 @@ function runNextAction() {
|
||||
<ConfirmAction
|
||||
:loading="isOperationRunning(operation, '批量生成场景身份母版')"
|
||||
label="生成场景母版"
|
||||
:before-open="ensureGenerationProfile"
|
||||
:disabled="
|
||||
blocked ||
|
||||
modelQueryBlocked ||
|
||||
!hasStyle ||
|
||||
!batchValid ||
|
||||
!candidateLimitValid ||
|
||||
@@ -634,8 +692,14 @@ function runNextAction() {
|
||||
<ConfirmAction
|
||||
:loading="isOperationRunning(operation, '批量生成道具身份母版')"
|
||||
label="生成道具母版"
|
||||
:before-open="ensureGenerationProfile"
|
||||
:disabled="
|
||||
blocked || !hasStyle || !batchValid || dirty || !subjects.length
|
||||
blocked ||
|
||||
modelQueryBlocked ||
|
||||
!hasStyle ||
|
||||
!batchValid ||
|
||||
dirty ||
|
||||
!subjects.length
|
||||
"
|
||||
acknowledgement
|
||||
:description="`最多处理 ${candidateLimit} 个道具,可能产生图片生成与质量校验费用。通过校验后自动设为母版并锁定,可能替换尚未锁定的已有母版;已锁定且有有效母版的道具会跳过。`"
|
||||
@@ -748,17 +812,6 @@ function runNextAction() {
|
||||
>
|
||||
</ContextNotice></NScrollbar
|
||||
>
|
||||
<ContextNotice
|
||||
v-if="profileQuery.data.value && !hasCreativeProfile"
|
||||
type="warning"
|
||||
:show-icon="false"
|
||||
class="identity-prerequisite"
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<span><strong>需要先配置项目生成模型</strong>,否则身份图和选角候选无法生成。</span>
|
||||
<NButton type="primary" @click="openProfileSettings">立即配置</NButton>
|
||||
</div>
|
||||
</ContextNotice>
|
||||
<div v-if="subjects.length" class="identity-workspace-region">
|
||||
<!-- 以下是与分镜一致的融合工作区模块,目录与详情共用外层背景。 -->
|
||||
<div class="panel workspace-surface directory-workspace identity-workspace">
|
||||
@@ -866,7 +919,7 @@ function runNextAction() {
|
||||
<span>{{ index + 1 }}. {{ step.label }}</span>
|
||||
</li>
|
||||
</ol>
|
||||
<div class="identity-next-action">
|
||||
<div v-if="nextAction.action !== 'profile'" class="identity-next-action">
|
||||
<div>
|
||||
<strong>{{ nextAction.title }}</strong>
|
||||
<p>{{ nextAction.description }}</p>
|
||||
@@ -938,17 +991,17 @@ function runNextAction() {
|
||||
<template #actions>
|
||||
<NButton
|
||||
v-if="subject.module === 'scene' || subject.module === 'prop'"
|
||||
:disabled="!canGenerateImage"
|
||||
@click="qualityOpen = true"
|
||||
:disabled="!canRequestImage"
|
||||
@click="requestImage('quality')"
|
||||
>生成稳定母版并校验质量</NButton
|
||||
>
|
||||
<NButton
|
||||
v-if="subject.module === 'character'"
|
||||
:disabled="!canGenerateCandidate"
|
||||
@click="castingOpen = true"
|
||||
:disabled="!canRequestCandidate"
|
||||
@click="requestImage('casting')"
|
||||
>{{ anchor ? '再生成一张候选' : 'AI 生成角色候选图' }}</NButton
|
||||
>
|
||||
<NButton :disabled="!canGenerateImage" @click="imageOpen = true">
|
||||
<NButton :disabled="!canRequestImage" @click="requestImage('image')">
|
||||
{{
|
||||
subject.module === 'character'
|
||||
? '生成辅助参考图'
|
||||
@@ -1028,6 +1081,19 @@ function runNextAction() {
|
||||
:disabled="!canGenerateCandidate"
|
||||
@generate="submitCastingCandidate"
|
||||
/></WorkspacePage>
|
||||
<!-- 以下是点击生图时才展示的模型配置引导,关闭后交给唯一项目配置抽屉 -->
|
||||
<AppDialog v-model:open="modelPromptOpen" title="需要配置生成模型" status="warning" @closed="finishModelPrompt">
|
||||
<!-- 以下是独立于标题的配置引导正文,沿用公共弹窗内容与底栏间距 -->
|
||||
<p class="text-sm leading-7 text-muted">
|
||||
请在右上角“项目配置”中选择图片与视频模型。配置保存后,请重新点击需要的生成操作;本次尚未生成,也未产生费用。
|
||||
</p>
|
||||
<template #footer>
|
||||
<NButton @click="modelPromptOpen = false">取消</NButton>
|
||||
<NButton type="primary" :disabled="!openProjectSettings" @click="requestProjectConfig"
|
||||
>前往项目配置</NButton
|
||||
>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
|
||||
@@ -162,25 +162,33 @@ export function useSubjectIdentity() {
|
||||
const canGenerateText = computed(
|
||||
() => !detailBlocked.value && hasStyle.value && !identity.value?.isLocked && !dirty.value
|
||||
)
|
||||
const canGenerateImage = computed(
|
||||
/** 图片入口允许先核对配置;任务、来源、正文和草稿限制仍然有效。 */
|
||||
const canRequestImage = computed(
|
||||
() =>
|
||||
!detailBlocked.value &&
|
||||
hasStyle.value &&
|
||||
hasCreativeProfile.value &&
|
||||
!!profileQuery.data.value &&
|
||||
!profileQuery.error.value &&
|
||||
!profileQuery.loading.value &&
|
||||
!!identity.value?.generationPrompt?.trim() &&
|
||||
!dirty.value
|
||||
)
|
||||
/** 真正生成仍必须具备正式保存的模型配置。 */
|
||||
const canGenerateImage = computed(() => canRequestImage.value && hasCreativeProfile.value)
|
||||
const activeIdentityGeneration = computed(() =>
|
||||
images.value.find(image => image.status === 'pending' || image.status === 'generating')
|
||||
)
|
||||
const canGenerateCandidate = computed(
|
||||
/** 角色候选入口与正式生成共用选角和活动图片限制,缺配置时先引导。 */
|
||||
const canRequestCandidate = computed(
|
||||
() =>
|
||||
canGenerateImage.value &&
|
||||
canRequestImage.value &&
|
||||
subject.value?.module === 'character' &&
|
||||
!!castingQuery.data.value &&
|
||||
!castingQuery.error.value &&
|
||||
!activeIdentityGeneration.value
|
||||
)
|
||||
/** 角色图片写入不会因为入口可点击而绕过模型配置。 */
|
||||
const canGenerateCandidate = computed(() => canRequestCandidate.value && hasCreativeProfile.value)
|
||||
const batchValid = computed(() => Number.isSafeInteger(concurrency.value) && concurrency.value > 0)
|
||||
const candidateLimitValid = computed(() => Number.isSafeInteger(candidateLimit.value) && candidateLimit.value > 0)
|
||||
const castingBlocked = computed(
|
||||
@@ -438,6 +446,7 @@ export function useSubjectIdentity() {
|
||||
castingBlocked.value ||
|
||||
!!catalog.data.value?.running ||
|
||||
!hasStyle.value ||
|
||||
!hasCreativeProfile.value ||
|
||||
!batchValid.value ||
|
||||
!candidateLimitValid.value ||
|
||||
!castingQuery.data.value?.missingAnchor
|
||||
@@ -692,6 +701,8 @@ export function useSubjectIdentity() {
|
||||
canGenerateText,
|
||||
canGenerateImage,
|
||||
canGenerateCandidate,
|
||||
canRequestImage,
|
||||
canRequestCandidate,
|
||||
activeIdentityGeneration,
|
||||
batchValid,
|
||||
candidateLimitValid,
|
||||
|
||||
@@ -7,8 +7,10 @@ import { AppDialog } from '../../components/ui'
|
||||
const props = defineProps<{
|
||||
/** 操作名称。 */
|
||||
label: string
|
||||
/** 确认前的操作说明。 */
|
||||
/** 正文中的完整操作说明,费用、范围与覆盖影响不能只放在标题描述中。 */
|
||||
description: string
|
||||
/** 费用与覆盖确认默认警告;调用方可按真实语义使用默认、成功或错误状态。 */
|
||||
status?: 'default' | 'warning' | 'success' | 'error'
|
||||
/** 前置条件未满足时禁止操作。 */
|
||||
disabled?: boolean
|
||||
/** 当前操作请求是否仍在执行。 */
|
||||
@@ -17,6 +19,8 @@ const props = defineProps<{
|
||||
acknowledgement?: boolean
|
||||
/** 是否使用主要操作样式。 */
|
||||
primary?: boolean
|
||||
/** 打开费用确认前的同步校验;返回 false 时由调用方展示必要的前置引导。 */
|
||||
beforeOpen?: () => boolean
|
||||
}>()
|
||||
/** 用户明确确认操作后通知调用方。 */
|
||||
const emit = defineEmits<{ confirm: [] }>()
|
||||
@@ -24,6 +28,11 @@ const emit = defineEmits<{ confirm: [] }>()
|
||||
const open = ref(false)
|
||||
/** 用户是否确认任务与费用。 */
|
||||
const acknowledged = ref(false)
|
||||
/** 前置条件通过后才展示费用确认,不执行真实生成。 */
|
||||
function requestOpen() {
|
||||
if (props.disabled || props.loading || props.beforeOpen?.() === false) return
|
||||
open.value = true
|
||||
}
|
||||
|
||||
/** 取消后重新打开,或确认目标改变,都必须重新确认任务与费用。 */
|
||||
watch([open, () => props.label, () => props.description], () => {
|
||||
@@ -42,7 +51,7 @@ function confirm() {
|
||||
<template>
|
||||
<span class="confirm-action">
|
||||
<!-- 稳定的根元素承接调用方间距;AppDialog 含多个根节点,不能替按钮接收 class。 -->
|
||||
<AppDialog v-model:open="open" :title="label" :description="description">
|
||||
<AppDialog v-model:open="open" :title="label" :status="status ?? 'warning'">
|
||||
<template #trigger
|
||||
><NButton
|
||||
:type="primary ? 'primary' : 'default'"
|
||||
@@ -50,10 +59,12 @@ function confirm() {
|
||||
:loading="loading"
|
||||
:aria-label="label"
|
||||
:aria-busy="!!loading"
|
||||
@click="open = true"
|
||||
@click="requestOpen"
|
||||
>{{ label }}</NButton
|
||||
></template
|
||||
>
|
||||
<!-- 以下是必读操作说明正文,未启用勾选确认时也保留完整内容 -->
|
||||
<p class="text-sm leading-7 text-muted">{{ description }}</p>
|
||||
<NCheckbox
|
||||
v-model:checked="acknowledged"
|
||||
v-if="acknowledgement"
|
||||
|
||||
@@ -513,7 +513,26 @@ describe('管理后台组件边界', () => {
|
||||
expect(wrapper.find('.project-header .n-tag').exists()).toBe(false)
|
||||
})
|
||||
|
||||
it('确认按钮有稳定根元素承接调用方间距,生产卡片用网格间距排列操作', () => {
|
||||
it('公共弹窗状态仅在标题旁提示,默认不显示图标,切换状态不影响正文', async () => {
|
||||
wrapper = mount(AppDialog, {
|
||||
attachTo: document.body,
|
||||
props: { open: true, title: '操作结果' },
|
||||
slots: { default: '<p>请核对当前内容。</p>' }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.n-card-header [role="img"]')).toBeNull()
|
||||
await wrapper.setProps({ status: 'warning' })
|
||||
expect(document.querySelector('.n-card-header [aria-label="警告"]')).not.toBeNull()
|
||||
await wrapper.setProps({ status: 'success' })
|
||||
expect(document.querySelector('.n-card-header [aria-label="警告"]')).toBeNull()
|
||||
expect(document.querySelector('.n-card-header [aria-label="成功"]')).not.toBeNull()
|
||||
await wrapper.setProps({ status: 'error' })
|
||||
expect(document.querySelector('.n-card-header [aria-label="成功"]')).toBeNull()
|
||||
expect(document.querySelector('.n-card-header [aria-label="错误"]')).not.toBeNull()
|
||||
expect(document.querySelector('.dialog-body-scroll')?.textContent).toContain('请核对当前内容。')
|
||||
})
|
||||
|
||||
it('确认按钮有稳定根元素,操作说明始终位于正文,标题说明可省略', async () => {
|
||||
wrapper = mount(ConfirmAction, {
|
||||
props: { label: '测试操作', description: '仅展示,不提交请求' },
|
||||
attrs: { class: 'mt-4' }
|
||||
@@ -522,6 +541,12 @@ describe('管理后台组件边界', () => {
|
||||
expect(wrapper.classes()).toContain('confirm-action')
|
||||
expect(wrapper.classes()).toContain('mt-4')
|
||||
expect(wrapper.get('button').text()).toBe('测试操作')
|
||||
await wrapper.get('button').trigger('click')
|
||||
await flushPromises()
|
||||
const dialog = document.querySelector('.app-dialog')!
|
||||
expect(dialog.querySelector('.n-card-header [aria-label="警告"]')).not.toBeNull()
|
||||
expect(dialog.querySelector('.n-card-header')?.textContent).not.toContain('仅展示,不提交请求')
|
||||
expect(dialog.querySelector('.dialog-body-scroll')?.textContent).toContain('仅展示,不提交请求')
|
||||
expect(readAllStyles()).toMatch(/\.production-pipeline-card\s*\{[^}]*display:\s*grid;[^}]*gap:\s*16px;/)
|
||||
})
|
||||
})
|
||||
@@ -24,9 +24,41 @@ import {
|
||||
import { projectsApi } from '@/features/projects/api'
|
||||
import type { ProjectQualityPolicy } from '@/features/projects/types'
|
||||
import { getOperation } from '@/features/workflows/operations'
|
||||
import { WorkspaceTools } from '@/components/ui'
|
||||
import BreakdownCandidatePanel from '@/features/breakdown/components/BreakdownCandidatePanel.vue'
|
||||
import { commitPreview } from '../../fixtures/breakdown-candidate'
|
||||
|
||||
let wrapper: VueWrapper | undefined
|
||||
|
||||
it('候选预检可从工具栏直达,从设置进入先关闭原抽屉再预检,成功后刷新全部阶段', async () => {
|
||||
vi.spyOn(breakdownApi, 'revalidateCandidate').mockResolvedValue(
|
||||
candidateReview({ projectId: 'breakdown-scroll-test' })
|
||||
)
|
||||
const preview = vi
|
||||
.spyOn(breakdownApi, 'candidateCommitPreview')
|
||||
.mockResolvedValue(commitPreview({ projectId: 'breakdown-scroll-test' }))
|
||||
const context = mountPage([candidateCheckpoint(candidateState({ projectId: 'breakdown-scroll-test' }))])
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('[aria-label="候选安全预检"]').exists()).toBe(true)
|
||||
await wrapper!.get('[data-workspace-tools]').trigger('click')
|
||||
await flushPromises()
|
||||
await drawerPanel()
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '候选安全预检')!
|
||||
.trigger('click')
|
||||
expect(wrapper!.getComponent(WorkspaceTools).props('open')).toBe(false)
|
||||
expect(wrapper!.getComponent(BreakdownCandidatePanel).props('open')).toBe(false)
|
||||
expect(preview).not.toHaveBeenCalled()
|
||||
wrapper!.getComponent(WorkspaceTools).vm.$emit('closed')
|
||||
await flushPromises()
|
||||
expect(wrapper!.getComponent(BreakdownCandidatePanel).props('open')).toBe(true)
|
||||
expect(preview).toHaveBeenCalledOnce()
|
||||
wrapper!.getComponent(BreakdownCandidatePanel).vm.$emit('refresh')
|
||||
await flushPromises()
|
||||
expect(context.refresh).toHaveBeenCalled()
|
||||
expect(context.refreshStageReadiness).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('没有拆解数据时提供居中的主设置入口,只打开现有抽屉,不预览或生成', async () => {
|
||||
const preview = vi.spyOn(breakdownApi, 'preview')
|
||||
const run = vi.spyOn(breakdownApi, 'run')
|
||||
|
||||
@@ -7,8 +7,9 @@ import { breakdownQuality, selectBreakdownSource } from '@/features/breakdown/qu
|
||||
import { getOperation } from '@/features/workflows/operations'
|
||||
import { candidateCheckpoint, candidateReview, candidateState, commitPreview } from '../../fixtures/breakdown-candidate'
|
||||
import type { CandidateCommitPreview } from '@/features/breakdown/candidate.types'
|
||||
import { NButton } from 'naive-ui'
|
||||
|
||||
/** 真实确认弹窗挂载于 body,验证完成后清理。 */
|
||||
/** 真实全屏抽屉挂载于 body,测试仅模拟网络,不接触项目数据。 */
|
||||
let wrapper: VueWrapper | undefined
|
||||
beforeEach(() => {
|
||||
vi.spyOn(projectsApi, 'checkpoints').mockResolvedValue([candidateCheckpoint()])
|
||||
@@ -20,11 +21,13 @@ afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
/** 创建质量已通过但尚未经过安全预检查的面板。 */
|
||||
/** 创建尚未打开的安全预检抽屉,不自动执行请求。 */
|
||||
function openPanel() {
|
||||
wrapper = mount(BreakdownCandidatePanel, {
|
||||
attachTo: document.body,
|
||||
props: {
|
||||
open: false,
|
||||
'onUpdate:open': (value: boolean) => wrapper?.setProps({ open: value }),
|
||||
projectId: 'candidate-project',
|
||||
checkpointId: 'candidate-current',
|
||||
state: candidateState(),
|
||||
@@ -35,28 +38,68 @@ function openPanel() {
|
||||
return wrapper
|
||||
}
|
||||
|
||||
/** 点击只读预检查入口,不直接提交。 */
|
||||
/** 打开只读预检查抽屉,不直接提交。 */
|
||||
async function checkCandidate() {
|
||||
await wrapper!
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '提交候选为正式结果')!
|
||||
.trigger('click')
|
||||
await wrapper!.setProps({ open: true })
|
||||
await flushPromises()
|
||||
}
|
||||
|
||||
/** 用户勾选并点击最终确认按钮。 */
|
||||
async function confirmCandidate() {
|
||||
const dialog = new DOMWrapper(document.querySelector<HTMLElement>('.app-dialog'))
|
||||
await dialog.get('[role="checkbox"]').trigger('click')
|
||||
await dialog
|
||||
/** 取得当前打开的预检抽屉正文及固定底栏。 */
|
||||
function drawer() {
|
||||
return new DOMWrapper(document.querySelector<HTMLElement>('.app-drawer')!)
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击抽屉内的真实操作按钮。
|
||||
* @param label 按钮可见名称
|
||||
*/
|
||||
async function clickAction(label: string) {
|
||||
const button = drawer()
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '确认提交候选为正式结果')!
|
||||
.trigger('click')
|
||||
.find(item => item.text() === label)
|
||||
expect(button, `缺少操作:${label}`).toBeDefined()
|
||||
await button!.trigger('click')
|
||||
await flushPromises()
|
||||
}
|
||||
|
||||
/** 用户勾选固定底栏的确认,再点击最终提交。 */
|
||||
async function confirmCandidate() {
|
||||
await drawer().get('.app-drawer-footer [role="checkbox"]').trigger('click')
|
||||
await clickAction('确认提交候选为正式结果')
|
||||
}
|
||||
|
||||
/** 两条关系仅为隔离测试样例,保留原始证据空格以检验请求不被改写。 */
|
||||
function relationPreview() {
|
||||
const result = commitPreview({ ready: false })
|
||||
result.checks.relationEvidenceValid = false
|
||||
result.relationIssues = ['@SC0002 位于→测试空地', '@PR0001 悬挂于→测试横木']
|
||||
result.relationRepairTargets = [
|
||||
{
|
||||
subjectRef: '@SC0002',
|
||||
subjectName: '测试场景',
|
||||
relation: '位于',
|
||||
target: '测试空地',
|
||||
evidence: ' 原始证据 '
|
||||
},
|
||||
{
|
||||
subjectRef: '@PR0001',
|
||||
subjectName: '测试铜铃',
|
||||
relation: '悬挂于',
|
||||
target: '测试横木',
|
||||
evidence: '另一条证据'
|
||||
}
|
||||
]
|
||||
return result
|
||||
}
|
||||
|
||||
/** 选择第一条真实返回的关系;选择不代表确认。 */
|
||||
async function selectRelation() {
|
||||
await drawer().get('input[type="radio"]').setValue(true)
|
||||
await flushPromises()
|
||||
}
|
||||
|
||||
describe('候选预检查与最终提交门禁', () => {
|
||||
it('审核通过不会直接提交;预检查及最终确认均通过后只提交一次并刷新', async () => {
|
||||
it('打开仅预检,固定底栏明确确认后重新核对版本和门禁,只提交一次并刷新', async () => {
|
||||
const preview = vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(commitPreview())
|
||||
const commit = vi.spyOn(breakdownApi, 'commitCandidate').mockResolvedValue({
|
||||
projectId: 'candidate-project',
|
||||
@@ -69,56 +112,46 @@ describe('候选预检查与最终提交门禁', () => {
|
||||
})
|
||||
openPanel()
|
||||
expect(preview).not.toHaveBeenCalled()
|
||||
expect(commit).not.toHaveBeenCalled()
|
||||
expect(wrapper!.findAll('button').some(button => button.text() === '重新检查')).toBe(true)
|
||||
await wrapper!
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '重新检查')!
|
||||
.trigger('click')
|
||||
expect(wrapper!.emitted('refresh')).toHaveLength(1)
|
||||
await checkCandidate()
|
||||
expect(commit).not.toHaveBeenCalled()
|
||||
expect(document.querySelector('.app-dialog')?.textContent).toContain('确认提交候选为正式结果')
|
||||
expect(drawer().get('.app-drawer-footer [role="checkbox"]').attributes('aria-checked')).toBe('false')
|
||||
await confirmCandidate()
|
||||
expect(preview).toHaveBeenCalledTimes(2)
|
||||
expect(commit).toHaveBeenCalledExactlyOnceWith('candidate-project')
|
||||
expect(wrapper!.emitted('refresh')).toHaveLength(2)
|
||||
expect(wrapper!.text()).toContain('拆解结果已保存并采用')
|
||||
expect(wrapper!.findAll('button').some(button => button.text() === '重新检查')).toBe(false)
|
||||
await wrapper!.setProps({
|
||||
state: candidateState({ storyboardPersisted: true, candidateCommitted: true }),
|
||||
quality: breakdownQuality(
|
||||
selectBreakdownSource([
|
||||
candidateCheckpoint(candidateState({ storyboardPersisted: true, candidateCommitted: true }))
|
||||
]),
|
||||
null
|
||||
)
|
||||
})
|
||||
expect(wrapper!.findAll('button').some(button => button.text() === '提交候选为正式结果')).toBe(false)
|
||||
expect(wrapper!.findAll('button').some(button => button.text() === '重新检查')).toBe(false)
|
||||
expect(wrapper!.emitted('refresh')).toHaveLength(1)
|
||||
expect(wrapper!.emitted('update:open')?.at(-1)).toEqual([false])
|
||||
})
|
||||
it('ready=false 显示未通过项且不打开最终确认', async () => {
|
||||
const result = commitPreview()
|
||||
result.ready = false
|
||||
|
||||
it('ready=false 展示未通过项,禁止最终确认', async () => {
|
||||
const result = commitPreview({ ready: false })
|
||||
result.checks.noProtectedShots = false
|
||||
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(result)
|
||||
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
|
||||
openPanel()
|
||||
await checkCandidate()
|
||||
expect(wrapper!.text()).toContain('没有需要保护的镜头资产')
|
||||
expect(document.querySelector('.app-dialog')).toBeNull()
|
||||
expect(drawer().text()).toContain('镜头资产')
|
||||
expect(drawer().text()).not.toContain('确认提交候选为正式结果')
|
||||
expect(commit).not.toHaveBeenCalled()
|
||||
})
|
||||
it('即使 ready=true,缺少一项安全门禁也禁止确认', async () => {
|
||||
const result = commitPreview()
|
||||
result.checks.noSubjectImages = false
|
||||
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(result)
|
||||
|
||||
it('已提交分支不伪造缺失检查失败,刷新页面且隐藏所有写入口', async () => {
|
||||
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue({
|
||||
projectId: 'candidate-project',
|
||||
checkpointId: 'new-committed',
|
||||
readOnly: true,
|
||||
ready: false,
|
||||
status: 'already_committed',
|
||||
reason: '最新候选已正式提交'
|
||||
})
|
||||
openPanel()
|
||||
await checkCandidate()
|
||||
expect(document.querySelector('.app-dialog')).toBeNull()
|
||||
expect(wrapper!.text()).toContain('主体图片')
|
||||
expect(drawer().text()).toContain('已提交正式结果')
|
||||
expect(drawer().find('[aria-label="未通过的提交安全检查"]').exists()).toBe(false)
|
||||
expect(drawer().text()).not.toContain('确认提交候选为正式结果')
|
||||
expect(wrapper!.emitted('refresh')).toHaveLength(1)
|
||||
})
|
||||
it('最终确认重新发现版本变化时禁止替换并要求刷新', async () => {
|
||||
|
||||
it('最终提交时发现来源版本变化,拒绝替换并刷新', async () => {
|
||||
vi.mocked(projectsApi.checkpoints).mockResolvedValue([candidateCheckpoint(candidateState(), 'new')])
|
||||
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(commitPreview())
|
||||
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
|
||||
@@ -129,10 +162,11 @@ describe('候选预检查与最终提交门禁', () => {
|
||||
expect(getOperation('candidate-project').error).toContain('版本已变化')
|
||||
expect(wrapper!.emitted('refresh')).toHaveLength(1)
|
||||
})
|
||||
it('最终确认时安全条件改变,原先通过的预检查不能继续使用', async () => {
|
||||
|
||||
it('最终确认发现安全条件变化,不沿用原许可', async () => {
|
||||
vi.spyOn(breakdownApi, 'candidateCommitPreview')
|
||||
.mockResolvedValueOnce(commitPreview())
|
||||
.mockResolvedValueOnce(commitPreview({ ready: false }))
|
||||
.mockResolvedValueOnce(relationPreview())
|
||||
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
|
||||
openPanel()
|
||||
await checkCandidate()
|
||||
@@ -140,9 +174,10 @@ describe('候选预检查与最终提交门禁', () => {
|
||||
expect(commit).not.toHaveBeenCalled()
|
||||
expect(getOperation('candidate-project').error).toContain('安全条件已变化')
|
||||
})
|
||||
it('版本变化后晚到的预检查响应不会重新打开确认窗口', async () => {
|
||||
|
||||
it.each(['close', 'project'] as const)('读取期间 %s,晚到的响应不回填原抽屉', async action => {
|
||||
let resolve!: (value: CandidateCommitPreview) => void
|
||||
const preview = vi.spyOn(breakdownApi, 'candidateCommitPreview').mockImplementation(
|
||||
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockImplementation(
|
||||
() =>
|
||||
new Promise(done => {
|
||||
resolve = done
|
||||
@@ -150,19 +185,150 @@ describe('候选预检查与最终提交门禁', () => {
|
||||
)
|
||||
openPanel()
|
||||
await checkCandidate()
|
||||
await wrapper!
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '提交候选为正式结果')!
|
||||
.trigger('click')
|
||||
expect(preview).toHaveBeenCalledTimes(1)
|
||||
await wrapper!.setProps({ checkpointId: 'new' })
|
||||
if (action === 'close') await wrapper!.setProps({ open: false })
|
||||
else await wrapper!.setProps({ projectId: 'other-project', disabled: true })
|
||||
resolve(commitPreview())
|
||||
await flushPromises()
|
||||
expect(document.querySelector('.app-dialog')).toBeNull()
|
||||
expect(document.body.textContent).not.toContain('确认提交候选为正式结果')
|
||||
})
|
||||
it('新快照没有候选标记时不会复用旧候选入口', async () => {
|
||||
})
|
||||
|
||||
describe('候选关系人工修复', () => {
|
||||
it('真实写入期间按钮保留 loading,锁定关闭,连点不会重复移除', async () => {
|
||||
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(relationPreview())
|
||||
let finish!: (value: { checkpointId: string; subjectRef: string; removed: 1 }) => void
|
||||
const repair = vi.spyOn(breakdownApi, 'repairCandidateRelation').mockImplementation(
|
||||
() =>
|
||||
new Promise(resolve => {
|
||||
finish = resolve
|
||||
})
|
||||
)
|
||||
openPanel()
|
||||
await wrapper!.setProps({ checkpointId: 'new', state: {} })
|
||||
expect(wrapper!.text()).not.toContain('提交候选为正式结果')
|
||||
await checkCandidate()
|
||||
await selectRelation()
|
||||
await drawer().get('.app-drawer-footer [role="checkbox"]').trigger('click')
|
||||
await clickAction('确认移除这条关系')
|
||||
await wrapper!.setProps({ disabled: true })
|
||||
const submit = wrapper!.findAllComponents(NButton).find(button => button.text() === '确认移除这条关系')!
|
||||
expect(submit.props('loading')).toBe(true)
|
||||
expect(
|
||||
drawer()
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '关闭')!
|
||||
.attributes('disabled')
|
||||
).toBeDefined()
|
||||
await submit.trigger('click')
|
||||
expect(repair).toHaveBeenCalledOnce()
|
||||
finish({ checkpointId: 'new-version', subjectRef: '@SC0002', removed: 1 })
|
||||
await flushPromises()
|
||||
})
|
||||
|
||||
it('完整展示原始关系,不自动选择、删除或提交', async () => {
|
||||
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(relationPreview())
|
||||
const repair = vi.spyOn(breakdownApi, 'repairCandidateRelation')
|
||||
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
|
||||
openPanel()
|
||||
await checkCandidate()
|
||||
expect(drawer().text()).toContain('测试场景')
|
||||
expect(drawer().text()).toContain('测试空地')
|
||||
expect(drawer().text()).toContain('原始证据')
|
||||
expect(
|
||||
drawer()
|
||||
.findAll<HTMLInputElement>('input[type="radio"]')
|
||||
.every(item => !item.element.checked)
|
||||
).toBe(true)
|
||||
expect(repair).not.toHaveBeenCalled()
|
||||
expect(commit).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('每次仅移除用户明确确认的一条原始关系,新版本到达后重新预检,不自动提交', async () => {
|
||||
const preview = vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(relationPreview())
|
||||
const repair = vi.spyOn(breakdownApi, 'repairCandidateRelation').mockResolvedValue({
|
||||
checkpointId: 'repaired-version',
|
||||
subjectRef: '@SC0002',
|
||||
removed: 1
|
||||
})
|
||||
const commit = vi.spyOn(breakdownApi, 'commitCandidate')
|
||||
openPanel()
|
||||
await checkCandidate()
|
||||
await selectRelation()
|
||||
expect(repair).not.toHaveBeenCalled()
|
||||
const button = drawer()
|
||||
.findAll('button')
|
||||
.find(item => item.text() === '确认移除这条关系')!
|
||||
expect(button.attributes('disabled')).toBeDefined()
|
||||
await drawer().get('.app-drawer-footer [role="checkbox"]').trigger('click')
|
||||
await button.trigger('click')
|
||||
await button.trigger('click')
|
||||
await flushPromises()
|
||||
expect(repair).toHaveBeenCalledExactlyOnceWith('candidate-project', {
|
||||
expectedCheckpointId: 'candidate-current',
|
||||
confirmed: true,
|
||||
subjectRef: '@SC0002',
|
||||
relation: '位于',
|
||||
target: '测试空地',
|
||||
evidence: ' 原始证据 '
|
||||
})
|
||||
expect(wrapper!.emitted('refresh')).toHaveLength(1)
|
||||
expect(commit).not.toHaveBeenCalled()
|
||||
expect(drawer().text()).not.toContain('确认移除这条关系')
|
||||
preview.mockResolvedValue(commitPreview({ checkpointId: 'repaired-version' }))
|
||||
await wrapper!.setProps({
|
||||
checkpointId: 'repaired-version',
|
||||
quality: breakdownQuality(
|
||||
selectBreakdownSource([candidateCheckpoint(candidateState(), 'repaired-version')]),
|
||||
candidateReview({ checkpointId: 'repaired-version' })
|
||||
)
|
||||
})
|
||||
await flushPromises()
|
||||
expect(preview).toHaveBeenCalledTimes(3)
|
||||
expect(drawer().text()).toContain('确认提交候选为正式结果')
|
||||
expect(drawer().get('.app-drawer-footer [role="checkbox"]').attributes('aria-checked')).toBe('false')
|
||||
expect(commit).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it.each(['version', 'target', 'active'] as const)('提交前 %s 变化,拒绝移除并撤销旧确认', async change => {
|
||||
const next = relationPreview()
|
||||
if (change === 'version') next.checkpointId = 'other-version'
|
||||
if (change === 'target') next.relationRepairTargets = []
|
||||
if (change === 'active') next.checks.noActiveExecutions = false
|
||||
vi.spyOn(breakdownApi, 'candidateCommitPreview')
|
||||
.mockResolvedValueOnce(relationPreview())
|
||||
.mockResolvedValue(next)
|
||||
const repair = vi.spyOn(breakdownApi, 'repairCandidateRelation')
|
||||
openPanel()
|
||||
await checkCandidate()
|
||||
await selectRelation()
|
||||
await drawer().get('.app-drawer-footer [role="checkbox"]').trigger('click')
|
||||
await clickAction('确认移除这条关系')
|
||||
expect(repair).not.toHaveBeenCalled()
|
||||
expect(drawer().text()).not.toContain('确认移除这条关系')
|
||||
expect(wrapper!.emitted('refresh')).toHaveLength(1)
|
||||
})
|
||||
|
||||
it('普通提交失败保留所选关系,清除勾选后允许用户修正重试', async () => {
|
||||
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(relationPreview())
|
||||
vi.spyOn(breakdownApi, 'repairCandidateRelation').mockRejectedValue(new Error('网络中断,请重新读取状态'))
|
||||
openPanel()
|
||||
await checkCandidate()
|
||||
await selectRelation()
|
||||
await drawer().get('.app-drawer-footer [role="checkbox"]').trigger('click')
|
||||
await clickAction('确认移除这条关系')
|
||||
expect(drawer().get<HTMLInputElement>('input[type="radio"]').element.checked).toBe(true)
|
||||
expect(drawer().text()).toContain('网络中断')
|
||||
expect(drawer().get('.app-drawer-footer [role="checkbox"]').attributes('aria-checked')).toBe('false')
|
||||
})
|
||||
|
||||
it('完全相同的重复定位关系不能提交删除', async () => {
|
||||
const result = relationPreview()
|
||||
result.relationRepairTargets.push({ ...result.relationRepairTargets[0]! })
|
||||
vi.spyOn(breakdownApi, 'candidateCommitPreview').mockResolvedValue(result)
|
||||
const repair = vi.spyOn(breakdownApi, 'repairCandidateRelation')
|
||||
openPanel()
|
||||
await checkCandidate()
|
||||
await selectRelation()
|
||||
expect(drawer().text()).toContain('定位不唯一')
|
||||
expect(drawer().text()).not.toContain('确认移除这条关系')
|
||||
expect(repair).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it, vi, afterEach } from 'vitest'
|
||||
import { candidateCommitIssue } from '@/features/breakdown/candidate'
|
||||
import { candidateCommitIssue, candidatePreviewReady } from '@/features/breakdown/candidate'
|
||||
import { commitPreview } from '../../fixtures/breakdown-candidate'
|
||||
import { breakdownApi } from '@/features/breakdown/api'
|
||||
import type { BreakdownState } from '@/features/breakdown/types'
|
||||
|
||||
@@ -50,6 +51,37 @@ function readyCandidate(): BreakdownState {
|
||||
afterEach(() => vi.unstubAllGlobals())
|
||||
|
||||
describe('候选提交资格', () => {
|
||||
it('关系来源检查缺失或失败时,即使 ready=true 也不能确认提交', () => {
|
||||
const preview = commitPreview()
|
||||
expect(candidatePreviewReady(preview, 'candidate-project', 'candidate-current')).toBe(true)
|
||||
delete (preview.checks as Partial<typeof preview.checks>).relationEvidenceValid
|
||||
expect(candidatePreviewReady(preview, 'candidate-project', 'candidate-current')).toBe(false)
|
||||
preview.checks.relationEvidenceValid = false
|
||||
expect(candidatePreviewReady(preview, 'candidate-project', 'candidate-current')).toBe(false)
|
||||
})
|
||||
|
||||
it('关系修复只发送最新版本和所选关系原始定位,不扩展成主体删除', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async () => new Response(JSON.stringify({ data: {} })))
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
await breakdownApi.repairCandidateRelation('p/id', {
|
||||
confirmed: true,
|
||||
expectedCheckpointId: 'cp-latest',
|
||||
subjectRef: '@SC0002',
|
||||
relation: '位于',
|
||||
target: '测试空地',
|
||||
evidence: ' 原始证据,保留空格 '
|
||||
})
|
||||
expect(fetcher.mock.calls[0]![0]).toBe('/api/projects/p%2Fid/breakdown/candidate-relation-repair')
|
||||
expect(fetcher.mock.calls[0]![1]?.method).toBe('POST')
|
||||
expect(JSON.parse(fetcher.mock.calls[0]![1]?.body as string)).toEqual({
|
||||
confirmed: true,
|
||||
expectedCheckpointId: 'cp-latest',
|
||||
subjectRef: '@SC0002',
|
||||
relation: '位于',
|
||||
target: '测试空地',
|
||||
evidence: ' 原始证据,保留空格 '
|
||||
})
|
||||
})
|
||||
it('只允许完整、未提交、审核通过的候选快照进入确认', () => {
|
||||
expect(candidateCommitIssue(readyCandidate())).toBe('')
|
||||
expect(candidateCommitIssue({ ...readyCandidate(), candidateOnly: false })).toContain('候选')
|
||||
|
||||
@@ -40,6 +40,9 @@ import { drawerPanel, expandSections, selectControl } from '@/testing/naive'
|
||||
import ProductionPage from '@/features/production/ProductionPage.vue'
|
||||
import RawDataDetails from '@/components/ui/RawDataDetails.vue'
|
||||
import { getProductionSession } from '@/features/production/model'
|
||||
import { generationConfigApi } from '@/features/generation-config/api'
|
||||
import { AppDialog } from '@/components/ui'
|
||||
import { projectSettingsOpenKey } from '@/features/generation-config/context'
|
||||
|
||||
/**
|
||||
* 为内存路由补齐页面链接使用的正式项目工作区,避免链接解析时缺少目标路由。
|
||||
@@ -69,16 +72,23 @@ function createPageRouter(routes: RouteRecordRaw[]) {
|
||||
* 新资产页面复用已有项目上下文和内存路由,不接入真实模型。
|
||||
* @param page 要挂载的风格或主体身份页面
|
||||
* @param query 初始地址的查询参数
|
||||
* @param openSettings 可选的项目顶栏配置入口
|
||||
* @returns 当前页面注入的项目上下文
|
||||
*/
|
||||
async function mountAssets(page: 'style' | 'identity', query = '') {
|
||||
async function mountAssets(page: 'style' | 'identity', query = '', openSettings?: () => void) {
|
||||
const component = page === 'style' ? VisualStylePage : SubjectIdentityPage
|
||||
const router = createPageRouter([{ path: '/assets', component }])
|
||||
await router.push('/assets' + query)
|
||||
const provided = context()
|
||||
wrapper = mount(component, {
|
||||
attachTo: document.body,
|
||||
global: { plugins: [router], provide: { [projectContextKey as symbol]: provided } }
|
||||
global: {
|
||||
plugins: [router],
|
||||
provide: {
|
||||
[projectContextKey as symbol]: provided,
|
||||
...(openSettings ? { [projectSettingsOpenKey as symbol]: openSettings } : {})
|
||||
}
|
||||
}
|
||||
})
|
||||
await flushPromises()
|
||||
if (page === 'identity') await expandSections()
|
||||
@@ -389,6 +399,59 @@ describe('内容级滚动下的生产反馈', () => {
|
||||
})
|
||||
|
||||
describe('视觉风格与主体身份工作区', () => {
|
||||
it.each(['AI 生成角色候选图', '生成辅助参考图', '批量生成角色候选图', '生成场景母版', '生成道具母版'])(
|
||||
'缺少模型时点击%s先提示配置,不出现费用确认也不发送生成请求',
|
||||
async label => {
|
||||
vi.spyOn(generationConfigApi, 'profile').mockResolvedValue(null)
|
||||
vi.spyOn(subjectIdentityApi, 'castingReadiness').mockResolvedValue({
|
||||
total: 1,
|
||||
ready: 0,
|
||||
missingIdentity: 0,
|
||||
missingAnchor: 1,
|
||||
candidatePending: 0,
|
||||
unlocked: 1,
|
||||
locked: 0,
|
||||
items: []
|
||||
})
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
if (String(url).endsWith('/subject-forms')) return jsonResponse([formFixture()])
|
||||
if (String(url).endsWith('/visual-style')) return jsonResponse(styleFixture())
|
||||
if (String(url).endsWith('/identity/images')) return jsonResponse([])
|
||||
return jsonResponse(identityFixture())
|
||||
})
|
||||
stubFetch(fetcher)
|
||||
const openSettings = vi.fn<() => void>()
|
||||
await mountAssets('identity', '', openSettings)
|
||||
const batch = label.startsWith('批量') || label.includes('母版')
|
||||
if (!batch) {
|
||||
const tools = wrapper!.findComponent({ name: 'WorkspaceTools' })
|
||||
tools.vm.$emit('update:open', false)
|
||||
tools.vm.$emit('closed')
|
||||
await flushPromises()
|
||||
}
|
||||
expect(document.body.textContent).not.toContain('立即配置')
|
||||
expect(button(label).disabled).toBe(false)
|
||||
button(label).click()
|
||||
await flushPromises()
|
||||
if (batch) {
|
||||
wrapper!.findComponent({ name: 'WorkspaceTools' }).vm.$emit('closed')
|
||||
await flushPromises()
|
||||
}
|
||||
const dialog = document.querySelector('.app-dialog')
|
||||
expect(dialog?.textContent).toContain('需要配置生成模型')
|
||||
expect(dialog?.textContent).toContain('项目配置')
|
||||
expect(dialog?.textContent).not.toContain('我已确认后台任务停止')
|
||||
expect(fetcher.mock.calls.some(([, init]) => init?.method === 'POST')).toBe(false)
|
||||
button('前往项目配置').click()
|
||||
await flushPromises()
|
||||
expect(openSettings).not.toHaveBeenCalled()
|
||||
wrapper!
|
||||
.findAllComponents(AppDialog)
|
||||
.find(item => item.props('title') === '需要配置生成模型')!
|
||||
.vm.$emit('closed')
|
||||
expect(openSettings).toHaveBeenCalledExactlyOnceWith('generation')
|
||||
}
|
||||
)
|
||||
it('当前主体已确认但其它角色未完成时,隐藏形态入口;保存后按新阶段状态开放', async () => {
|
||||
/** 当前主体已锁定,其它角色仍未确认,用真实项目准入规则约束页面入口。 */
|
||||
const saved = identityFixture({ isLocked: true })
|
||||
|
||||
+7
-4
@@ -1,5 +1,5 @@
|
||||
import type { BreakdownState, EpisodePlan } from '@/features/breakdown/types'
|
||||
import type { CandidateCommitPreview, CandidateRevalidation } from '@/features/breakdown/candidate.types'
|
||||
import type { CandidateCommitCheckPreview, CandidateRevalidation } from '@/features/breakdown/candidate.types'
|
||||
import type { Checkpoint } from '@/features/workflows/types'
|
||||
|
||||
/**
|
||||
@@ -192,16 +192,18 @@ export function candidateReview(overrides: Partial<CandidateRevalidation> = {}):
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建七项门禁均通过的安全预检查响应。
|
||||
* 创建全部门禁均通过的安全预检查响应。
|
||||
* @param overrides 本次检查差异
|
||||
* @returns 只读安全检查
|
||||
*/
|
||||
export function commitPreview(overrides: Partial<CandidateCommitPreview> = {}): CandidateCommitPreview {
|
||||
export function commitPreview(overrides: Partial<CandidateCommitCheckPreview> = {}): CandidateCommitCheckPreview {
|
||||
return {
|
||||
projectId: 'candidate-project',
|
||||
checkpointId: 'candidate-current',
|
||||
ready: true,
|
||||
readOnly: true,
|
||||
relationIssues: [],
|
||||
relationRepairTargets: [],
|
||||
checks: {
|
||||
qualityPolicyMatches: true,
|
||||
episodeNumbersMatch: true,
|
||||
@@ -210,7 +212,8 @@ export function commitPreview(overrides: Partial<CandidateCommitPreview> = {}):
|
||||
noActiveVideos: true,
|
||||
noSubjectIdentities: true,
|
||||
noSubjectImages: true,
|
||||
noProtectedShots: true
|
||||
noProtectedShots: true,
|
||||
relationEvidenceValid: true
|
||||
},
|
||||
counts: {
|
||||
episodes: 1,
|
||||
|
||||
Reference in new issue
Block a user