feat(short-drama-agent-front): 完善镜头定位与项目配置

This commit is contained in:
GJ committed 2026-10-08 19:45:26 +08:00
1 parent 470b52e26d
commit 5b134207b8
66 files changed
+2042 -984

No files matched your search

+50 -8
View File
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { computed, inject, onScopeDispose, provide, watchEffect } from 'vue'
import { computed, inject, onScopeDispose, provide, ref, watch, watchEffect } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { NScrollbar, NAlert, NButton, NPageHeader, NSpin, NEllipsis } from 'naive-ui'
import { EmptyState } from '../../components/ui'
@@ -9,6 +9,8 @@ import { projectAccessKey, projectSectionFromPath, type ProjectAccess } from './
import { useProjectStageAccess } from './useProjectStageAccess'
import { useWorkflowExecution } from '../workflows/execution'
import { clearEpisodeSourceInvalidations, invalidateEpisodeSource } from '../storyboard/model'
import ProjectSettingsDialog from '../generation-config/components/ProjectSettingsDialog.vue'
import { projectGenerationRevisionKey } from '../generation-config/context'
import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
/** 项目标题只保留名称;下游工作区在剧本完成前不挂载,直接链接也无法越过限制。 */
@@ -22,6 +24,32 @@ const isGallery = computed(() => {
})
const context = useProjectData(id)
provide(projectContextKey, context)
/** 项目全局配置保存后更新已挂载生成表单。 */
const generationRevision = ref(0)
provide(projectGenerationRevisionKey, generationRevision)
/** 项目标题栏共用配置弹窗开关。 */
const settingsOpen = ref(false)
/** 既有配置恢复链接打开同一个全局弹窗,不切换工作区。 */
watch(
() => route.query.configure,
value => {
if (value === 'profile') settingsOpen.value = true
},
{ immediate: true }
)
/** 关闭弹窗清除仅用于打开配置的参数,保留镜头与其它地址信息。 */
watch(settingsOpen, shown => {
if (!shown && route.query.configure === 'profile') {
const query = { ...route.query }
delete query.configure
void router.replace({ path: route.path, query, hash: route.hash })
}
})
/** 切项目时关闭旧配置,禁止把草稿带入其它项目。 */
watch(id, () => {
settingsOpen.value = false
generationRevision.value = 0
})
const operation = computed(() => getOperation(id.value))
const createDramaExecution = useWorkflowExecution(id, 'create-drama')
/** 项目内跨页面继续观察首帧后台任务,维持活动锁并在真实终态后释放。 */
@@ -128,13 +156,12 @@ function resolveOperationError() {
void router.push({ path: `/projects/${id.value}/production`, query })
} else if (target === 'style') void router.push(`/projects/${id.value}/visual-style`)
else if (target === 'identity') void router.push(`/projects/${id.value}/subject-identity`)
else if (target === 'profile') {
const onIdentityPage = route.path.replace(/\/+$/, '').endsWith('/subject-identity')
void router.push({
path: onIdentityPage ? route.path : `/projects/${id.value}/production`,
query: { ...route.query, configure: 'profile' }
})
}
else if (target === 'profile') settingsOpen.value = true
}
/** 配置真实保存后更新当前项目的就绪门禁并解除配置缺失提示。 */
function projectSettingsSaved() {
if (operationGuide.value?.target === 'profile') operation.value.error = ''
void context.refreshStageReadiness()
}
const access = inject(projectAccessKey, undefined)
let published: ProjectAccess | null = null
@@ -149,12 +176,18 @@ onScopeDispose(() => {
<template>
<section class="project-frame">
<header class="project-header">
<!-- 以下是项目标题与全局配置入口模块 -->
<NPageHeader @back="router.push('/projects')">
<template #title
><NEllipsis class="project-title" :tooltip="false">{{
context.project.value?.title || context.project.value?.topic || '读取项目'
}}</NEllipsis></template
>
<template #extra>
<NButton size="small" :disabled="!context.project.value" @click="settingsOpen = true"
>项目配置</NButton
>
</template>
</NPageHeader>
</header>
<NScrollbar
@@ -194,6 +227,15 @@ onScopeDispose(() => {
@refresh="createDramaExecution.query.refresh"
@dismiss="createDramaExecution.dismiss"
/>
<!-- 以下是当前项目图片与视频配置弹窗模块 -->
<ProjectSettingsDialog
:key="id"
v-if="context.project.value?.id === id"
v-model:open="settingsOpen"
:project-id="id"
:disabled="operation.pending"
@saved="projectSettingsSaved"
/>
<div class="project-view">
<RouterView v-if="context.project.value?.id === id && currentAccess?.enabled" :key="id" />
<EmptyState
+3 -11
View File
@@ -12,7 +12,7 @@ import {
type DataTableColumns,
type DataTableInst
} from 'naive-ui'
import { MoreHorizontal, Pencil, RefreshCw, Search, Trash2 } from '@lucide/vue'
import { MoreHorizontal, Pencil, Search, Trash2 } from '@lucide/vue'
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
import { useQuery } from '../../composables/useQuery'
import { StatusBadge } from '../../components/ui'
@@ -25,7 +25,7 @@ import DeleteProjectDialog from './components/DeleteProjectDialog.vue'
/** 项目表格使用固定表头与独立滚动;搜索筛选仍作用于真实接口数据。 */
const router = useRouter()
/** 列表已有刷新按钮,只在进入和手动刷新时读取;筛选在完整结果中进行。 */
/** 列表在进入或自身操作完成后读取;筛选在完整结果中进行。 */
const query = useQuery(ref('projects'), (_, signal) => projectsApi.list(signal))
const search = ref('')
const filter = ref('all')
@@ -150,7 +150,7 @@ function clearFilters() {
</div>
<CreateProjectDialog @created="openProject" />
</div>
<!-- 以下是状态筛选、搜索与刷新 -->
<!-- 以下是状态筛选与搜索模块 -->
<div class="project-index-toolbar">
<div class="project-status-filter-scroller">
<NRadioGroup
@@ -172,14 +172,6 @@ function clearFilters() {
:input-props="{ 'aria-label': '搜索项目' }"
><template #prefix><Search :size="15" /></template
></NInput>
<NButton
class="icon-button"
:loading="query.loading.value"
aria-label="刷新项目"
title="刷新项目"
@click="query.refresh"
><template #icon><RefreshCw :size="16" /></template
></NButton>
</div>
</div>
</div>
+12 -2
View File
@@ -1,7 +1,14 @@
import { request, optionalResource } from '../../lib/http'
import type { Checkpoint } from '../workflows/types'
import type { WorkflowExecutionStart } from '../workflows/execution.types'
import type { CreateProjectInput, DramaState, Project, ProjectDetail, ProjectStageReadiness, UpdateProjectInput } from './types'
import type {
CreateProjectInput,
DramaState,
Project,
ProjectDetail,
ProjectStageReadiness,
UpdateProjectInput
} from './types'
/** 项目与 Create Drama API;路径严格对应后端 dev。 */
export const projectsApi = {
@@ -11,7 +18,10 @@ export const projectsApi = {
stageReadiness: (id: string, signal?: AbortSignal) =>
request<ProjectStageReadiness>(`/projects/${encodeURIComponent(id)}/stage-readiness`, { signal }),
create: (input: CreateProjectInput) =>
request<{ projectId: string; status: string; executionId: string }>('/projects', { method: 'POST', body: input }),
request<{ projectId: string; status: string; executionId: string }>('/projects', {
method: 'POST',
body: input
}),
update: (id: string, input: UpdateProjectInput) =>
request<Project>(`/projects/${encodeURIComponent(id)}`, { method: 'PUT', body: input }),
deleteReadiness: (id: string, signal?: AbortSignal) =>
@@ -17,6 +17,8 @@ const open = ref(false)
const busy = ref(false)
/** 创建请求的错误提示。 */
const error = ref('')
/** 公共表单实例,底栏和回车提交共用同一字段校验。 */
const formRef = ref<InstanceType<typeof AppForm> | null>(null)
/** 与后端 POST /projects 入参一致的创建表单。 */
const form = reactive({ title: '', topic: '', style: '', episodeCount: 1 })
@@ -61,6 +63,7 @@ const rules = {
><NButton @click="open = true" type="primary"><Plus :size="16" />新建剧本</NButton></template
>
<AppForm
ref="formRef"
:model="form"
:rules="rules"
:disabled="busy"
@@ -116,11 +119,10 @@ const rules = {
建议先用 1 集验证生成效果。生成会实际调用后端模型,产生相应费用。
</p>
<NAlert v-if="error" role="alert" type="error" :show-icon="false" class=" ">{{ error }}</NAlert>
</AppForm>
<template #footer>
<NButton :disabled="busy" @click="open = false">取消</NButton>
<NButton :disabled="busy" type="primary" @click="submit">
<NButton :disabled="busy" type="primary" @click="formRef?.validate(submit)">
<LoaderCircle v-if="busy" :size="16" class="animate-spin" />
开始生成
<ArrowRight v-if="!busy" :size="16" />
@@ -53,18 +53,29 @@ async function remove() {
<template>
<AppDialog v-model:open="open" :title="`永久删除 · ${expected}`" description="删除后无法恢复。">
<NAlert type="error" :show-icon="false" class="mt-4">
会永久删除剧本、主体、身份、形态、分镜、首帧、视频、工作流记录,以及本地 Storage 中属于该项目的图片、视频和上传素材。
会永久删除剧本、主体、身份、形态、分镜、首帧、视频、工作流记录,以及本地 Storage
中属于该项目的图片、视频和上传素材。
</NAlert>
<NAlert v-if="readinessPending" type="info" :show-icon="false" class="mt-3">正在检查项目后台任务…</NAlert>
<NAlert v-else-if="readiness && !readiness.canDelete" type="warning" :show-icon="false" class="mt-3">
当前有 {{ readiness.totalActiveTasks }} 个后台任务正在执行,暂不能删除。请等待图片、首帧、视频或工作流任务结束后再试。
当前有
{{ readiness.totalActiveTasks }}
个后台任务正在执行,暂不能删除。请等待图片、首帧、视频或工作流任务结束后再试。
</NAlert>
<NAlert v-if="state.error" type="error" :show-icon="false" class="mt-3">{{ state.error }}</NAlert>
<p class="mt-5 text-xs">请输入 <strong>{{ expected }}</strong> 确认删除:</p>
<p class="mt-5 text-xs">
请输入 <strong>{{ expected }}</strong> 确认删除:
</p>
<NInput v-model:value="state.confirm" class="mt-2" placeholder="输入项目名称" />
<template #footer>
<NButton @click="open = false">取消</NButton>
<NButton type="error" :loading="state.pending" :disabled="!confirmed || readinessPending || !readiness?.canDelete" @click="remove">永久删除项目</NButton>
<NButton
type="error"
:loading="state.pending"
:disabled="!confirmed || readinessPending || !readiness?.canDelete"
@click="remove"
>永久删除项目</NButton
>
</template>
</AppDialog>
</template>
@@ -31,11 +31,23 @@ watch(
{ immediate: true }
)
async function save() {
if (!props.project || state.pending || !dirty.value || !form.title.trim() || !form.topic.trim() || !form.style.trim()) return
if (
!props.project ||
state.pending ||
!dirty.value ||
!form.title.trim() ||
!form.topic.trim() ||
!form.style.trim()
)
return
state.pending = true
state.error = ''
try {
await projectsApi.update(props.project.id, { title: form.title.trim(), topic: form.topic.trim(), style: form.style.trim() })
await projectsApi.update(props.project.id, {
title: form.title.trim(),
topic: form.topic.trim(),
style: form.style.trim()
})
emit('changed')
open.value = false
} catch (cause) {
@@ -46,16 +58,32 @@ async function save() {
}
</script>
<template>
<AppDialog v-model:open="open" :title="`编辑项目 · ${project?.title || project?.topic || ''}`" description="仅更新项目基础信息,不自动重生成剧本或 Production 资产。">
<AppDialog
v-model:open="open"
:title="`编辑项目 · ${project?.title || project?.topic || ''}`"
description="仅更新项目基础信息,不自动重生成剧本或 Production 资产。"
>
<NAlert v-if="state.error" type="error" :show-icon="false" class="mt-4">{{ state.error }}</NAlert>
<section class="dialog-form-stack">
<label class="block text-xs">项目名称<NInput v-model:value="form.title" class="mt-2" /></label>
<label class="block text-xs">故事主题<NInput v-model:value="form.topic" type="textarea" :autosize="{ minRows: 3, maxRows: 8 }" class="mt-2" /></label>
<label class="block text-xs"
>故事主题<NInput
v-model:value="form.topic"
type="textarea"
:autosize="{ minRows: 3, maxRows: 8 }"
class="mt-2"
/></label>
<label class="block text-xs">风格<NInput v-model:value="form.style" class="mt-2" /></label>
</section>
<template #footer>
<NButton @click="open = false">取消</NButton>
<NButton type="primary" :loading="state.pending" :disabled="!dirty || !form.title.trim() || !form.topic.trim() || !form.style.trim()" @click="save">保存项目</NButton>
<NButton
type="primary"
:loading="state.pending"
:disabled="!dirty || !form.title.trim() || !form.topic.trim() || !form.style.trim()"
@click="save"
>保存项目</NButton
>
</template>
</AppDialog>
</template>
+2 -1
View File
@@ -23,7 +23,8 @@ export function useProjectData(id: Ref<string>) {
const projectId = id.value
if (!projectId || !query.data.value) return
const nextReadiness = await projectsApi.stageReadiness(projectId)
if (id.value === projectId && query.data.value) query.data.value = { ...query.data.value, stageReadiness: nextReadiness }
if (id.value === projectId && query.data.value)
query.data.value = { ...query.data.value, stageReadiness: nextReadiness }
}
return { ...query, project, checkpoints, stageReadiness, refreshStageReadiness }
}
+20 -4
View File
@@ -35,8 +35,16 @@ export function useProjectStageAccess(projectId: Ref<string>, readiness: Ref<Pro
state?.visualStyle.reason ||
state?.identity.reason ||
'请先完成主体身份准备',
nextPath: state?.visualStyle.ready ? 'subject-identity' : state?.breakdown.ready ? 'visual-style' : 'breakdown',
nextLabel: state?.visualStyle.ready ? '前往主体身份' : state?.breakdown.ready ? '前往视觉风格' : '前往剧本拆解'
nextPath: state?.visualStyle.ready
? 'subject-identity'
: state?.breakdown.ready
? 'visual-style'
: 'breakdown',
nextLabel: state?.visualStyle.ready
? '前往主体身份'
: state?.breakdown.ready
? '前往视觉风格'
: '前往剧本拆解'
},
storyboard: {
enabled: Boolean(state?.breakdown.ready && state?.subjectAssets.ready),
@@ -51,8 +59,16 @@ export function useProjectStageAccess(projectId: Ref<string>, readiness: Ref<Pro
state?.subjectAssets.reason ||
state?.storyboard.reason ||
'请先完成镜头制作准备',
nextPath: state?.subjectAssets.ready ? 'storyboard' : state?.breakdown.ready ? 'subject-images' : 'breakdown',
nextLabel: state?.subjectAssets.ready ? '前往分镜设计' : state?.breakdown.ready ? '前往形态图片' : '前往剧本拆解'
nextPath: state?.subjectAssets.ready
? 'storyboard'
: state?.breakdown.ready
? 'subject-images'
: 'breakdown',
nextLabel: state?.subjectAssets.ready
? '前往分镜设计'
: state?.breakdown.ready
? '前往形态图片'
: '前往剧本拆解'
}
}
})