import { computed } from 'vue' import { useProjectContext } from '../projects/context' import { getOperation } from './operations' import { workflowCheckpoints } from './selectors' /** 资产编辑沿用项目级互斥;剧本生成或拆解期间不修改其下游资产。 */ export function useProjectMutationGuard() { const context = useProjectContext() const projectId = computed(() => context.project.value?.id ?? '') const operation = computed(() => getOperation(projectId.value)) const blocked = computed( () => !projectId.value || !!context.error.value || operation.value.pending || context.project.value?.status === 'generating' || workflowCheckpoints(context.checkpoints.value, 'breakdown').at(-1)?.state.workflowExecution?.status === 'running' ) return { projectId, operation, blocked } }