refactor: 项目准入直接消费统一阶段状态

This commit is contained in:
GouJ committed 2026-09-26 21:15:21 +08:00
1 parent 2a2a81772d
commit 184cb4b1dd
1 file changed
+57 -67
+57 -67
View File
@@ -1,71 +1,61 @@
import { computed, type Ref } from 'vue' import { computed, type Ref } from 'vue'
import { breakdownSnapshot } from '../workflows/selectors' import type { ProjectAccess, ProjectSection } from './access'
import type { ProjectSection, ProjectAccess } from './access' import type { ProjectStageReadiness } from './types'
import type { ProjectDetail } from './types'
import type { Checkpoint } from '../workflows/types'
/** /** 将服务端统一 readiness 转为侧栏、URL 门禁和下一步引导,前端不复制制作规则。 */
* 主流程准入只使用已经持久化且当前项目可读取的数据。 export function useProjectStageAccess(projectId: Ref<string>, readiness: Ref<ProjectStageReadiness | null>) {
* 更细的身份、图片和分镜 readiness 由对应页面与 Production Plan 继续校验, const sections = computed<Record<ProjectSection, ProjectAccess['sections'][ProjectSection]>>(() => {
* 避免前端复制服务端业务规则。 const state = readiness.value
*/ const own = (ready: boolean | undefined, reason: string | null | undefined, fallback: string) => ({
export function useProjectStageAccess( enabled: Boolean(ready),
projectId: Ref<string>, reason: reason || fallback
project: Ref<ProjectDetail | null>, })
checkpoints: Ref<Checkpoint[]> return {
) { 'create-drama': { enabled: true, reason: '' },
const scriptReady = computed(() => project.value?.id === projectId.value && project.value.status === 'completed') breakdown: {
const breakdownReady = computed(() => { ...own(state?.script.ready, state?.script.reason, '请先完成剧本创作'),
if (!scriptReady.value) return false nextPath: 'create-drama',
const snapshot = breakdownSnapshot(checkpoints.value) nextLabel: '前往剧本创作'
const result = snapshot?.breakdownResult ?? snapshot },
return Boolean( 'visual-style': {
result?.subjectCandidates?.length && ...own(state?.breakdown.ready, state?.breakdown.reason, '请先完成剧本拆解'),
result?.subjectForms?.length && nextPath: 'breakdown',
result?.storyboardEpisodeShots?.length && nextLabel: '前往剧本拆解'
result?.storyboardShotValidation?.valid },
) 'subject-identity': {
}) enabled: Boolean(state?.breakdown.ready && state?.visualStyle.ready),
reason: state?.breakdown.reason || state?.visualStyle.reason || '请先准备视觉风格',
const sections = computed<Record<ProjectSection, ProjectAccess['sections'][ProjectSection]>>(() => ({ nextPath: state?.breakdown.ready ? 'visual-style' : 'breakdown',
'create-drama': { enabled: true, reason: '' }, nextLabel: state?.breakdown.ready ? '前往视觉风格' : '前往剧本拆解'
breakdown: { },
enabled: scriptReady.value, 'subject-images': {
reason: '请先完成剧本创作', enabled: Boolean(state?.breakdown.ready && state?.visualStyle.ready && state?.identity.ready),
nextPath: 'create-drama', reason:
nextLabel: '前往剧本创作' state?.breakdown.reason ||
}, state?.visualStyle.reason ||
'visual-style': { state?.identity.reason ||
enabled: breakdownReady.value, '请先完成主体身份准备',
reason: '请先完成剧本拆解,准备好人物、场景、道具和镜头', nextPath: state?.visualStyle.ready ? 'subject-identity' : state?.breakdown.ready ? 'visual-style' : 'breakdown',
nextPath: 'breakdown', nextLabel: state?.visualStyle.ready ? '前往主体身份' : state?.breakdown.ready ? '前往视觉风格' : '前往剧本拆解'
nextLabel: '前往剧本拆解' },
}, storyboard: {
'subject-identity': { enabled: Boolean(state?.breakdown.ready && state?.subjectAssets.ready),
enabled: breakdownReady.value, reason: state?.breakdown.reason || state?.subjectAssets.reason || '请先准备主体素材',
reason: '请先完成剧本拆解,准备好需要制作的主体', nextPath: state?.breakdown.ready ? 'subject-images' : 'breakdown',
nextPath: 'breakdown', nextLabel: state?.breakdown.ready ? '前往形态图片' : '前往剧本拆解'
nextLabel: '前往剧本拆解' },
}, production: {
'subject-images': { enabled: Boolean(state?.breakdown.ready && state?.subjectAssets.ready && state?.storyboard.ready),
enabled: breakdownReady.value, reason:
reason: '请先完成剧本拆解和主体准备', state?.breakdown.reason ||
nextPath: 'subject-identity', state?.subjectAssets.reason ||
nextLabel: '前往主体身份' state?.storyboard.reason ||
}, '请先完成镜头制作准备',
storyboard: { nextPath: state?.subjectAssets.ready ? 'storyboard' : state?.breakdown.ready ? 'subject-images' : 'breakdown',
enabled: breakdownReady.value, nextLabel: state?.subjectAssets.ready ? '前往分镜设计' : state?.breakdown.ready ? '前往形态图片' : '前往剧本拆解'
reason: '请先完成剧本拆解,生成正式镜头后再进行分镜设计', }
nextPath: 'breakdown',
nextLabel: '前往剧本拆解'
},
production: {
enabled: breakdownReady.value,
reason: '请先完成剧本拆解。进入镜头生产后还会检查主体素材和分镜设计是否齐全',
nextPath: 'breakdown',
nextLabel: '前往剧本拆解'
} }
})) })
const scriptReady = computed(() => readiness.value?.script.ready === true)
return { scriptReady, breakdownReady, sections } return { projectId, scriptReady, sections }
} }