From 3d888ce28d9144573386c9f65a591648b8ad22a9 Mon Sep 17 00:00:00 2001 From: GouJ Date: Sat, 26 Sep 2026 21:22:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=8F=90=E5=8F=96=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=87=86=E5=85=A5=E7=8A=B6=E6=80=81=E6=9E=84=E9=80=A0?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/projects/useProjectStageAccess.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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: '前往剧本拆解' },