refactor: 项目准入直接消费统一阶段状态
This commit is contained in:
1 parent
2a2a81772d
commit
184cb4b1dd
1 file changed
+40
-50
@@ -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[]>
|
|
||||||
) {
|
|
||||||
const scriptReady = computed(() => project.value?.id === projectId.value && project.value.status === 'completed')
|
|
||||||
const breakdownReady = computed(() => {
|
|
||||||
if (!scriptReady.value) return false
|
|
||||||
const snapshot = breakdownSnapshot(checkpoints.value)
|
|
||||||
const result = snapshot?.breakdownResult ?? snapshot
|
|
||||||
return Boolean(
|
|
||||||
result?.subjectCandidates?.length &&
|
|
||||||
result?.subjectForms?.length &&
|
|
||||||
result?.storyboardEpisodeShots?.length &&
|
|
||||||
result?.storyboardShotValidation?.valid
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
return {
|
||||||
const sections = computed<Record<ProjectSection, ProjectAccess['sections'][ProjectSection]>>(() => ({
|
|
||||||
'create-drama': { enabled: true, reason: '' },
|
'create-drama': { enabled: true, reason: '' },
|
||||||
breakdown: {
|
breakdown: {
|
||||||
enabled: scriptReady.value,
|
...own(state?.script.ready, state?.script.reason, '请先完成剧本创作'),
|
||||||
reason: '请先完成剧本创作',
|
|
||||||
nextPath: 'create-drama',
|
nextPath: 'create-drama',
|
||||||
nextLabel: '前往剧本创作'
|
nextLabel: '前往剧本创作'
|
||||||
},
|
},
|
||||||
'visual-style': {
|
'visual-style': {
|
||||||
enabled: breakdownReady.value,
|
...own(state?.breakdown.ready, state?.breakdown.reason, '请先完成剧本拆解'),
|
||||||
reason: '请先完成剧本拆解,准备好人物、场景、道具和镜头',
|
|
||||||
nextPath: 'breakdown',
|
nextPath: 'breakdown',
|
||||||
nextLabel: '前往剧本拆解'
|
nextLabel: '前往剧本拆解'
|
||||||
},
|
},
|
||||||
'subject-identity': {
|
'subject-identity': {
|
||||||
enabled: breakdownReady.value,
|
enabled: Boolean(state?.breakdown.ready && state?.visualStyle.ready),
|
||||||
reason: '请先完成剧本拆解,准备好需要制作的主体',
|
reason: state?.breakdown.reason || state?.visualStyle.reason || '请先准备视觉风格',
|
||||||
nextPath: 'breakdown',
|
nextPath: state?.breakdown.ready ? 'visual-style' : 'breakdown',
|
||||||
nextLabel: '前往剧本拆解'
|
nextLabel: state?.breakdown.ready ? '前往视觉风格' : '前往剧本拆解'
|
||||||
},
|
},
|
||||||
'subject-images': {
|
'subject-images': {
|
||||||
enabled: breakdownReady.value,
|
enabled: Boolean(state?.breakdown.ready && state?.visualStyle.ready && state?.identity.ready),
|
||||||
reason: '请先完成剧本拆解和主体准备',
|
reason:
|
||||||
nextPath: 'subject-identity',
|
state?.breakdown.reason ||
|
||||||
nextLabel: '前往主体身份'
|
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 ? '前往视觉风格' : '前往剧本拆解'
|
||||||
},
|
},
|
||||||
storyboard: {
|
storyboard: {
|
||||||
enabled: breakdownReady.value,
|
enabled: Boolean(state?.breakdown.ready && state?.subjectAssets.ready),
|
||||||
reason: '请先完成剧本拆解,生成正式镜头后再进行分镜设计',
|
reason: state?.breakdown.reason || state?.subjectAssets.reason || '请先准备主体素材',
|
||||||
nextPath: 'breakdown',
|
nextPath: state?.breakdown.ready ? 'subject-images' : 'breakdown',
|
||||||
nextLabel: '前往剧本拆解'
|
nextLabel: state?.breakdown.ready ? '前往形态图片' : '前往剧本拆解'
|
||||||
},
|
},
|
||||||
production: {
|
production: {
|
||||||
enabled: breakdownReady.value,
|
enabled: Boolean(state?.breakdown.ready && state?.subjectAssets.ready && state?.storyboard.ready),
|
||||||
reason: '请先完成剧本拆解。进入镜头生产后还会检查主体素材和分镜设计是否齐全',
|
reason:
|
||||||
nextPath: 'breakdown',
|
state?.breakdown.reason ||
|
||||||
nextLabel: '前往剧本拆解'
|
state?.subjectAssets.reason ||
|
||||||
|
state?.storyboard.reason ||
|
||||||
|
'请先完成镜头制作准备',
|
||||||
|
nextPath: state?.subjectAssets.ready ? 'storyboard' : state?.breakdown.ready ? 'subject-images' : 'breakdown',
|
||||||
|
nextLabel: state?.subjectAssets.ready ? '前往分镜设计' : state?.breakdown.ready ? '前往形态图片' : '前往剧本拆解'
|
||||||
}
|
}
|
||||||
}))
|
}
|
||||||
|
})
|
||||||
return { scriptReady, breakdownReady, sections }
|
const scriptReady = computed(() => readiness.value?.script.ready === true)
|
||||||
|
return { projectId, scriptReady, sections }
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user