diff --git a/src/features/projects/useProjectStageAccess.ts b/src/features/projects/useProjectStageAccess.ts index 000160c..ec77ef2 100644 --- a/src/features/projects/useProjectStageAccess.ts +++ b/src/features/projects/useProjectStageAccess.ts @@ -2,23 +2,23 @@ import { computed, type Ref } from 'vue' import type { ProjectAccess, ProjectSection } from './access' import type { ProjectStageReadiness } from './types' +function accessState(ready: boolean | undefined, reason: string | null | undefined, fallback: string) { + return { enabled: Boolean(ready), reason: reason || fallback } +} + /** 将服务端统一 readiness 转为侧栏、URL 门禁和下一步引导,前端不复制制作规则。 */ export function useProjectStageAccess(projectId: Ref, readiness: Ref) { const sections = computed>(() => { const state = readiness.value - const own = (ready: boolean | undefined, reason: string | null | undefined, fallback: string) => ({ - enabled: Boolean(ready), - reason: reason || fallback - }) return { 'create-drama': { enabled: true, reason: '' }, breakdown: { - ...own(state?.script.ready, state?.script.reason, '请先完成剧本创作'), + ...accessState(state?.script.ready, state?.script.reason, '请先完成剧本创作'), nextPath: 'create-drama', nextLabel: '前往剧本创作' }, 'visual-style': { - ...own(state?.breakdown.ready, state?.breakdown.reason, '请先完成剧本拆解'), + ...accessState(state?.breakdown.ready, state?.breakdown.reason, '请先完成剧本拆解'), nextPath: 'breakdown', nextLabel: '前往剧本拆解' },