fix: 补齐过期首帧素材定位与图库影响提示
This commit is contained in:
1 parent
f71d2bf0a4
commit
771b66cafc
11 files changed
+826
-23
No files matched your search
@@ -3,7 +3,7 @@ import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
import WorkspaceTools from '../../components/ui/WorkspaceTools.vue'
|
||||
import { NAlert, NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NInputNumber, NSelect, NTag } from 'naive-ui'
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { Search, RefreshCw, Download, ImagePlus, ArrowRight, AlertTriangle } from '@lucide/vue'
|
||||
import { AssetImage, EmptyState, StatusBadge } from '../../components/ui'
|
||||
import { downloadText } from '../../lib/format'
|
||||
@@ -15,9 +15,12 @@ import GenerateImageDialog from './components/GenerateImageDialog.vue'
|
||||
import ImageGalleryDialog from './components/ImageGalleryDialog.vue'
|
||||
import FormPromptDialog from './components/FormPromptDialog.vue'
|
||||
import FormPromptBatch from './components/FormPromptBatch.vue'
|
||||
import { useKeyframeImpact } from './useKeyframeImpact'
|
||||
import { queryText, referenceLocation, referenceTargets } from '../production/asset-links'
|
||||
|
||||
/** 形态图库以正式数据库为准,自动显示已在后端生成的图片。 */
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const {
|
||||
id,
|
||||
forms,
|
||||
@@ -40,6 +43,28 @@ const {
|
||||
generateProject,
|
||||
generateStale
|
||||
} = useSubjectImages()
|
||||
const sourceShotId = computed(() => queryText(route.query.sourceShotId))
|
||||
const targetFormId = computed(() => queryText(route.query.subjectFormId))
|
||||
const targetForm = computed(() => forms.value.find(form => form.id === targetFormId.value))
|
||||
const impact = useKeyframeImpact(id, sourceShotId)
|
||||
const sourceShot = impact.source
|
||||
const linkedReferences = computed(() => referenceTargets(impact.references.data.value, []))
|
||||
const sourceLocation = computed(() =>
|
||||
sourceShot.value
|
||||
? {
|
||||
path: `/projects/${encodeURIComponent(id.value)}/production`,
|
||||
query: { episodeNo: String(sourceShot.value.episodeNo), shotId: sourceShot.value.shotId }
|
||||
}
|
||||
: null
|
||||
)
|
||||
const impactOptions = computed(() => {
|
||||
const items = [...impact.stale.value]
|
||||
if (sourceShot.value && !items.some(item => item.shotId === sourceShot.value?.shotId)) items.push(sourceShot.value)
|
||||
return items.map(item => ({
|
||||
value: item.shotId,
|
||||
label: `第 ${item.episodeNo} 集 · BEAT ${item.beatNo} / 镜头 ${item.shotNo}${item.inconsistent ? ' · 状态待核对' : item.primaryKeyframeStale ? ' · 首帧过期' : ' · 当前镜头'}`
|
||||
}))
|
||||
})
|
||||
const toolsOpen = ref(false)
|
||||
/** 新批量回执到达时显示诊断,进入页面不自动遮挡图库。 */
|
||||
watch(
|
||||
@@ -71,6 +96,7 @@ const completeCount = computed(() => forms.value.filter(form => primaryImage(for
|
||||
const filtered = computed(() =>
|
||||
forms.value.filter(
|
||||
form =>
|
||||
(!targetFormId.value || form.id === targetFormId.value) &&
|
||||
(module.value === 'all' || form.subject.module === module.value) &&
|
||||
(!onlyMissing.value || !primaryImage(form.images)) &&
|
||||
(!onlyStale.value || isPrimaryIdentityStale(form)) &&
|
||||
@@ -80,9 +106,15 @@ const filtered = computed(() =>
|
||||
)
|
||||
)
|
||||
watch(
|
||||
() => route.query.subjectRef,
|
||||
value => {
|
||||
search.value = typeof value === 'string' ? value : ''
|
||||
() => [route.query.subjectRef, route.query.subjectFormId, route.query.sourceShotId],
|
||||
() => {
|
||||
search.value = targetFormId.value ? '' : queryText(route.query.subjectRef)
|
||||
module.value = 'all'
|
||||
onlyMissing.value = false
|
||||
onlyStale.value = false
|
||||
galleryOpen.value = false
|
||||
generateOpen.value = false
|
||||
promptOpen.value = false
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
@@ -117,6 +149,32 @@ function resetFilters() {
|
||||
module.value = 'all'
|
||||
onlyMissing.value = false
|
||||
onlyStale.value = false
|
||||
void router.replace({
|
||||
query: { ...route.query, subjectFormId: undefined, subjectRef: undefined, sourceShotId: undefined }
|
||||
})
|
||||
}
|
||||
|
||||
/** 切换受影响镜头时清空之前的素材过滤,避免相关素材被旧筛选隐藏。 */
|
||||
function selectImpactShot(shotId: string | null) {
|
||||
void router.replace({
|
||||
query: { ...route.query, sourceShotId: shotId || undefined, subjectFormId: undefined, subjectRef: undefined }
|
||||
})
|
||||
}
|
||||
|
||||
/** 同时刷新素材和镜头影响状态,查询仍不启动生成。 */
|
||||
async function refreshAssets() {
|
||||
await Promise.all([query.refresh(), impact.query.refresh(), impact.references.refresh()])
|
||||
}
|
||||
|
||||
/** 全局过期筛选不沿用深链接的单个素材限制。 */
|
||||
async function showStaleForms() {
|
||||
await router.replace({
|
||||
query: { ...route.query, subjectFormId: undefined, subjectRef: undefined, sourceShotId: undefined }
|
||||
})
|
||||
search.value = ''
|
||||
module.value = 'all'
|
||||
onlyMissing.value = false
|
||||
onlyStale.value = true
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -129,7 +187,11 @@ function resetFilters() {
|
||||
>{{ staleForms.length }} 个形态主图过期</NButton
|
||||
>
|
||||
<div class="toolbar-actions">
|
||||
<NButton :disabled="query.loading.value" @click="query.refresh" text size="small"
|
||||
<NButton
|
||||
:disabled="query.loading.value || impact.query.loading.value"
|
||||
@click="refreshAssets"
|
||||
text
|
||||
size="small"
|
||||
><RefreshCw :size="13" :class="{ 'animate-spin': query.loading.value }" />刷新图库 </NButton
|
||||
><WorkspaceTools
|
||||
v-model:open="toolsOpen"
|
||||
@@ -289,6 +351,122 @@ function resetFilters() {
|
||||
</WorkspaceTools>
|
||||
</div>
|
||||
</div>
|
||||
<NAlert v-if="staleForms.length" type="error" :show-icon="false" class="mt-3" title="形态主图需要更新">
|
||||
{{ staleForms.length }}
|
||||
个形态主图与当前已锁定身份母版不一致。请生成候选、验图并切换主图,再重建相关首帧。
|
||||
<NButton text size="small" @click="showStaleForms">筛选身份过期形态</NButton>
|
||||
</NAlert>
|
||||
<NAlert
|
||||
v-if="impact.stale.value.length"
|
||||
type="warning"
|
||||
:show-icon="false"
|
||||
class="mt-3"
|
||||
title="下游主首帧需要处理"
|
||||
data-keyframe-impact
|
||||
>
|
||||
{{ impact.stale.value.length }}
|
||||
个镜头被后端报告主首帧过期。此警告不表示形态图片本身失效;请选择镜头核对当前素材,确认过期后再重建首帧。
|
||||
<p v-if="impact.stale.value.some(item => item.inconsistent)" class="mt-2">
|
||||
其中
|
||||
{{ impact.stale.value.filter(item => item.inconsistent).length }}
|
||||
个镜头的首帧与视频检查结果不一致,不建议直接重复生图。
|
||||
</p>
|
||||
</NAlert>
|
||||
<NAlert v-if="impact.query.error.value" type="warning" :show-icon="false" class="mt-3"
|
||||
>镜头影响检查失败,暂时无法确认有无过期首帧:{{ impact.query.error.value }}
|
||||
<NButton text size="small" @click="impact.query.refresh">重试检查</NButton></NAlert
|
||||
>
|
||||
<div
|
||||
v-if="impactOptions.length || sourceShotId"
|
||||
class="asset-impact-context mt-3"
|
||||
aria-label="镜头与素材定位"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<NSelect
|
||||
:value="sourceShot?.shotId ?? null"
|
||||
:options="impactOptions"
|
||||
placeholder="选择过期镜头,查看关联素材"
|
||||
clearable
|
||||
aria-label="选择关联镜头"
|
||||
class="asset-impact-select"
|
||||
@update:value="selectImpactShot"
|
||||
/>
|
||||
<RouterLink v-if="sourceLocation" :to="sourceLocation" class="text-button"
|
||||
>返回第 {{ sourceShot?.episodeNo }} 集 · 镜头 {{ sourceShot?.shotNo }} →</RouterLink
|
||||
>
|
||||
<NButton v-if="targetFormId || sourceShotId" text size="small" @click="resetFilters"
|
||||
>查看全部素材</NButton
|
||||
>
|
||||
</div>
|
||||
<p
|
||||
v-if="sourceShotId && !sourceShot && !impact.query.loading.value && !impact.query.error.value"
|
||||
class="mt-3 text-danger"
|
||||
>
|
||||
来源镜头不存在或不属于当前项目,未读取其素材。
|
||||
</p>
|
||||
<p
|
||||
v-if="
|
||||
sourceShot &&
|
||||
!sourceShot.primaryKeyframeStale &&
|
||||
!impact.query.error.value &&
|
||||
!impact.query.loading.value
|
||||
"
|
||||
class="mt-3 text-xs"
|
||||
>
|
||||
当前检查:{{
|
||||
sourceShot.primaryKeyframeId ? '该镜头主首帧未被标记为过期' : '该镜头暂无主首帧'
|
||||
}}。请以后端最新就绪状态为准。
|
||||
</p>
|
||||
<p v-if="sourceShot?.inconsistent" class="mt-3 text-xs text-danger">
|
||||
当前镜头:首帧检查未标记过期,但视频检查报告过期。请核对后端检查逻辑与身份母版,暂不建议重复生图。
|
||||
</p>
|
||||
<p
|
||||
v-if="
|
||||
targetForm &&
|
||||
impact.references.data.value &&
|
||||
!impact.references.error.value &&
|
||||
!impact.relatedForms.value.has(targetForm.id)
|
||||
"
|
||||
class="mt-3 text-xs text-danger"
|
||||
>
|
||||
指定形态不在该镜头当前的有效引用列表中,关联可能已调整或主图缺失,请从下方关联素材重新核对。
|
||||
</p>
|
||||
<div
|
||||
v-if="linkedReferences.length && !impact.references.error.value"
|
||||
class="mt-3 flex flex-wrap items-center gap-3"
|
||||
>
|
||||
<span class="text-xs text-muted">本镜头当前关联素材:</span
|
||||
><RouterLink
|
||||
v-for="target in linkedReferences"
|
||||
:key="target.formId || target.subjectRef"
|
||||
:to="referenceLocation(id, sourceShotId, target)"
|
||||
class="text-button"
|
||||
>{{ target.label }} →</RouterLink
|
||||
>
|
||||
</div>
|
||||
<p v-if="impact.references.loading.value" class="mt-2 text-xs text-muted">正在读取镜头关联素材…</p>
|
||||
<p v-if="impact.references.error.value" class="mt-2 text-xs text-danger">
|
||||
{{ impact.references.error.value }}
|
||||
<NButton text size="small" @click="impact.references.refresh">重试读取素材</NButton>
|
||||
</p>
|
||||
</div>
|
||||
<NAlert
|
||||
v-if="targetFormId"
|
||||
:type="targetForm ? 'info' : 'warning'"
|
||||
:show-icon="false"
|
||||
class="mt-3"
|
||||
data-focused-material
|
||||
>
|
||||
<template v-if="targetForm"
|
||||
>已定位:{{ targetForm.subject.name }} · {{ targetForm.name }}({{
|
||||
targetForm.subject.ref
|
||||
}})。可直接查看下方图片与记录、主体身份与母版。</template
|
||||
>
|
||||
<template v-else>{{
|
||||
query.loading.value ? '正在定位素材…' : '指定形态不存在或已被移除,请从本镜头当前关联素材重新选择。'
|
||||
}}</template>
|
||||
<NButton text size="small" @click="resetFilters">清除定位</NButton>
|
||||
</NAlert>
|
||||
<div class="form-image-filter-region">
|
||||
<div class="form-image-filters" role="group" aria-label="形态图片筛选">
|
||||
<NInput
|
||||
@@ -329,7 +507,11 @@ function resetFilters() {
|
||||
v-for="form in filtered"
|
||||
:key="form.id"
|
||||
class="panel form-image-card"
|
||||
:class="{ 'ring-1 ring-danger': isPrimaryIdentityStale(form) }"
|
||||
:class="{
|
||||
'ring-1 ring-danger': isPrimaryIdentityStale(form),
|
||||
'form-image-card-focused': targetFormId === form.id
|
||||
}"
|
||||
:data-form-id="form.id"
|
||||
>
|
||||
<AssetImage
|
||||
:src="coverImage(form)?.imageUrl"
|
||||
@@ -373,6 +555,29 @@ function resetFilters() {
|
||||
当前主图未能匹配最新已锁定母版。请基于当前 Identity Anchor
|
||||
重新生成候选图,并在确认后设置为新的主参考图。
|
||||
</NAlert>
|
||||
<NAlert
|
||||
v-if="
|
||||
sourceShot?.primaryKeyframeStale &&
|
||||
impact.relatedForms.value.has(form.id) &&
|
||||
!impact.references.error.value
|
||||
"
|
||||
type="warning"
|
||||
:show-icon="false"
|
||||
class="mt-3 text-xs leading-6"
|
||||
>
|
||||
第 {{ sourceShot.episodeNo }} 集 · BEAT {{ sourceShot.beatNo }} / 镜头
|
||||
{{ sourceShot.shotNo }} 的待处理首帧关联此素材。
|
||||
{{
|
||||
sourceShot.inconsistent
|
||||
? '后端首帧与视频检查结果不一致,请先核对,不要据此重复生图。'
|
||||
: isPrimaryIdentityStale(form)
|
||||
? '请先更新该形态主图,再重建首帧。'
|
||||
: '关联不等于本素材失效;核对形态主图与身份母版,确认无误后只需重建首帧。'
|
||||
}}
|
||||
<RouterLink v-if="sourceLocation" :to="sourceLocation" class="text-button mt-2"
|
||||
>返回该镜头处理 →</RouterLink
|
||||
>
|
||||
</NAlert>
|
||||
<p v-if="form.images[0]?.status === 'failed'" class="mt-2 line-clamp-2 text-xs text-danger">
|
||||
{{ form.images[0].error }}
|
||||
</p>
|
||||
@@ -419,6 +624,6 @@ function resetFilters() {
|
||||
:project-id="id"
|
||||
:form="galleryForm"
|
||||
:disabled="blocked || !galleryForm"
|
||||
@changed="query.refresh"
|
||||
@changed="refreshAssets"
|
||||
/></WorkspacePage>
|
||||
</template>
|
||||
@@ -0,0 +1,360 @@
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { createMemoryHistory, createRouter } from 'vue-router'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
import { NSelect } from 'naive-ui'
|
||||
import { testProjectContext } from '../../testing/project-context'
|
||||
import { projectContextKey } from '../projects/context'
|
||||
import { formFixture, imageFixture } from './testing/fixtures'
|
||||
import { referenceLocation, referenceTargets } from '../production/asset-links'
|
||||
import StaleKeyframeNotice from '../production/components/StaleKeyframeNotice.vue'
|
||||
import SubjectImagesPage from './SubjectImagesPage.vue'
|
||||
import ProductionPage from '../production/ProductionPage.vue'
|
||||
import { directionsResult, storyboardCheckpoint } from '../storyboard/testing/fixtures'
|
||||
import type { ProductionIssue } from '../production/types'
|
||||
import type { ShotReferences } from '../storyboard/types'
|
||||
|
||||
let wrapper: VueWrapper | undefined
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
document.body.innerHTML = ''
|
||||
vi.unstubAllGlobals()
|
||||
})
|
||||
|
||||
/** 镜头引用非默认形态,用于防止退化成仅按主体名搜索。 */
|
||||
function fixture() {
|
||||
const first = formFixture('capability-test')
|
||||
const second = {
|
||||
...first,
|
||||
id: 'form-special',
|
||||
name: '雨夜形态',
|
||||
isDefault: false,
|
||||
images: [imageFixture({ subjectFormId: 'form-special' })]
|
||||
}
|
||||
const other = {
|
||||
...formFixture('capability-test'),
|
||||
id: 'form-other',
|
||||
subjectId: 'subject-other',
|
||||
subject: { ...first.subject, id: 'subject-other', name: '路人', ref: '@CH0005' },
|
||||
images: [imageFixture({ subjectFormId: 'form-other' })]
|
||||
}
|
||||
const references: ShotReferences = {
|
||||
shotId: 'shot-target',
|
||||
references: [
|
||||
{
|
||||
shotSubjectId: 'binding-1',
|
||||
subjectId: first.subjectId,
|
||||
subjectRef: first.subject.ref,
|
||||
subjectName: first.subject.name,
|
||||
module: 'character',
|
||||
subjectFormId: second.id,
|
||||
subjectFormName: second.name,
|
||||
imageId: 'image-db-1',
|
||||
imageUrl: '/storage/current.png'
|
||||
},
|
||||
{
|
||||
shotSubjectId: 'binding-2',
|
||||
subjectId: other.subjectId,
|
||||
subjectRef: other.subject.ref,
|
||||
subjectName: other.subject.name,
|
||||
module: 'character',
|
||||
subjectFormId: other.id,
|
||||
subjectFormName: other.name,
|
||||
imageId: 'other-image',
|
||||
imageUrl: '/storage/other.png'
|
||||
}
|
||||
],
|
||||
missing: []
|
||||
}
|
||||
const issues: ProductionIssue[] = [
|
||||
{ code: 'stale_keyframe', reason: '参考资产已变化: @CH0001, @CH0005', missingSubjects: ['@CH0001', '@CH0005'] }
|
||||
]
|
||||
const keyframes = {
|
||||
total: 1,
|
||||
ready: 1,
|
||||
skipped: 0,
|
||||
blocked: 0,
|
||||
stalePrimaryKeyframe: 1,
|
||||
items: [
|
||||
{
|
||||
shotId: 'shot-target',
|
||||
shotNo: 1,
|
||||
episodeNo: 2,
|
||||
beatNo: 2,
|
||||
status: 'ready',
|
||||
primaryKeyframeStale: true,
|
||||
primaryKeyframeId: 'keyframe-old',
|
||||
issues: []
|
||||
}
|
||||
]
|
||||
}
|
||||
const videos = {
|
||||
total: 1,
|
||||
ready: 0,
|
||||
skipped: 0,
|
||||
blocked: 1,
|
||||
items: [{ shotId: 'shot-target', shotNo: 1, status: 'blocked', issues }]
|
||||
}
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
const path = String(url)
|
||||
const data = path.endsWith('/subject-forms')
|
||||
? [first, second, other]
|
||||
: path.includes('/keyframes/readiness')
|
||||
? keyframes
|
||||
: path.includes('/videos/readiness')
|
||||
? videos
|
||||
: path.endsWith('/references')
|
||||
? references
|
||||
: []
|
||||
return new Response(JSON.stringify({ data }))
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
return { first, second, other, references, issues, keyframes, videos, fetcher }
|
||||
}
|
||||
|
||||
/** 在真实内存路由中验证跨页 URL,不替换 RouterLink 行为。 */
|
||||
async function gallery(query = '') {
|
||||
const data = fixture()
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [
|
||||
{ path: '/projects/:projectId/subject-images', component: SubjectImagesPage },
|
||||
{ path: '/projects/:projectId/production', component: { template: '<div />' } }
|
||||
]
|
||||
})
|
||||
await router.push('/projects/capability-test/subject-images' + query)
|
||||
wrapper = mount(SubjectImagesPage, {
|
||||
attachTo: document.body,
|
||||
global: { plugins: [router], provide: { [projectContextKey as symbol]: testProjectContext() } }
|
||||
})
|
||||
await flushPromises()
|
||||
return { ...data, router }
|
||||
}
|
||||
|
||||
describe('过期首帧到具体素材定位', () => {
|
||||
it('切换镜头取消旧参考图查询,迟到响应不会产生旧素材链接', async () => {
|
||||
const { references } = fixture()
|
||||
let finish!: (response: Response) => void
|
||||
const nextReferences = {
|
||||
...references,
|
||||
shotId: 'shot-new',
|
||||
references: [{ ...references.references[0]!, subjectFormId: 'form-new', subjectFormName: '新镜头形态' }]
|
||||
}
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(url =>
|
||||
String(url).includes('shot-target')
|
||||
? new Promise(resolve => {
|
||||
finish = resolve
|
||||
})
|
||||
: Promise.resolve(new Response(JSON.stringify({ data: nextReferences })))
|
||||
)
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [{ path: '/:pathMatch(.*)*', component: { template: '<div />' } }]
|
||||
})
|
||||
await router.push('/')
|
||||
wrapper = mount(StaleKeyframeNotice, {
|
||||
global: { plugins: [router] },
|
||||
props: { projectId: 'capability-test', shotId: 'shot-target', issues: [] }
|
||||
})
|
||||
await flushPromises()
|
||||
const signal = fetcher.mock.calls[0]?.[1]?.signal
|
||||
await wrapper.setProps({ shotId: 'shot-new' })
|
||||
await flushPromises()
|
||||
expect(signal?.aborted).toBe(true)
|
||||
finish(new Response(JSON.stringify({ data: references })))
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('新镜头形态')
|
||||
expect(wrapper.findAll('a').some(link => link.attributes('href')?.includes('form-special'))).toBe(false)
|
||||
})
|
||||
it('参考素材查询失败时保留引用级定位和重试,不静默选择默认形态', async () => {
|
||||
const { issues } = fixture()
|
||||
vi.stubGlobal('fetch', vi.fn<typeof fetch>().mockResolvedValue(new Response('{}', { status: 500 })))
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [{ path: '/:pathMatch(.*)*', component: { template: '<div />' } }]
|
||||
})
|
||||
await router.push('/')
|
||||
wrapper = mount(StaleKeyframeNotice, {
|
||||
global: { plugins: [router] },
|
||||
props: { projectId: 'capability-test', shotId: 'shot-target', issues, inconsistent: true }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper.text()).toContain('状态待核对')
|
||||
expect(wrapper.text()).toContain('重试定位')
|
||||
expect(wrapper.findAll('a').every(link => !link.attributes('href')?.includes('subjectFormId'))).toBe(true)
|
||||
})
|
||||
it('结构化变更引用映射到实际使用的非默认形态,并保留来源镜头', () => {
|
||||
const { references, issues } = fixture()
|
||||
const targets = referenceTargets(references, issues)
|
||||
expect(targets.map(item => item.formId)).toEqual(['form-special', 'form-other'])
|
||||
expect(referenceLocation('project/1', 'shot-target', targets[0]!)).toEqual({
|
||||
path: '/projects/project%2F1/subject-images',
|
||||
query: { sourceShotId: 'shot-target', subjectRef: '@CH0001', subjectFormId: 'form-special' }
|
||||
})
|
||||
})
|
||||
it('没有当前关联时只回退到引用,不猜默认形态;没有变更列表时展示关联素材', () => {
|
||||
const { references } = fixture()
|
||||
const targets = referenceTargets(references, [
|
||||
{ code: 'stale_keyframe', reason: '历史主体被移除', missingSubjects: ['@CH0999'] }
|
||||
])
|
||||
expect(targets[0]?.formId).toBeUndefined()
|
||||
expect(targets[0]?.label).toContain('当前形态待核对')
|
||||
expect(referenceTargets(references, [])).toHaveLength(2)
|
||||
})
|
||||
it('生产警告的引用可点击定位,点击不提交生图', async () => {
|
||||
const { issues, fetcher } = fixture()
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [{ path: '/:pathMatch(.*)*', component: { template: '<div />' } }]
|
||||
})
|
||||
await router.push('/projects/capability-test/production')
|
||||
wrapper = mount(StaleKeyframeNotice, {
|
||||
global: { plugins: [router] },
|
||||
props: { projectId: 'capability-test', shotId: 'shot-target', issues }
|
||||
})
|
||||
await flushPromises()
|
||||
const links = wrapper.findAll('a')
|
||||
expect(links).toHaveLength(2)
|
||||
expect(links[0]?.text()).toContain('雨夜形态')
|
||||
await links[0]!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(router.currentRoute.value.query.subjectFormId).toBe('form-special')
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
it('图库直接访问即显示下游警告,但不把有效素材误标成身份过期', async () => {
|
||||
const { fetcher } = await gallery()
|
||||
expect(wrapper!.get('[data-keyframe-impact]').text()).toContain('1 个镜头')
|
||||
expect(wrapper!.text()).toContain('不表示形态图片本身失效')
|
||||
expect(wrapper!.findAll('.form-image-card')).toHaveLength(3)
|
||||
expect(wrapper!.text()).not.toContain('个形态主图与当前已锁定身份母版不一致')
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url).endsWith('/references'))).toBe(false)
|
||||
const select = wrapper!
|
||||
.findAllComponents(NSelect)
|
||||
.find(item => item.attributes('aria-label') === '选择关联镜头')!
|
||||
select.vm.$emit('update:value', 'shot-target')
|
||||
await flushPromises()
|
||||
expect(wrapper!.text()).toContain('待处理首帧关联此素材')
|
||||
expect(fetcher.mock.calls.filter(([url]) => String(url).endsWith('/references'))).toHaveLength(1)
|
||||
})
|
||||
it('精准定位卡片、清空旧类型筛选、提供可恢复原镜头的返回链接', async () => {
|
||||
const { router } = await gallery('?sourceShotId=shot-target&subjectFormId=form-special&subjectRef=%40CH0001')
|
||||
expect(wrapper!.findAll('.form-image-card')).toHaveLength(1)
|
||||
expect(wrapper!.get('.form-image-card').attributes('data-form-id')).toBe('form-special')
|
||||
expect(wrapper!.get('.form-image-card').classes()).toContain('form-image-card-focused')
|
||||
expect(wrapper!.get('[data-focused-material]').text()).toContain('雨夜形态')
|
||||
const back = wrapper!.findAll('a').find(link => link.text().includes('返回第 2 集'))!
|
||||
const url = new URL(back.attributes('href')!, 'https://local.test')
|
||||
expect(url.searchParams.get('episodeNo')).toBe('2')
|
||||
expect(url.searchParams.get('shotId')).toBe('shot-target')
|
||||
const type = wrapper!.findAllComponents(NSelect).find(item => item.attributes('aria-label') === '筛选主体类型')!
|
||||
type.vm.$emit('update:value', 'scene')
|
||||
await flushPromises()
|
||||
expect(wrapper!.findAll('.form-image-card')).toHaveLength(0)
|
||||
await router.push({ query: { sourceShotId: 'shot-target', subjectFormId: 'form-other' } })
|
||||
await flushPromises()
|
||||
expect(wrapper!.get('.form-image-card').attributes('data-form-id')).toBe('form-other')
|
||||
const clear = wrapper!.findAll('button').find(button => button.text() === '清除定位')!
|
||||
await clear.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper!.findAll('.form-image-card')).toHaveLength(3)
|
||||
})
|
||||
it('身份主图真的过期时显示独立顶部警告,并可从定位模式筛选所有过期素材', async () => {
|
||||
const { first, router } = await gallery('?subjectFormId=form-other')
|
||||
first.subject.identity = { id: 'identity-1', isLocked: true, images: [{ id: 'anchor-new' }] }
|
||||
const refresh = wrapper!.findAll('button').find(button => button.text() === '刷新图库')!
|
||||
await refresh.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper!.text()).toContain('形态主图需要更新')
|
||||
await wrapper!
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '筛选身份过期形态')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(router.currentRoute.value.query.subjectFormId).toBeUndefined()
|
||||
expect(wrapper!.findAll('.form-image-card').map(item => item.attributes('data-form-id'))).toEqual([
|
||||
'form-db-1',
|
||||
'form-special'
|
||||
])
|
||||
})
|
||||
it('仅视频接口报告过期时也显示警告,并明确两种检查不一致', async () => {
|
||||
const { keyframes } = await gallery('?sourceShotId=shot-target&subjectFormId=form-special')
|
||||
keyframes.items[0]!.primaryKeyframeStale = false
|
||||
await wrapper!
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '刷新图库')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper!.get('[data-keyframe-impact]').text()).toContain('检查结果不一致')
|
||||
expect(wrapper!.get('.form-image-card').text()).toContain('不要据此重复生图')
|
||||
})
|
||||
it('镜头修复后清除过期警告,保留明确的当前状态和返回入口', async () => {
|
||||
const { keyframes, videos } = await gallery('?sourceShotId=shot-target&subjectFormId=form-special')
|
||||
keyframes.items[0]!.primaryKeyframeStale = false
|
||||
videos.items[0]!.issues = []
|
||||
await wrapper!
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '刷新图库')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper!.find('[data-keyframe-impact]').exists()).toBe(false)
|
||||
expect(wrapper!.text()).toContain('未被标记为过期')
|
||||
})
|
||||
it('无效镜头和已移除形态不发跨项目请求,也不误定位其他素材', async () => {
|
||||
const { fetcher } = await gallery('?sourceShotId=foreign-shot&subjectFormId=deleted-form')
|
||||
expect(wrapper!.text()).toContain('来源镜头不存在或不属于当前项目')
|
||||
expect(wrapper!.get('[data-focused-material]').text()).toContain('指定形态不存在')
|
||||
expect(wrapper!.findAll('.form-image-card')).toHaveLength(0)
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url).includes('foreign-shot/references'))).toBe(false)
|
||||
})
|
||||
it('影响查询失败不能当成没有过期首帧,仍然显示已有图库', async () => {
|
||||
const { fetcher } = await gallery()
|
||||
const original = fetcher.getMockImplementation()!
|
||||
fetcher.mockImplementation((url, init) =>
|
||||
String(url).includes('/readiness')
|
||||
? Promise.resolve(new Response('{}', { status: 500 }))
|
||||
: original(url, init)
|
||||
)
|
||||
await wrapper!
|
||||
.findAll('button')
|
||||
.find(button => button.text() === '刷新图库')!
|
||||
.trigger('click')
|
||||
await flushPromises()
|
||||
expect(wrapper!.text()).toContain('暂时无法确认有无过期首帧')
|
||||
expect(wrapper!.findAll('.form-image-card')).toHaveLength(3)
|
||||
})
|
||||
it('素材返回生产页时按正式 Shot ID 选择,不误选同编号的另一个 Beat', async () => {
|
||||
const context = testProjectContext()
|
||||
context.data.value!.checkpoints = [storyboardCheckpoint()]
|
||||
const data = directionsResult('capability-test', 2)
|
||||
const target = data.beats[1]!.shots[0]!
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
const path = String(url)
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
data: path.includes('/storyboard-directions')
|
||||
? data
|
||||
: path.includes('/readiness') || path.endsWith('/videos/status')
|
||||
? { total: 0, items: [] }
|
||||
: []
|
||||
})
|
||||
)
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [{ path: '/projects/:projectId/production', component: ProductionPage }]
|
||||
})
|
||||
await router.push({
|
||||
path: '/projects/capability-test/production',
|
||||
query: { episodeNo: '2', shotId: target.shotId }
|
||||
})
|
||||
wrapper = mount(ProductionPage, {
|
||||
global: { plugins: [router], provide: { [projectContextKey as symbol]: context } }
|
||||
})
|
||||
await flushPromises()
|
||||
expect(wrapper!.get('.production-detail').text()).toContain(target.shotId)
|
||||
expect(fetcher.mock.calls.some(([url]) => String(url).includes('episodeNo=2'))).toBe(true)
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,42 @@
|
||||
import { computed, type Ref } from 'vue'
|
||||
import { usePolling } from '../../composables/usePolling'
|
||||
import { productionApi } from '../production/api'
|
||||
import { useShotReferences } from '../production/useShotReferences'
|
||||
|
||||
/** 镜头影响检查与素材查询独立;检查失败不把素材误判为正常或阻断独立的素材操作。 */
|
||||
export function useKeyframeImpact(projectId: Ref<string>, sourceShotId: Ref<string>) {
|
||||
const query = usePolling(projectId, async (id, signal) => {
|
||||
if (!id) return null
|
||||
const [keyframes, videos] = await Promise.all([
|
||||
productionApi.keyframeReadiness(id, false, signal),
|
||||
productionApi.videoReadiness(id, false, signal)
|
||||
])
|
||||
if (!keyframes || !Array.isArray(keyframes.items) || !videos || !Array.isArray(videos.items))
|
||||
throw new Error('主首帧影响检查未返回镜头列表。')
|
||||
const byShot = new Map(videos.items.map(item => [item.shotId, item]))
|
||||
if (byShot.size !== keyframes.items.length || keyframes.items.some(item => !byShot.has(item.shotId)))
|
||||
throw new Error('首帧与视频检查的镜头列表不一致,可能正在重新拆解,请刷新后重试。')
|
||||
return {
|
||||
...keyframes,
|
||||
items: keyframes.items.map(item => {
|
||||
const issues = byShot.get(item.shotId)?.issues.filter(issue => issue.code === 'stale_keyframe') ?? []
|
||||
return {
|
||||
...item,
|
||||
primaryKeyframeStale: !!item.primaryKeyframeStale || issues.length > 0,
|
||||
inconsistent: item.primaryKeyframeStale === false && issues.length > 0
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
const stale = computed(() => query.data.value?.items.filter(item => item.primaryKeyframeStale) ?? [])
|
||||
// 不根据 URL 中的任意镜头 ID 发请求,必须属于当前项目的就绪列表。
|
||||
const source = computed(() => query.data.value?.items.find(item => item.shotId === sourceShotId.value))
|
||||
const references = useShotReferences(
|
||||
projectId,
|
||||
computed(() => source.value?.shotId ?? '')
|
||||
)
|
||||
const relatedForms = computed(
|
||||
() => new Set(references.data.value?.references.map(item => item.subjectFormId) ?? [])
|
||||
)
|
||||
return { query, stale, source, references, relatedForms }
|
||||
}
|
||||
Reference in new issue
Block a user