fix(short-drama-agent-front): 优化项目操作与形态图库
This commit is contained in:
1 parent
27ee9fd4ff
commit
dbf97e6f98
11 files changed
+175
-109
No files matched your search
@@ -1,4 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { Image as ImageIcon } from '@lucide/vue'
|
||||
import { NImage } from 'naive-ui'
|
||||
import { ref, watch } from 'vue'
|
||||
|
||||
@@ -67,8 +68,10 @@ watch(() => props.src, reset)
|
||||
@load="reveal"
|
||||
@error="fail"
|
||||
/>
|
||||
<!-- 以下是 Instagram 风格的图片加载骨架模块 -->
|
||||
<span v-if="!loaded" class="reveal-image-placeholder" aria-hidden="true" />
|
||||
<!-- 图片读取时仅让占位图标轻微淡入淡出,保持画幅稳定。 -->
|
||||
<span v-if="!loaded" class="reveal-image-placeholder" aria-hidden="true">
|
||||
<ImageIcon :size="22" :stroke-width="1.3" />
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
@@ -90,7 +93,23 @@ watch(() => props.src, reset)
|
||||
opacity: 1;
|
||||
}
|
||||
.reveal-image-placeholder {
|
||||
@apply absolute inset-0 pointer-events-none;
|
||||
@apply absolute inset-0 pointer-events-none grid place-items-center text-muted;
|
||||
background-color: var(--app-control);
|
||||
}
|
||||
.reveal-image-placeholder > svg {
|
||||
animation: reveal-image-loading 1.8s ease-in-out infinite alternate;
|
||||
}
|
||||
@keyframes reveal-image-loading {
|
||||
from {
|
||||
opacity: 0.45;
|
||||
}
|
||||
to {
|
||||
opacity: 0.85;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.reveal-image-placeholder > svg {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,11 +1,10 @@
|
||||
<script setup lang="ts">
|
||||
import ContextNotice from '../../components/ui/ContextNotice.vue'
|
||||
import WorkspaceActionTooltip from '../../components/ui/WorkspaceActionTooltip.vue'
|
||||
|
||||
import { computed, h, inject, onScopeDispose, provide, ref, watch, watchEffect } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { Settings2 } from '@lucide/vue'
|
||||
import { NScrollbar, NButton, NPageHeader, NSpin, NEllipsis, NSkeleton } from 'naive-ui'
|
||||
import { Menu, Settings2, ShieldCheck } from '@lucide/vue'
|
||||
import { NScrollbar, NButton, NPageHeader, NSpin, NEllipsis, NSkeleton, NDropdown, NPopover } from 'naive-ui'
|
||||
import { EmptyState, WorkspaceRefreshButton } from '../../components/ui'
|
||||
import { projectContextKey, useProjectData, type CheckpointWorkflow } from './context'
|
||||
import { getOperation, operationErrorText } from '../workflows/operations'
|
||||
@@ -36,6 +35,33 @@ const generationRevision = ref(0)
|
||||
provide(projectGenerationRevisionKey, generationRevision)
|
||||
/** 项目标题栏共用配置弹窗开关。 */
|
||||
const settingsOpen = ref(false)
|
||||
/** 项目操作菜单的展开状态。 */
|
||||
const projectActionsOpen = ref(false)
|
||||
/** 制作前检查抽屉的打开状态。 */
|
||||
const preparationOpen = ref(false)
|
||||
/** 标题栏操作只使用当前项目的数据。 */
|
||||
const hasCurrentProject = computed(() => context.project.value?.id === id.value)
|
||||
/** 检查入口沿用读取错误限制,已有项目仍可打开配置。 */
|
||||
const projectActionOptions = computed(() => [
|
||||
{
|
||||
key: 'preparation',
|
||||
label: '制作前检查',
|
||||
icon: () => h(ShieldCheck, { size: 16 }),
|
||||
disabled: !!context.error.value
|
||||
},
|
||||
{ key: 'settings', label: '项目配置', icon: () => h(Settings2, { size: 16 }) }
|
||||
])
|
||||
|
||||
/**
|
||||
* 打开所选的项目抽屉。
|
||||
* @param key 项目操作选项
|
||||
*/
|
||||
function selectProjectAction(key: string | number) {
|
||||
if (!hasCurrentProject.value) return
|
||||
if (key === 'preparation' && !context.error.value) preparationOpen.value = true
|
||||
if (key === 'settings') openProjectSettings()
|
||||
}
|
||||
|
||||
/** 本次项目配置打开的指定分类,不改变当前工作区路由。 */
|
||||
const settingsTab = ref<ProjectSettingsTab>('generation')
|
||||
/**
|
||||
@@ -66,6 +92,8 @@ watch(settingsOpen, shown => {
|
||||
/** 切项目时关闭旧配置,禁止把草稿带入其它项目。 */
|
||||
watch(id, () => {
|
||||
settingsOpen.value = false
|
||||
preparationOpen.value = false
|
||||
projectActionsOpen.value = false
|
||||
generationRevision.value = 0
|
||||
})
|
||||
const operation = computed(() => getOperation(id.value))
|
||||
@@ -308,7 +336,7 @@ onScopeDispose(() => {
|
||||
<template>
|
||||
<section class="project-frame">
|
||||
<header class="project-header">
|
||||
<!-- 以下是项目标题与全局配置入口模块,首次读取保留标题及两个操作的真实占位 -->
|
||||
<!-- 以下是项目标题与全局配置入口模块,首次读取保留标题和菜单按钮的占位 -->
|
||||
<NPageHeader @back="router.push('/projects')">
|
||||
<template #title>
|
||||
<div v-if="isProjectInitialLoading" class="project-title project-title-loading" aria-hidden="true">
|
||||
@@ -319,38 +347,36 @@ onScopeDispose(() => {
|
||||
}}</NEllipsis>
|
||||
</template>
|
||||
<template #extra>
|
||||
<!-- 以下是制作前检查入口,后续页面受限时仍可完成正式分镜审核 -->
|
||||
<div class="project-header-actions flex items-center gap-2">
|
||||
<template v-if="isProjectInitialLoading">
|
||||
<NSkeleton class="project-header-action-placeholder" aria-hidden="true" />
|
||||
<NSkeleton
|
||||
class="project-header-action-placeholder project-header-config-placeholder"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</template>
|
||||
<template v-else>
|
||||
<StoryboardPreparation
|
||||
v-if="context.project.value?.id === id"
|
||||
:key="id"
|
||||
:project-id="id"
|
||||
:disabled="!!context.error.value"
|
||||
:can-open-storyboard="stageAccess.sections.value.storyboard.enabled"
|
||||
@changed="context.refresh()"
|
||||
@open-storyboard="router.push(`/projects/${id}/storyboard`)"
|
||||
/>
|
||||
<WorkspaceActionTooltip label="项目配置" mobile-only>
|
||||
<!-- 以下是制作前检查与项目配置共用的菜单入口。 -->
|
||||
<NSkeleton
|
||||
v-if="isProjectInitialLoading"
|
||||
class="project-header-action-placeholder"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<NDropdown
|
||||
v-else
|
||||
v-model:show="projectActionsOpen"
|
||||
trigger="click"
|
||||
placement="bottom-end"
|
||||
:options="projectActionOptions"
|
||||
@select="selectProjectAction"
|
||||
>
|
||||
<NPopover trigger="hover" placement="left" :disabled="projectActionsOpen || !hasCurrentProject">
|
||||
<template #trigger>
|
||||
<NButton
|
||||
class="workspace-action-button"
|
||||
class="project-header-menu icon-button workspace-action-button"
|
||||
size="small"
|
||||
aria-label="项目配置"
|
||||
:disabled="!context.project.value"
|
||||
@click="openProjectSettings()"
|
||||
><template #icon><Settings2 :size="15" aria-hidden="true" /></template
|
||||
><span class="project-config-label">项目配置</span></NButton
|
||||
:disabled="!hasCurrentProject"
|
||||
aria-label="项目操作"
|
||||
aria-haspopup="menu"
|
||||
:aria-expanded="projectActionsOpen"
|
||||
>
|
||||
</WorkspaceActionTooltip>
|
||||
</template>
|
||||
</div>
|
||||
<template #icon><Menu :size="18" aria-hidden="true" /></template>
|
||||
</NButton>
|
||||
</template>
|
||||
项目操作
|
||||
</NPopover>
|
||||
</NDropdown>
|
||||
</template>
|
||||
</NPageHeader>
|
||||
</header>
|
||||
@@ -362,6 +388,17 @@ onScopeDispose(() => {
|
||||
></ContextNotice
|
||||
>
|
||||
</NScrollbar>
|
||||
<!-- 以下是制作前检查抽屉,跨工作区保留真实任务状态。 -->
|
||||
<StoryboardPreparation
|
||||
v-if="hasCurrentProject"
|
||||
:key="id"
|
||||
v-model:open="preparationOpen"
|
||||
:project-id="id"
|
||||
:disabled="!!context.error.value"
|
||||
:can-open-storyboard="stageAccess.sections.value.storyboard.enabled"
|
||||
@changed="context.refresh()"
|
||||
@open-storyboard="router.push(`/projects/${id}/storyboard`)"
|
||||
/>
|
||||
<!-- 以下是当前项目图片与视频配置弹窗模块 -->
|
||||
<ProjectSettingsDialog
|
||||
:key="id"
|
||||
@@ -461,12 +498,14 @@ onScopeDispose(() => {
|
||||
min-height: 1.5em;
|
||||
}
|
||||
.project-header-action-placeholder {
|
||||
width: 120px;
|
||||
height: 34px;
|
||||
width: var(--app-toolbar-icon-size, 34px);
|
||||
height: var(--app-toolbar-icon-size, 34px);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.project-header-config-placeholder {
|
||||
width: 104px;
|
||||
.project-header .n-button.project-header-menu {
|
||||
--n-height: var(--app-toolbar-icon-size, 34px);
|
||||
min-height: var(--n-height);
|
||||
padding-inline: 0;
|
||||
}
|
||||
.project-notices.n-scrollbar {
|
||||
@apply shrink-0 h-auto max-h-[min(24dvh,160px)] overflow-hidden;
|
||||
@@ -502,27 +541,11 @@ onScopeDispose(() => {
|
||||
@apply items-start flex-col gap-2;
|
||||
}
|
||||
}
|
||||
/* 手机端隐藏文字后,两个项目入口共用方形点击区域并将图标居中。 */
|
||||
/* 手机端的项目菜单和标签栏图标共用紧凑尺寸。 */
|
||||
@media (max-width: 639px) {
|
||||
.project-frame {
|
||||
/* 顶部入口与标签栏图标共用紧凑尺寸。 */
|
||||
--app-toolbar-icon-size: 32px;
|
||||
}
|
||||
.project-header-actions > .n-button.workspace-action-button {
|
||||
width: var(--app-toolbar-icon-size);
|
||||
min-width: var(--app-toolbar-icon-size);
|
||||
height: var(--app-toolbar-icon-size);
|
||||
min-height: var(--app-toolbar-icon-size);
|
||||
padding: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.project-header-action-placeholder {
|
||||
width: var(--app-toolbar-icon-size);
|
||||
height: var(--app-toolbar-icon-size);
|
||||
}
|
||||
.project-header-actions > .n-button .n-button__icon {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.project-header .n-skeleton {
|
||||
@@ -530,12 +553,3 @@ onScopeDispose(() => {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
/* 窄屏的两个项目操作统一显示图标,保留按钮的完整可访问名称。 */
|
||||
@media (max-width: 639px) {
|
||||
.project-config-label {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,9 +1,8 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox, NFormItem, NInput, NTag } from 'naive-ui'
|
||||
import { ArrowLeft, ArrowRight, CheckCheck, RefreshCw, Save, ShieldCheck, Wrench } from '@lucide/vue'
|
||||
import { ArrowLeft, ArrowRight, CheckCheck, RefreshCw, Save, Wrench } from '@lucide/vue'
|
||||
import AppDrawer from '../../components/ui/AppDrawer.vue'
|
||||
import WorkspaceActionTooltip from '../../components/ui/WorkspaceActionTooltip.vue'
|
||||
import WorkspaceSectionHeading from '../../components/ui/WorkspaceSectionHeading.vue'
|
||||
import QualityPolicySummary from '../generation-config/components/QualityPolicySummary.vue'
|
||||
import { projectSettingsOpenKey } from '../generation-config/context'
|
||||
@@ -26,7 +25,7 @@ import {
|
||||
} from '../projects/quality-policy-confirmation'
|
||||
import { userFacingText } from '../../lib/user-facing-text'
|
||||
|
||||
/** 制作前检查统一入口,即使后续页面尚未开放也可以补齐审核。 */
|
||||
/** 制作前检查抽屉,即使后续页面尚未开放也可以补齐审核。 */
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** 当前正式项目。 */ projectId: string
|
||||
@@ -38,7 +37,7 @@ const props = withDefaults(
|
||||
/** 所有写入或后台终态后让调用方刷新实际导航状态。 */
|
||||
const emit = defineEmits<{ changed: []; openStoryboard: [] }>()
|
||||
/** 全屏入口,未打开不读取完整复检。 */
|
||||
const open = ref(false)
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 复用标题栏的唯一配置入口,跳转时指定质量规则分类。 */
|
||||
const openProjectSettings = inject(projectSettingsOpenKey, undefined)
|
||||
/** 只记录用户主动的抽屉交接,等待当前抽屉离场后再打开配置。 */
|
||||
@@ -267,18 +266,7 @@ async function repaired() {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是项目顶部始终可到达的制作前检查入口及统一悬浮说明 -->
|
||||
<WorkspaceActionTooltip label="制作前检查" mobile-only>
|
||||
<NButton
|
||||
size="small"
|
||||
class="preparation-trigger workspace-action-button"
|
||||
:disabled="disabled || !projectId"
|
||||
aria-label="制作前检查"
|
||||
@click="open = true"
|
||||
><template #icon><ShieldCheck :size="15" aria-hidden="true" /></template
|
||||
><span class="preparation-trigger-label">制作前检查</span></NButton
|
||||
>
|
||||
</WorkspaceActionTooltip>
|
||||
<!-- 以下是制作前检查抽屉。 -->
|
||||
<AppDrawer
|
||||
v-model:open="open"
|
||||
:title="repairIssue ? '修订正式分镜问题' : '制作前检查'"
|
||||
@@ -577,9 +565,4 @@ async function repaired() {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
@media (max-width: 639px) {
|
||||
.preparation-trigger-label {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -12,7 +12,7 @@ import ActionMenu from '../../components/ui/ActionMenu.vue'
|
||||
import DetailDisclosure from '../../components/ui/DetailDisclosure.vue'
|
||||
import WorkspaceTools from '../../components/ui/WorkspaceTools.vue'
|
||||
import { NButton, NCheckbox, NInput, NInputNumber, NPopover, NScrollbar, NSelect, NTag } from 'naive-ui'
|
||||
import { computed, onScopeDispose, ref, watch, type Directive } from 'vue'
|
||||
import { computed, onScopeDispose, ref, useTemplateRef, watch, type Directive } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import {
|
||||
Search,
|
||||
@@ -138,6 +138,8 @@ const statusFilterOptions: Array<{ label: string; value: ImageStatusFilter }> =
|
||||
{ label: '全部状态', value: 'all' },
|
||||
{ label: '缺少主图', value: 'missing' }
|
||||
]
|
||||
/** 当前卡片容器,用于在筛选移除卡片后重新计算位置。 */
|
||||
const galleryGrid = useTemplateRef<HTMLElement>('galleryGrid')
|
||||
/** 保存每张卡片的尺寸观察器,切换回网格时及时释放。 */
|
||||
const masonryCardObservers = new WeakMap<HTMLElement, ResizeObserver>()
|
||||
|
||||
@@ -243,6 +245,14 @@ const filtered = computed(() =>
|
||||
.includes(search.value.trim().toLowerCase())
|
||||
)
|
||||
)
|
||||
/** 筛选或数据更新可能只移除卡片,保留的卡片尺寸不变也需要重新排位。 */
|
||||
watch(
|
||||
[filtered, layout],
|
||||
() => {
|
||||
if (galleryGrid.value) syncMasonryLayout(galleryGrid.value)
|
||||
},
|
||||
{ flush: 'post' }
|
||||
)
|
||||
watch(
|
||||
() => [route.query.subjectRef, route.query.subjectFormId, route.query.sourceShotId],
|
||||
() => {
|
||||
@@ -626,7 +636,13 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
|
||||
><ContextNotice v-if="running" role="status" type="info" :show-icon="false" class="mt-4">
|
||||
部分形态正在生成。任务完成后可再次批量生图。
|
||||
</ContextNotice>
|
||||
<div v-if="filtered.length" class="form-image-grid" :class="{ 'form-image-masonry': layout === 'masonry' }">
|
||||
<!-- 以下是筛选结果,网格与瀑布流共用同一组卡片。 -->
|
||||
<div
|
||||
v-if="filtered.length"
|
||||
ref="galleryGrid"
|
||||
class="form-image-grid"
|
||||
:class="{ 'form-image-masonry': layout === 'masonry' }"
|
||||
>
|
||||
<article
|
||||
v-for="form in filtered"
|
||||
v-masonry-card="layout === 'masonry'"
|
||||
|
||||
@@ -47,6 +47,13 @@ const query = useQuery(key, async (value, signal) => {
|
||||
})
|
||||
/** 道具当前有效规格或独立的缺失、过期状态。 */
|
||||
const prop = computed(() => query.data.value?.prop)
|
||||
/** 基础形态需有已完成的旧规格,状态形态可从有效的基础规格派生。 */
|
||||
const canReuseStructure = computed(() => {
|
||||
const current = prop.value
|
||||
if (!current || current.status === 'ready' || current.reason) return false
|
||||
if (!props.form.isDefault) return true
|
||||
return current.status === 'stale' && current.lastGenerationAttempt?.status === 'completed'
|
||||
})
|
||||
/** 复用中的局部按钮状态。 */
|
||||
const reusing = ref(false)
|
||||
/** 复用反馈只在消息层展示。 */
|
||||
@@ -54,7 +61,7 @@ const message = useActionMessage()
|
||||
|
||||
/** 仅复用已有结构;冲突保留当前数据,不调用生成入口。 */
|
||||
async function reuseStructure() {
|
||||
if (!prop.value || reusing.value || getOperation(props.projectId).pending) return
|
||||
if (!canReuseStructure.value || reusing.value || getOperation(props.projectId).pending) return
|
||||
const target = key.value
|
||||
const formId = props.form.id
|
||||
reusing.value = true
|
||||
@@ -129,7 +136,7 @@ function episodeLabel(id: string) {
|
||||
{{ userFacingText(prop.reason, '请重新核对当前形态与剧本来源。') }}
|
||||
</p>
|
||||
<!-- 以下是免费复用操作,文字生成仍使用图片准备检查 -->
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<div v-if="canReuseStructure" class="flex flex-wrap items-center gap-3">
|
||||
<NButton
|
||||
size="small"
|
||||
:loading="reusing"
|
||||
@@ -140,6 +147,9 @@ function episodeLabel(id: string) {
|
||||
</NButton>
|
||||
<span class="text-xs text-muted">需要新规格时,可在图片准备检查中另行确认文字模型费用。</span>
|
||||
</div>
|
||||
<p v-else-if="prop.status === 'missing'" class="text-xs text-muted">
|
||||
可在图片准备检查中核对缺少的资料和准备费用。
|
||||
</p>
|
||||
<p v-if="prop.spec" class="font-medium">{{ prop.spec.semanticClass }}</p>
|
||||
<ul v-if="parts.length" class="space-y-3">
|
||||
<li v-for="part in parts" :key="part.id">
|
||||
|
||||
@@ -33,10 +33,12 @@ describe('资源图片展示与原图预览', () => {
|
||||
expect(wrapper.get<HTMLImageElement>('img').element.style.objectFit).toBe('contain')
|
||||
})
|
||||
|
||||
it('图片加载前显示轻量骨架占位,加载完成后直接淡入图片并移除占位', async () => {
|
||||
it('图片加载时显示无文字的占位图标,完成后展示原图', async () => {
|
||||
wrapper = mount(AssetImage, { props: { src: '/storage/reveal.png', alt: '加载中的图片' } })
|
||||
expect(wrapper.get('.reveal-image').attributes('aria-busy')).toBe('true')
|
||||
expect(wrapper.find('.reveal-image-placeholder').exists()).toBe(true)
|
||||
const placeholder = wrapper.get('.reveal-image-placeholder')
|
||||
expect(placeholder.find('svg').exists()).toBe(true)
|
||||
expect(placeholder.text()).toBe('')
|
||||
expect(wrapper.find('.reveal-image-grid').exists()).toBe(false)
|
||||
await wrapper.get('img').trigger('load')
|
||||
expect(wrapper.get('.reveal-image').classes()).toContain('is-loaded')
|
||||
|
||||
@@ -529,10 +529,14 @@ describe('管理后台组件边界', () => {
|
||||
expect(wrapper.get('.project-view .workspace-page').text()).toBe(path)
|
||||
}
|
||||
expect(detail).toHaveBeenCalledOnce()
|
||||
expect(wrapper.findAll('.project-header .n-button').map(button => button.text())).toEqual([
|
||||
'制作前检查',
|
||||
'项目配置'
|
||||
])
|
||||
const menuButton = wrapper.get('.project-header button[aria-label="项目操作"]')
|
||||
expect(wrapper.findAll('.project-header .n-button')).toHaveLength(1)
|
||||
await menuButton.trigger('click')
|
||||
await flushPromises()
|
||||
expect(menuButton.attributes('aria-expanded')).toBe('true')
|
||||
expect(
|
||||
[...document.querySelectorAll('.n-dropdown-option-body')].map(option => option.textContent?.trim())
|
||||
).toEqual(['制作前检查', '项目配置'])
|
||||
expect(wrapper.find('.project-header [aria-label="刷新项目"]').exists()).toBe(false)
|
||||
expect(wrapper.find('.project-header .n-tag').exists()).toBe(false)
|
||||
})
|
||||
|
||||
@@ -239,7 +239,7 @@ describe('剧本完成前的下游访问限制', () => {
|
||||
expect(wrapper!.get(skeleton).attributes('aria-busy')).toBe('true')
|
||||
expect(wrapper!.find('.workspace-loading').exists()).toBe(false)
|
||||
expect(wrapper!.get('.project-title').text()).toBe('')
|
||||
expect(wrapper!.findAll('.project-header-action-placeholder')).toHaveLength(2)
|
||||
expect(wrapper!.findAll('.project-header-action-placeholder')).toHaveLength(1)
|
||||
expect(wrapper!.find('.project-header .n-button').exists()).toBe(false)
|
||||
expect(mounted).not.toHaveBeenCalled()
|
||||
|
||||
@@ -389,7 +389,7 @@ describe('剧本完成前的下游访问限制', () => {
|
||||
expect(wrapper!.findAll('.n-menu a')).toHaveLength(2)
|
||||
})
|
||||
|
||||
it('读取失败保持锁定;重试成功后解锁,标题只保留项目配置入口', async () => {
|
||||
it('读取失败时禁用项目操作;重试成功后恢复入口和正文', async () => {
|
||||
const detail = vi
|
||||
.spyOn(projectsApi, 'detail')
|
||||
.mockRejectedValueOnce(new Error('项目读取失败'))
|
||||
@@ -398,12 +398,13 @@ describe('剧本完成前的下游访问限制', () => {
|
||||
const { mounted } = await openProject('/projects/retry/storyboard')
|
||||
expect(mounted).not.toHaveBeenCalled()
|
||||
expect(wrapper!.findAll('.n-menu a')).toHaveLength(3)
|
||||
expect(wrapper!.get('.project-header .n-button').text()).toBe('项目配置')
|
||||
expect(wrapper!.get('.project-header button').attributes('disabled')).toBeDefined()
|
||||
const menu = wrapper!.get('.project-header button[aria-label="项目操作"]')
|
||||
expect(menu.attributes('disabled')).toBeDefined()
|
||||
expect(wrapper!.find('.project-header .n-tag').exists()).toBe(false)
|
||||
await wrapper!.get('.project-notices button').trigger('click')
|
||||
await flushPromises()
|
||||
expect(detail).toHaveBeenCalledTimes(2)
|
||||
expect(wrapper!.get('.project-header button[aria-label="项目操作"]').attributes('disabled')).toBeUndefined()
|
||||
expect(mounted).toHaveBeenCalledExactlyOnceWith('storyboard')
|
||||
})
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import { projectSettingsOpenKey } from '@/features/generation-config/context'
|
||||
import { preparationFixture } from './fixtures'
|
||||
|
||||
/** 当前挂载的检查入口,不连接模型或数据库写入。 */
|
||||
let wrapper: VueWrapper | undefined
|
||||
let wrapper: VueWrapper<InstanceType<typeof StoryboardPreparation>> | undefined
|
||||
afterEach(() => {
|
||||
wrapper?.unmount()
|
||||
wrapper = undefined
|
||||
@@ -39,7 +39,7 @@ async function openPreparation(id: string) {
|
||||
props: { projectId: id },
|
||||
global: { provide: { [projectSettingsOpenKey as symbol]: openSettings } }
|
||||
})
|
||||
await wrapper.get('button[aria-label="制作前检查"]').trigger('click')
|
||||
await wrapper.setProps({ open: true })
|
||||
await flushPromises()
|
||||
return { data, openSettings, drawer: new DOMWrapper(document.querySelector<HTMLElement>('.app-drawer')!) }
|
||||
}
|
||||
|
||||
@@ -247,6 +247,21 @@ describe('过期首帧到具体素材定位', () => {
|
||||
expect(fetcher).toHaveBeenCalledTimes(requestCount)
|
||||
})
|
||||
|
||||
it('筛选只移除卡片且保留卡片尺寸不变时,瀑布流将它移回首列首行', async () => {
|
||||
const { second, fetcher } = await gallery()
|
||||
const retainedCard = wrapper!.get<HTMLElement>(`[data-form-id="${second.id}"]`).element
|
||||
// 测试 DOM 不计算布局,预置卡片筛选前的位置,且不触发尺寸变化。
|
||||
retainedCard.style.setProperty('--form-image-column', '2')
|
||||
retainedCard.style.setProperty('--form-image-row-start', '500')
|
||||
const requestCount = fetcher.mock.calls.length
|
||||
await wrapper!.get('input[aria-label="搜索形态图片"]').setValue('雨夜')
|
||||
expect(wrapper!.findAll('.form-image-card')).toHaveLength(1)
|
||||
expect(wrapper!.get('.form-image-card').element).toBe(retainedCard)
|
||||
expect(retainedCard.style.getPropertyValue('--form-image-column')).toBe('1')
|
||||
expect(retainedCard.style.getPropertyValue('--form-image-row-start')).toBe('1')
|
||||
expect(fetcher).toHaveBeenCalledTimes(requestCount)
|
||||
})
|
||||
|
||||
it('图库与关联检查不定时刷新,图片记录变更后更新数据', async () => {
|
||||
vi.useFakeTimers()
|
||||
const { fetcher } = await gallery('?sourceShotId=shot-target')
|
||||
|
||||
@@ -8,9 +8,10 @@ afterEach(() => vi.unstubAllGlobals())
|
||||
|
||||
describe('道具与场景来源诊断', () => {
|
||||
it.each([
|
||||
['missing', '尚未准备结构规格'],
|
||||
['stale', '结构来源已过期']
|
||||
])('道具 %s 只读取原文和历史,不调用生成', async (status, label) => {
|
||||
['missing', '尚未准备结构规格', null, false],
|
||||
['stale', '结构来源已过期', 'failed', false],
|
||||
['stale', '结构来源已过期', 'completed', true]
|
||||
])('道具 %s 只读取原文和历史,不调用生成', async (status, label, attemptStatus, canReuse) => {
|
||||
const form = formFixture('source-project')
|
||||
form.subject.module = 'prop'
|
||||
const fetcher = vi.fn<typeof fetch>(
|
||||
@@ -35,8 +36,8 @@ describe('道具与场景来源诊断', () => {
|
||||
relationQuote: '搭扣从工具箱脱落'
|
||||
}
|
||||
],
|
||||
lastGenerationAttempt: {
|
||||
status: 'failed',
|
||||
lastGenerationAttempt: attemptStatus && {
|
||||
status: attemptStatus,
|
||||
sourceCurrent: false,
|
||||
error: '无法核对归属',
|
||||
evidence: { candidates: [{ semanticClass: '工具箱' }] },
|
||||
@@ -56,7 +57,8 @@ describe('道具与场景来源诊断', () => {
|
||||
expect(wrapper.text()).toContain(label)
|
||||
expect(wrapper.text()).toContain('数量来源 · 第 1 集')
|
||||
expect(wrapper.text()).toContain('拆装来源 · 第 2 集')
|
||||
expect(wrapper.text()).toContain('准备时的来源已过期')
|
||||
expect(wrapper.text().includes('准备时的来源已过期')).toBe(Boolean(attemptStatus))
|
||||
expect(wrapper.findAll('button').some(button => button.text() === '免费复用已有规格')).toBe(canReuse)
|
||||
expect(fetcher.mock.calls).toHaveLength(1)
|
||||
expect(fetcher.mock.calls[0]?.[1]?.method).toBe('GET')
|
||||
} finally {
|
||||
|
||||
Reference in new issue
Block a user