feat(short-drama-agent-front): 接入素材预览审核并完善创作流程
This commit is contained in:
1 parent
f8b0fbb8ca
commit
dc8bb17a23
66 files changed
+2864
-632
No files matched your search
@@ -10,6 +10,7 @@ import { useQuery } from '../../../composables/useQuery'
|
||||
import { useProjectContext } from '../../projects/context'
|
||||
import { workflowCheckpoints } from '../../workflows/selectors'
|
||||
import DramaRewriteAction from './DramaRewriteAction.vue'
|
||||
import DramaSystemReviewAction from './DramaSystemReviewAction.vue'
|
||||
import ManualReviewIssueEditor from './ManualReviewIssueEditor.vue'
|
||||
import ReviewUncertaintyCard from './ReviewUncertaintyCard.vue'
|
||||
import { reviewCategoryOptions, suggestionForUncertainty, savedReviewDecisions } from './model'
|
||||
@@ -87,12 +88,12 @@ const hasRewriteTargets = computed(
|
||||
)
|
||||
)
|
||||
/** 当前有效预检只强调一个下一步入口,配色不代替服务端操作权限。 */
|
||||
const primaryAction = computed<'confirm' | 'rewrite' | null>(() => {
|
||||
const primaryAction = computed<'review' | 'rewrite' | null>(() => {
|
||||
if (flow.locked.value || rewriteQuery.loading.value || rewriteQuery.error.value || latest.value?.passed !== false)
|
||||
return null
|
||||
if (currentRewrite.value?.status === 'blocked' || currentRewrite.value?.status === 'stale') return null
|
||||
if (hasRewriteTargets.value) return currentRewrite.value?.ready === true ? 'rewrite' : null
|
||||
return hasManualIssues.value ? 'confirm' : null
|
||||
return hasManualIssues.value ? 'review' : null
|
||||
})
|
||||
/** 剧集范围同样读取真实改写预检,设定单独改写不伪造成剧集任务。 */
|
||||
const rewriteEpisodeSummary = computed(() => {
|
||||
@@ -117,9 +118,9 @@ const nextStep = computed(() => {
|
||||
description: `${scope}已有改写依据。点击“改写预检”核对范围${hasManualIssues.value ? ';待确认问题仍可继续人工处理' : ''}。开始改写前会再次确认费用。`
|
||||
}
|
||||
: {
|
||||
title: '请先核对审核问题',
|
||||
title: '可由系统继续核查',
|
||||
description:
|
||||
'点击“人工确认”对照原文逐项处理。确认后如需改写,会显示“改写预检”入口;所有处理都需要你确认。'
|
||||
'点击“系统重新核查”检查已保存正文,系统会优先复核疑点。只有仍无法确认的关键问题才需要人工处理。'
|
||||
}
|
||||
})
|
||||
/** 正式正文的当前阅读集号。 */
|
||||
@@ -283,10 +284,16 @@ function editorClosed() {
|
||||
:disabled="flow.writing.value"
|
||||
@refresh="flow.query.refresh"
|
||||
/>
|
||||
<DramaSystemReviewAction
|
||||
v-if="latest?.passed === false"
|
||||
:project-id="projectId"
|
||||
:primary="primaryAction === 'review'"
|
||||
:disabled="disabled || flow.locked.value"
|
||||
@started="context.refresh"
|
||||
/>
|
||||
<NButton
|
||||
v-if="hasManualIssues"
|
||||
:class="{ 'workspace-action-button': primaryAction !== 'confirm' }"
|
||||
:type="primaryAction === 'confirm' ? 'primary' : 'default'"
|
||||
class="workspace-action-button"
|
||||
aria-label="人工确认"
|
||||
:disabled="!latest || latest.passed || flow.writing.value"
|
||||
@click="flow.openEditor"
|
||||
@@ -321,6 +328,15 @@ function editorClosed() {
|
||||
reviewUncertain ? '审核状态待核对' : latest.passed ? '当前审核已通过' : '当前审核尚未通过'
|
||||
}}</NTag>
|
||||
</div>
|
||||
<!-- 以下是系统已完成的逐项复核摘要,保留关键待核对数 -->
|
||||
<p v-if="latest.automaticQualityResolution" class="text-sm text-muted">
|
||||
<template v-if="latest.automaticQualityResolution.status === 'completed'">
|
||||
系统复核了 {{ latest.automaticQualityResolution.candidateCount }} 项初审疑点, 其中
|
||||
{{ latest.automaticQualityResolution.resolvedCount }} 项已有依据,
|
||||
{{ latest.automaticQualityResolution.remainingCount }} 项仍需核对。
|
||||
</template>
|
||||
<template v-else>系统复核未完成,原审核疑点已保留。</template>
|
||||
</p>
|
||||
<!-- 以下是当前审核的下一步引导,仅在来源有效且读取完成后显示 -->
|
||||
<ContextNotice
|
||||
v-if="
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton } from 'naive-ui'
|
||||
import { FileSearch } from '@lucide/vue'
|
||||
import { AppDialog, WorkspaceRefreshButton } from '../../../components/ui'
|
||||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||||
import { useQuery } from '../../../composables/useQuery'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import { getOperation, runOperation } from '../../workflows/operations'
|
||||
import { useWorkflowExecution } from '../../workflows/execution'
|
||||
import { dramaReviewApi, loadDramaReviewResumePreview } from './api'
|
||||
|
||||
/** 已保存剧本的系统核查入口,沿用项目级活动任务锁。 */
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** 当前正式项目。 */ projectId: string
|
||||
/** 当前外部操作锁。 */ disabled?: boolean
|
||||
/** 无明确改写目标时强调系统核查。 */ primary?: boolean
|
||||
}>(),
|
||||
{ disabled: false, primary: false }
|
||||
)
|
||||
/** 后台实际受理后才通知页面刷新。 */
|
||||
const emit = defineEmits<{ started: [executionId: string, projectId: string] }>()
|
||||
/** 费用与范围确认弹窗。 */
|
||||
const open = ref(false)
|
||||
/** 正在提交,防止重复收费请求。 */
|
||||
const writing = ref(false)
|
||||
/** 只展示当前项目的操作错误。 */
|
||||
const actionError = ref('')
|
||||
/** 当前项目的公共操作状态。 */
|
||||
const operation = computed(() => getOperation(props.projectId))
|
||||
/** 弹窗打开后才查询来源。 */
|
||||
const queryKey = computed(() => (open.value ? props.projectId : ''))
|
||||
/** 只读查询可取消,关闭弹窗不启动模型。 */
|
||||
const query = useQuery(queryKey, (id, signal) =>
|
||||
id ? loadDramaReviewResumePreview(id, signal) : Promise.resolve(null)
|
||||
)
|
||||
/** 页面布局观察后台任务,本入口仅保存真实句柄。 */
|
||||
const trackerProject = ref('')
|
||||
/** 与其他创作入口共用持久化任务句柄。 */
|
||||
const tracker = useWorkflowExecution(trackerProject, 'create-drama')
|
||||
/** 当前确认来源版本。 */
|
||||
let revision = 0
|
||||
/** 二次预检的取消控制器。 */
|
||||
let controller: AbortController | undefined
|
||||
watch([open, () => props.projectId], () => {
|
||||
revision++
|
||||
controller?.abort()
|
||||
actionError.value = ''
|
||||
})
|
||||
onScopeDispose(() => {
|
||||
revision++
|
||||
controller?.abort()
|
||||
})
|
||||
/** 仅使用当前预检与真实活动状态开放提交。 */
|
||||
const ready = computed(
|
||||
() =>
|
||||
query.data.value?.ready === true &&
|
||||
!query.loading.value &&
|
||||
!query.error.value &&
|
||||
!props.disabled &&
|
||||
!operation.value.pending &&
|
||||
!writing.value
|
||||
)
|
||||
|
||||
/** 二次核对保存记录后提交一次核查;来源变化或网络不确定时不自动重试。 */
|
||||
async function confirm() {
|
||||
if (!ready.value || !query.data.value) return
|
||||
const expected = query.data.value
|
||||
const id = props.projectId
|
||||
const version = revision
|
||||
writing.value = true
|
||||
actionError.value = ''
|
||||
controller = new AbortController()
|
||||
try {
|
||||
await runOperation(
|
||||
id,
|
||||
'系统核查剧本',
|
||||
async () => {
|
||||
const current = await loadDramaReviewResumePreview(id, controller!.signal)
|
||||
if (version !== revision || props.projectId !== id) throw new Error('当前项目已变化,请重新核对。')
|
||||
if (
|
||||
!current.ready ||
|
||||
current.checkpointId !== expected.checkpointId ||
|
||||
current.episodeCount !== expected.episodeCount
|
||||
) {
|
||||
query.data.value = current
|
||||
throw new Error('保存记录已变化,请重新核对本次范围。')
|
||||
}
|
||||
const started = await dramaReviewApi.resumeReview(id, expected.checkpointId)
|
||||
await tracker.track(started.executionId, id)
|
||||
if (version === revision && props.projectId === id) {
|
||||
emit('started', started.executionId, id)
|
||||
open.value = false
|
||||
}
|
||||
return started
|
||||
},
|
||||
{ type: 'info', content: '系统核查已开始,请查看创作任务进度。' }
|
||||
)
|
||||
if (version === revision && props.projectId === id && getOperation(id).error)
|
||||
actionError.value = getOperation(id).error
|
||||
} catch (cause) {
|
||||
if (version === revision && props.projectId === id) actionError.value = errorMessage(cause)
|
||||
} finally {
|
||||
writing.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<span class="inline-flex">
|
||||
<!-- 以下是系统核查入口,打开仅执行只读预检 -->
|
||||
<NButton
|
||||
:type="primary ? 'primary' : 'default'"
|
||||
:disabled="disabled || operation.pending || writing"
|
||||
aria-label="系统重新核查"
|
||||
aria-haspopup="dialog"
|
||||
:aria-expanded="open"
|
||||
@click="open = true"
|
||||
>
|
||||
<template #icon><FileSearch :size="15" aria-hidden="true" /></template>系统重新核查
|
||||
</NButton>
|
||||
<AppDialog
|
||||
v-model:open="open"
|
||||
title="系统重新核查"
|
||||
description="核查已保存的剧本,先由系统处理可确认的问题。"
|
||||
:busy="writing"
|
||||
>
|
||||
<!-- 以下是范围、模型费用与错误反馈模块 -->
|
||||
<div class="grid gap-5">
|
||||
<p v-if="query.loading.value" class="text-sm text-muted">正在核对保存记录…</p>
|
||||
<p v-if="query.data.value" class="text-sm">
|
||||
本次核查已保存的 {{ query.data.value.episodeCount }} 集,不会重写正文、角色设定或世界观。
|
||||
</p>
|
||||
<ContextNotice type="info" title="本次操作会调用模型"
|
||||
>系统会检查完整正文,必要时再复核一次疑点。明确错误会保留为改写依据,无法确认的关键问题仍会保留;请勿重复提交。</ContextNotice
|
||||
>
|
||||
<ContextNotice v-if="query.error.value || actionError" type="error" title="暂不能开始核查">{{
|
||||
actionError || query.error.value
|
||||
}}</ContextNotice>
|
||||
</div>
|
||||
<!-- 以下是固定取消、重新读取与明确开始操作模块 -->
|
||||
<template #footer>
|
||||
<NButton :disabled="writing" @click="open = false">取消</NButton>
|
||||
<WorkspaceRefreshButton
|
||||
label="重新检查"
|
||||
:loading="query.loading.value"
|
||||
:disabled="writing"
|
||||
@refresh="query.refresh"
|
||||
/>
|
||||
<NButton type="primary" :loading="writing" :disabled="!ready" @click="confirm">开始系统核查</NButton>
|
||||
</template>
|
||||
</AppDialog>
|
||||
</span>
|
||||
</template>
|
||||
@@ -3,6 +3,7 @@ import type {
|
||||
ConfirmDramaIssuesInput,
|
||||
ConfirmDramaIssuesResult,
|
||||
DramaReviewPreview,
|
||||
DramaReviewResumePreview,
|
||||
DramaReviewSnapshot,
|
||||
DramaRewritePreview,
|
||||
LatestDramaReview
|
||||
@@ -100,6 +101,28 @@ function validSuggestions(value: unknown): boolean {
|
||||
|
||||
/** 真实剧本审核接口;只读预检和人工确认均不调用模型。 */
|
||||
export const dramaReviewApi = {
|
||||
/**
|
||||
* 读取重新核查已保存剧本的来源,不调用模型。
|
||||
* @param id 正式项目
|
||||
* @param signal 取消过期查询
|
||||
* @returns 可核查的正文版本与集数
|
||||
*/
|
||||
resumePreview: (id: string, signal?: AbortSignal) =>
|
||||
request<DramaReviewResumePreview>(`/projects/${encodeURIComponent(id)}/resume-review/preview`, { signal }),
|
||||
/**
|
||||
* 明确启动当前保存版本的系统核查,不重写正文。
|
||||
* @param id 正式项目
|
||||
* @param expectedCheckpointId 用户核对的来源版本
|
||||
* @returns 持久化任务句柄
|
||||
*/
|
||||
resumeReview: (id: string, expectedCheckpointId: string) =>
|
||||
request<{ executionId: string; projectId: string; status: string }>(
|
||||
`/projects/${encodeURIComponent(id)}/resume-review`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: { confirmed: true, expectedCheckpointId }
|
||||
}
|
||||
),
|
||||
/**
|
||||
* 读取最新正式审核,尚无审核时返回空值。
|
||||
* @param id 正式项目编号
|
||||
@@ -198,3 +221,26 @@ export async function loadDramaReview(id: string, signal?: AbortSignal): Promise
|
||||
return { latest, preview: null, previewError: errorMessage(cause) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 核对系统核查预检的归属与完整字段,不能据本地状态补造就绪结果。
|
||||
* @param id 正式项目
|
||||
* @param signal 取消过期查询
|
||||
* @returns 当前可信核查预检
|
||||
*/
|
||||
export async function loadDramaReviewResumePreview(
|
||||
id: string,
|
||||
signal?: AbortSignal
|
||||
): Promise<DramaReviewResumePreview> {
|
||||
const value = await dramaReviewApi.resumePreview(id, signal)
|
||||
if (
|
||||
value.projectId !== id ||
|
||||
!value.checkpointId ||
|
||||
value.readOnly !== true ||
|
||||
typeof value.ready !== 'boolean' ||
|
||||
!Number.isSafeInteger(value.episodeCount) ||
|
||||
value.episodeCount < 1
|
||||
)
|
||||
throw new Error('系统核查的保存记录不完整,请重新读取。')
|
||||
return value
|
||||
}
|
||||
@@ -35,6 +35,15 @@ export interface ManualReviewDecision {
|
||||
/** 已保存的后续核验标准。 */ verificationCriteria?: string
|
||||
}
|
||||
|
||||
/** 系统核查已保存正文前的只读来源预检。 */
|
||||
export interface DramaReviewResumePreview {
|
||||
/** 正式项目。 */ projectId: string
|
||||
/** 当前完整正文对应的保存记录。 */ checkpointId: string
|
||||
/** 实际保存的剧集数。 */ episodeCount: number
|
||||
/** 后端已确认可核查。 */ ready: boolean
|
||||
/** 预检不调用模型。 */ readOnly: true
|
||||
}
|
||||
|
||||
/** 最新正式审核,不从保存记录的布尔值虚构明细。 */
|
||||
export interface LatestDramaReview {
|
||||
/** 正式审核编号。 */ id: string
|
||||
@@ -48,6 +57,16 @@ export interface LatestDramaReview {
|
||||
} | null
|
||||
/** 原始待人工确认的问题。 */ pendingQualityIssues: DramaReviewIssue[]
|
||||
/** 已保存的人工裁决。 */ manualUncertaintyDecisions: ManualReviewDecision[]
|
||||
/** 系统逐项复核摘要;不等同于人工确认。 */ automaticQualityResolution?: {
|
||||
/** 本次复核候选数。 */ candidateCount: number
|
||||
/** 已有有效依据的项数。 */ resolvedCount: number
|
||||
/** 仍需核对的项数。 */ remainingCount: number
|
||||
/** 系统复核实际状态。 */ status: 'completed' | 'failed'
|
||||
/** 实际判断依据,仅供追溯。 */ decisions: Array<{
|
||||
/** 本轮候选索引。 */ candidateIndex: number
|
||||
/** 判断原因。 */ reason: string
|
||||
}>
|
||||
} | null
|
||||
/** 已有改写目标集数。 */ affectedEpisodes: number[]
|
||||
/** 敏感词审核结果。 */ hitWords: string[]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user