From 76e586a5cd548281dfdffba62ca0b59dd9e788f3 Mon Sep 17 00:00:00 2001 From: GouJ Date: Sat, 26 Sep 2026 21:02:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=BB=9F=E4=B8=80=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=88=B6=E4=BD=9C=E9=98=B6=E6=AE=B5=E5=87=86=E5=85=A5?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/projects/access.ts | 38 ++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) 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 +}