diff --git a/src/features/projects/access.ts b/src/features/projects/access.ts index 98a6401..195b176 100644 --- a/src/features/projects/access.ts +++ b/src/features/projects/access.ts @@ -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 } -/** 侧栏与项目布局共享同一份判定,初次读取和切换项目时默认锁定。 */ export const projectAccessKey: InjectionKey> = Symbol('project-access') -/** 仅正式项目状态 completed 解锁下游;已有部分剧集或旧 checkpoint 不代表剧本完成。 */ +/** 正式项目状态 completed 才表示剧本创作结束。 */ export function isProjectComplete(project: Pick | 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 +}