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 才表示剧本创作结束。 */ 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 }