refactor: 统一项目制作阶段准入类型
This commit is contained in:
1 parent
ffa8c4be52
commit
76e586a5cd
1 file changed
+35
-3
@@ -1,16 +1,48 @@
|
||||
import type { InjectionKey, ShallowRef } from 'vue'
|
||||
import type { Project } from './types'
|
||||
|
||||
/** 由项目布局发布给应用侧栏的访问状态;不额外请求或持久化项目数据。 */
|
||||
export type ProjectSection =
|
||||
| 'create-drama'
|
||||
| 'breakdown'
|
||||
| 'visual-style'
|
||||
| 'subject-identity'
|
||||
| 'subject-images'
|
||||
| 'storyboard'
|
||||
| 'production'
|
||||
|
||||
export interface ProjectSectionAccess {
|
||||
enabled: boolean
|
||||
reason: string
|
||||
nextPath?: ProjectSection
|
||||
nextLabel?: string
|
||||
}
|
||||
|
||||
/** 项目侧栏与项目布局共享同一份制作阶段准入结果。 */
|
||||
export interface ProjectAccess {
|
||||
projectId: string
|
||||
completed: boolean
|
||||
sections: Record<ProjectSection, ProjectSectionAccess>
|
||||
}
|
||||
|
||||
/** 侧栏与项目布局共享同一份判定,初次读取和切换项目时默认锁定。 */
|
||||
export const projectAccessKey: InjectionKey<ShallowRef<ProjectAccess | null>> = Symbol('project-access')
|
||||
|
||||
/** 仅正式项目状态 completed 解锁下游;已有部分剧集或旧 checkpoint 不代表剧本完成。 */
|
||||
/** 正式项目状态 completed 才表示剧本创作结束。 */
|
||||
export function isProjectComplete(project: Pick<Project, 'id' | 'status'> | null, projectId: string): boolean {
|
||||
return !!projectId && project?.id === projectId && project.status === 'completed'
|
||||
}
|
||||
|
||||
/** 路由末段映射到制作工作区;项目资产库不参与主流程门禁。 */
|
||||
export function projectSectionFromPath(path: string): ProjectSection | null {
|
||||
const section = path.replace(/\/+$/, '').split('/').at(-1)
|
||||
return [
|
||||
'create-drama',
|
||||
'breakdown',
|
||||
'visual-style',
|
||||
'subject-identity',
|
||||
'subject-images',
|
||||
'storyboard',
|
||||
'production'
|
||||
].includes(section ?? '')
|
||||
? (section as ProjectSection)
|
||||
: null
|
||||
}
|
||||
Reference in new issue
Block a user