feat(short-drama-agent-front): 优化项目查询与工作区界面

This commit is contained in:
GJ committed 2026-09-21 19:36:47 +08:00
1 parent 227db5450d
commit e6d02a20a7
33 files changed
+439 -513

No files matched your search

@@ -701,6 +701,7 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
:src="coverImage(form)?.imageUrl"
:alt="`${form.subject.name} · ${form.name}`"
:object-fit="layout === 'masonry' ? 'contain' : 'cover'"
:class="{ 'form-image-empty': !coverImage(form) }"
preview
:empty-text="hasRunningImages(form.images) ? '后台正在生成图片' : '尚未生成图片'"
/>
@@ -842,6 +843,10 @@ const rules = { concurrency: integerRule('批量并发'), limit: integerRule('
.form-image-masonry .asset-image {
@apply aspect-auto;
}
/* 无图占位保持正方形,避免瀑布流的自适应比例将占位区域压扁。 */
.form-image-grid .asset-image.form-image-empty {
@apply aspect-square;
}
.form-image-masonry .asset-image .n-image,
.form-image-masonry .asset-image .n-image img {
@apply h-auto;
@@ -3,7 +3,7 @@ import { NScrollbar, NAlert, NButton, NTag } from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { ExternalLink, RefreshCw } from '@lucide/vue'
import { AppDialog, AssetImage, StatusBadge } from '../../../components/ui'
import { usePolling } from '../../../composables/usePolling'
import { useQuery } from '../../../composables/useQuery'
import { referenceImageUrl } from '../../../lib/assets'
import { formatDate } from '../../../lib/format'
import { getOperation, runOperation } from '../../workflows/operations'
@@ -18,16 +18,12 @@ const emit = defineEmits<{ changed: [] }>()
const selectedId = ref('')
const confirming = ref(false)
const key = computed(() => (open.value ? (props.form?.id ?? '') : ''))
const query = usePolling(
key,
async (id, signal) => {
if (!id) return null
const rows = await subjectImagesApi.listImages(id, signal)
if (rows.some(image => image.subjectFormId !== id)) throw new Error('图片记录与当前形态不匹配,请刷新后重试。')
return rows
},
false
)
const query = useQuery(key, async (id, signal) => {
if (!id) return null
const rows = await subjectImagesApi.listImages(id, signal)
if (rows.some(image => image.subjectFormId !== id)) throw new Error('图片记录与当前形态不匹配,请刷新后重试。')
return rows
})
const images = computed(() => query.data.value ?? [])
const selected = computed(
() => images.value.find(image => image.id === selectedId.value) ?? primaryImage(images.value) ?? images.value[0]
@@ -1,45 +1,39 @@
import { computed, type Ref } from 'vue'
import { usePolling } from '../../composables/usePolling'
import { useQuery } from '../../composables/useQuery'
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
}
})
}
},
false
)
const query = useQuery(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 ?? ''),
false
computed(() => source.value?.shotId ?? '')
)
const relatedForms = computed(
() => new Set(references.data.value?.references.map(item => item.subjectFormId) ?? [])
+22 -26
View File
@@ -1,5 +1,5 @@
import { computed, ref } from 'vue'
import { usePolling } from '../../composables/usePolling'
import { useQuery } from '../../composables/useQuery'
import { ApiError } from '../../lib/http'
import { useProjectContext } from '../projects/context'
import { getOperation, runOperation } from '../workflows/operations'
@@ -17,32 +17,28 @@ export function useSubjectImages() {
const limit = ref<number | ''>('')
const promptConcurrency = ref(3)
const promptForce = ref(false)
const query = usePolling(
id,
async (projectId, signal) => {
if (!projectId) return []
try {
const forms = await subjectImagesApi.listForms(projectId, signal)
if (
forms.some(
form =>
form.subject.projectId !== projectId ||
form.images.some(image => image.subjectFormId !== form.id)
)
const query = useQuery(id, async (projectId, signal) => {
if (!projectId) return []
try {
const forms = await subjectImagesApi.listForms(projectId, signal)
if (
forms.some(
form =>
form.subject.projectId !== projectId ||
form.images.some(image => image.subjectFormId !== form.id)
)
throw new Error('形态图库返回了不匹配的项目或图片,请刷新后重试。')
return forms
} catch (error) {
if (error instanceof ApiError && error.status === 404)
throw new Error(
'后端尚未提供形态图库查询,请更新后端 dev 并重启服务(GET /projects/:id/subject-forms)。',
{ cause: error }
)
throw error
}
},
false
)
)
throw new Error('形态图库返回了不匹配的项目或图片,请刷新后重试。')
return forms
} catch (error) {
if (error instanceof ApiError && error.status === 404)
throw new Error(
'后端尚未提供形态图库查询,请更新后端 dev 并重启服务(GET /projects/:id/subject-forms)。',
{ cause: error }
)
throw error
}
})
const forms = computed(() => query.data.value ?? [])
const operation = computed(() => getOperation(id.value))
const session = computed(() => getImageSession(id.value))