feat(short-drama-agent-front): 完善分镜审核与制作准备流程
This commit is contained in:
1 parent
c4b43b9725
commit
1da56e0d46
72 files changed
+2801
-528
No files matched your search
@@ -3,6 +3,7 @@ import ContextNotice from '../../components/ui/ContextNotice.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 } from 'naive-ui'
|
||||
import { EmptyState, WorkspaceRefreshButton } from '../../components/ui'
|
||||
import { projectContextKey, useProjectData } from './context'
|
||||
@@ -13,8 +14,9 @@ import { useWorkflowExecution } from '../workflows/execution'
|
||||
import { clearEpisodeSourceInvalidations, invalidateEpisodeSource } from '../storyboard/model'
|
||||
import { useActionMessage } from '../../components/ui/useActionMessage'
|
||||
import { productionMessage } from '../production/production-messages'
|
||||
import StoryboardPreparation from '../storyboard-preparation/StoryboardPreparation.vue'
|
||||
import ProjectSettingsDialog from '../generation-config/components/ProjectSettingsDialog.vue'
|
||||
import { projectGenerationRevisionKey } from '../generation-config/context'
|
||||
import { projectGenerationRevisionKey, projectSettingsOpenKey } from '../generation-config/context'
|
||||
import CreateDramaSkeleton from '../create-drama/CreateDramaSkeleton.vue'
|
||||
import BreakdownSkeleton from '../breakdown/BreakdownSkeleton.vue'
|
||||
import VisualStyleSkeleton from '../visual-style/VisualStyleSkeleton.vue'
|
||||
@@ -36,6 +38,11 @@ const generationRevision = ref(0)
|
||||
provide(projectGenerationRevisionKey, generationRevision)
|
||||
/** 项目标题栏共用配置弹窗开关。 */
|
||||
const settingsOpen = ref(false)
|
||||
/** 打开标题栏已有的项目配置抽屉,保留当前镜头与工作区。 */
|
||||
function openProjectSettings() {
|
||||
settingsOpen.value = true
|
||||
}
|
||||
provide(projectSettingsOpenKey, openProjectSettings)
|
||||
/** 既有配置恢复链接打开同一个全局弹窗,不切换工作区。 */
|
||||
watch(
|
||||
() => route.query.configure,
|
||||
@@ -257,9 +264,13 @@ onScopeDispose(() => {
|
||||
}}</NEllipsis>
|
||||
</template>
|
||||
<template #extra>
|
||||
<NButton size="small" :disabled="!context.project.value" @click="settingsOpen = true"
|
||||
>项目配置</NButton
|
||||
<!-- 以下是制作前检查入口,后续页面受限时仍可完成正式分镜审核 -->
|
||||
<div class="flex items-center gap-2">
|
||||
<StoryboardPreparation v-if="context.project.value?.id === id" :key="id" :project-id="id" :disabled="!!context.error.value" @changed="context.refresh()" />
|
||||
<NButton class="workspace-action-button" size="small" aria-label="项目配置" title="项目配置" :disabled="!context.project.value" @click="settingsOpen = true"
|
||||
><template #icon><Settings2 :size="15" aria-hidden="true" /></template><span class="project-config-label">项目配置</span></NButton
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
</NPageHeader>
|
||||
</header>
|
||||
@@ -372,3 +383,8 @@ onScopeDispose(() => {
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<style scoped>
|
||||
/* 窄屏的两个项目操作统一显示图标,保留按钮的完整可访问名称。 */
|
||||
@media (max-width: 639px) { .project-config-label { display: none; } }
|
||||
</style>
|
||||
@@ -27,12 +27,23 @@ export const projectsApi = {
|
||||
* 显式替换完整质量策略,不触发模型生成。
|
||||
* @param id 当前项目编号
|
||||
* @param policy 用户明确确认的完整策略
|
||||
* @param expectedRevision 最后读取的服务端修订版本
|
||||
* @returns 服务端实际保存的策略
|
||||
*/
|
||||
saveQualityPolicy: (id: string, policy: ProjectQualityPolicy) =>
|
||||
saveQualityPolicy: (id: string, policy: ProjectQualityPolicy, expectedRevision: number) =>
|
||||
request<ProjectQualityPolicyResult>(`/projects/${encodeURIComponent(id)}/quality-policy`, {
|
||||
method: 'PUT',
|
||||
body: policy
|
||||
body: { policy, expectedRevision }
|
||||
}),
|
||||
/**
|
||||
* 用户明确确认当前规则;普通保存不能代替确认。
|
||||
* @param id 当前项目
|
||||
* @param expectedRevision 用户核对的服务端修订版本
|
||||
* @returns 服务保存的确认状态
|
||||
*/
|
||||
confirmQualityPolicy: (id: string, expectedRevision: number) =>
|
||||
request<ProjectQualityPolicyResult>(`/projects/${encodeURIComponent(id)}/quality-policy/confirm`, {
|
||||
method: 'POST', body: { expectedRevision }
|
||||
}),
|
||||
list: (signal?: AbortSignal) => request<Project[]>('/projects', { signal }),
|
||||
detail: (id: string, signal?: AbortSignal) =>
|
||||
|
||||
@@ -3,17 +3,25 @@ import FeedbackMessage from '../../../components/ui/FeedbackMessage.vue'
|
||||
|
||||
import { computed, reactive, watch } from 'vue'
|
||||
import { NButton, NInput } from 'naive-ui'
|
||||
import { AppDialog } from '../../../components/ui'
|
||||
import { AppDrawer } from '../../../components/ui'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import { projectsApi } from '../api'
|
||||
import type { Project } from '../types'
|
||||
|
||||
/** 编辑项目基础信息;不会触发已有剧本或制作资产重生成。 */
|
||||
const props = defineProps<{ project: Project | null }>()
|
||||
/** 待编辑的项目基础信息;不会触发已有剧本或制作资产重生成。 */
|
||||
const props = defineProps<{
|
||||
/** 当前选中的项目。 */
|
||||
project: Project | null
|
||||
}>()
|
||||
/** 编辑项目全屏抽屉的显隐状态。 */
|
||||
const open = defineModel<boolean>('open', { default: false })
|
||||
/** 保存成功后通知列表刷新项目。 */
|
||||
const emit = defineEmits<{ changed: [] }>()
|
||||
/** 项目名称、故事主题和风格的编辑草稿。 */
|
||||
const form = reactive({ title: '', topic: '', style: '' })
|
||||
/** 保存请求状态及错误提示。 */
|
||||
const state = reactive({ pending: false, error: '' })
|
||||
/** 基础信息发生有效变更后才允许保存。 */
|
||||
const dirty = computed(
|
||||
() =>
|
||||
!!props.project &&
|
||||
@@ -32,6 +40,7 @@ watch(
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
/** 保存项目基础信息,成功后关闭抽屉并刷新列表。 */
|
||||
async function save() {
|
||||
if (
|
||||
!props.project ||
|
||||
@@ -60,40 +69,53 @@ async function save() {
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<AppDialog
|
||||
<!-- 以下是编辑项目全屏抽屉模块,标题与底栏固定、正文独立滚动 -->
|
||||
<AppDrawer
|
||||
v-model:open="open"
|
||||
:title="`编辑项目 · ${project?.title || project?.topic || ''}`"
|
||||
description="仅更新项目基础信息,不自动重生成剧本或制作资产。"
|
||||
:busy="state.pending"
|
||||
>
|
||||
<!-- 以下是保存失败提示模块 -->
|
||||
<FeedbackMessage v-if="state.error" :message="state.error" />
|
||||
|
||||
<!-- 以下是单列铺满可用宽度的项目基本信息模块 -->
|
||||
<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.title" :disabled="state.pending" class="mt-2"
|
||||
/></label>
|
||||
|
||||
<!-- 以下是加高的故事主题编辑模块,随内容自动增高 -->
|
||||
<label class="block text-xs"
|
||||
>故事主题<NInput
|
||||
v-model:value="form.topic"
|
||||
:disabled="state.pending"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 3, maxRows: 8 }"
|
||||
:autosize="{ minRows: 10, maxRows: 20 }"
|
||||
class="project-story-input mt-2"
|
||||
/></label>
|
||||
<!-- 以下是与新增弹窗共用内边距的多行风格编辑模块,随内容自动增高 -->
|
||||
|
||||
<!-- 以下是与故事主题保持相同高度规则的风格编辑模块 -->
|
||||
<label class="block text-xs"
|
||||
>风格<NInput
|
||||
v-model:value="form.style"
|
||||
:disabled="state.pending"
|
||||
type="textarea"
|
||||
:autosize="{ minRows: 3, maxRows: 8 }"
|
||||
:autosize="{ minRows: 10, maxRows: 20 }"
|
||||
class="project-story-input mt-2"
|
||||
/></label>
|
||||
</section>
|
||||
|
||||
<!-- 以下是固定底部操作模块,保存期间禁止重复操作或关闭 -->
|
||||
<template #footer>
|
||||
<NButton @click="open = false">取消</NButton>
|
||||
<NButton :disabled="state.pending" @click="open = false">取消</NButton>
|
||||
<NButton
|
||||
type="primary"
|
||||
:loading="state.pending"
|
||||
:disabled="!dirty || !form.title.trim() || !form.topic.trim() || !form.style.trim()"
|
||||
:disabled="state.pending || !dirty || !form.title.trim() || !form.topic.trim() || !form.style.trim()"
|
||||
@click="save"
|
||||
>保存项目</NButton
|
||||
>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</AppDrawer>
|
||||
</template>
|
||||
@@ -1,8 +1,5 @@
|
||||
import { policyIssue } from './quality-policy'
|
||||
import type { ProjectQualityPolicy } from './types'
|
||||
|
||||
/** 同一页面中主动保存规则后,也撤销无法持久化的临时确认。 */
|
||||
const invalidations = new Map<string, number>()
|
||||
import type { ProjectQualityPolicy, ProjectQualityPolicyResult } from './types'
|
||||
|
||||
/**
|
||||
* 只比较质量规则的规范化内容,不把模型参数或对象属性顺序作为变更。
|
||||
@@ -32,62 +29,29 @@ export function qualityPolicySignature(policy: ProjectQualityPolicy): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 隔离项目及本地确认格式版本。
|
||||
* 核对服务回执的项目、内容与修订字段;缺失时不能使用默认版本补齐。
|
||||
* @param result 规则接口原始回执
|
||||
* @param projectId 当前项目
|
||||
* @returns 本地 UX 记忆键
|
||||
* @returns 已核对的完整回执
|
||||
*/
|
||||
function confirmationKey(projectId: string): string {
|
||||
return `short-drama:breakdown-quality-confirmation:v1:${projectId}`
|
||||
export function validateQualityPolicyReceipt(result: ProjectQualityPolicyResult, projectId: string): ProjectQualityPolicyResult {
|
||||
if (!result || result.projectId !== projectId) throw new Error('质量规则所属项目不一致,请重新读取。')
|
||||
qualityPolicySignature(result.policy)
|
||||
if (!Number.isSafeInteger(result.revision) || result.revision < 0 ||
|
||||
!/^[a-f\d]{64}$/.test(result.fingerprint) || typeof result.confirmed !== 'boolean' ||
|
||||
!(result.confirmedRevision === null || Number.isSafeInteger(result.confirmedRevision) && result.confirmedRevision >= 0) ||
|
||||
!(result.confirmedAt === null || typeof result.confirmedAt === 'string' && Number.isFinite(Date.parse(result.confirmedAt))))
|
||||
throw new Error('质量规则确认信息不完整,请重新读取。')
|
||||
if (result.confirmed && !qualityPolicyConfirmed(result)) throw new Error('质量规则确认版本不一致,请重新读取。')
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取当前浏览器明确确认过的规则,不将默认值当作确认。
|
||||
* @param projectId 当前项目
|
||||
* @returns 已确认内容或空值,损坏与不可用存储均不视为确认
|
||||
* 仅认可服务保存的同修订明确确认,浏览器本地记录不构成确认。
|
||||
* @param result 已读取的规则回执
|
||||
* @returns 当前修订是否已经明确确认
|
||||
*/
|
||||
export function readQualityPolicyConfirmation(projectId: string): string | null {
|
||||
try {
|
||||
const raw = localStorage.getItem(confirmationKey(projectId))
|
||||
if (!raw) return null
|
||||
const parsed: unknown = JSON.parse(raw)
|
||||
if (!parsed || typeof parsed !== 'object' || !('signature' in parsed) ||
|
||||
!('formatVersion' in parsed) || parsed.formatVersion !== 1 ||
|
||||
typeof parsed.signature !== 'string') return null
|
||||
return parsed.signature
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅在用户明确确认后记住当前浏览器的规则内容,不能代替后端门禁。
|
||||
* @param projectId 当前项目
|
||||
* @param signature 已核对的规则内容
|
||||
* @returns 是否成功持久化,失败时调用方只保留本次会话确认
|
||||
*/
|
||||
export function rememberQualityPolicyConfirmation(projectId: string, signature: string): boolean {
|
||||
try {
|
||||
localStorage.setItem(confirmationKey(projectId), JSON.stringify({ formatVersion: 1, signature }))
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 规则有实质变化时撤销本地确认,无变化保存不调用此方法。
|
||||
* @param projectId 规则所属项目
|
||||
*/
|
||||
export function invalidateQualityPolicyConfirmation(projectId: string) {
|
||||
invalidations.set(projectId, qualityPolicyConfirmationEpoch(projectId) + 1)
|
||||
try { localStorage.removeItem(confirmationKey(projectId)) } catch { /* 存储受限时仍撤销页面内确认。 */ }
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前页面内的确认失效代次,用于存储受限的降级场景。
|
||||
* @param projectId 当前项目
|
||||
* @returns 规则失效代次
|
||||
*/
|
||||
export function qualityPolicyConfirmationEpoch(projectId: string): number {
|
||||
return invalidations.get(projectId) ?? 0
|
||||
export function qualityPolicyConfirmed(result: ProjectQualityPolicyResult): boolean {
|
||||
return result.confirmed === true && result.confirmedRevision === result.revision &&
|
||||
typeof result.confirmedAt === 'string' && Number.isFinite(Date.parse(result.confirmedAt))
|
||||
}
|
||||
@@ -186,4 +186,14 @@ export interface ProjectQualityPolicyResult {
|
||||
projectId: string
|
||||
/** 服务端实际保存或解析的策略。 */
|
||||
policy: ProjectQualityPolicy
|
||||
/** 服务端修订版本,独立于规则格式版本。 */
|
||||
revision: number
|
||||
/** 服务端规则内容指纹。 */
|
||||
fingerprint: string
|
||||
/** 当前修订是否已明确确认。 */
|
||||
confirmed: boolean
|
||||
/** 最近明确确认的修订,尚未确认时为空。 */
|
||||
confirmedRevision: number | null
|
||||
/** 服务端记录的确认时间。 */
|
||||
confirmedAt: string | null
|
||||
}
|
||||
Reference in new issue
Block a user