feat(short-drama-agent-front): 完善主体身份骨架屏与交互反馈
This commit is contained in:
1 parent
5fa1c251a9
commit
dd0bd79a35
19 files changed
+1552
-419
No files matched your search
@@ -2,6 +2,7 @@
|
||||
import { computed, h, inject, onScopeDispose, provide, ref, watch, watchEffect } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { NScrollbar, NAlert, NButton, NPageHeader, NSpin, NEllipsis } from 'naive-ui'
|
||||
import type { MessageReactive } from 'naive-ui'
|
||||
import { EmptyState } from '../../components/ui'
|
||||
import { projectContextKey, useProjectData } from './context'
|
||||
import { getOperation } from '../workflows/operations'
|
||||
@@ -17,6 +18,7 @@ import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
|
||||
import CreateDramaSkeleton from '../create-drama/CreateDramaSkeleton.vue'
|
||||
import BreakdownSkeleton from '../breakdown/BreakdownSkeleton.vue'
|
||||
import VisualStyleSkeleton from '../visual-style/VisualStyleSkeleton.vue'
|
||||
import SubjectIdentitySkeleton from '../subject-identity/SubjectIdentitySkeleton.vue'
|
||||
|
||||
/** 项目标题只保留名称;下游工作区在剧本完成前不挂载,直接链接也无法越过限制。 */
|
||||
const route = useRoute()
|
||||
@@ -147,18 +149,40 @@ const operationGuide = computed<OperationGuide | null>(() => {
|
||||
return { title: '操作未完成', description: error }
|
||||
})
|
||||
|
||||
/** 镜头工作区的操作结果只在用户发起操作后显示,不在进入页面时重放旧提示。 */
|
||||
/** 操作结果只在当前项目收到新响应后通知,不在进入工作区时重放旧提示。 */
|
||||
const actionMessage = useActionMessage()
|
||||
/** 分镜和生产页保留必要进度,操作成功或失败改用临时消息。 */
|
||||
const quietFeedback = computed(() => currentSection.value === 'production' || currentSection.value === 'storyboard')
|
||||
/** 分镜、生产和主体身份的操作结果使用临时消息。 */
|
||||
const quietFeedback = computed(() =>
|
||||
['production', 'storyboard', 'subject-identity'].includes(currentSection.value ?? '')
|
||||
)
|
||||
/** 主体身份请求进度使用消息,其余工作区继续展示已有任务进度。 */
|
||||
const inlinePendingFeedback = computed(() => operation.value.pending && currentSection.value !== 'subject-identity')
|
||||
/** 当前身份请求的加载消息,完成或离开工作区后立即销毁。 */
|
||||
let pendingMessage: MessageReactive | null = null
|
||||
/** 请求开始即反馈,切换主体时保留请求目标名称,避免无反馈的禁用按钮。 */
|
||||
watch(
|
||||
() => [id.value, currentSection.value, operation.value.pending, operation.value.label] as const,
|
||||
([, section, pending, label]) => {
|
||||
pendingMessage?.destroy()
|
||||
pendingMessage = null
|
||||
if (section === 'subject-identity' && pending)
|
||||
pendingMessage = actionMessage?.loading(`${label || '主体身份操作'},请稍候…`, { duration: 0 }) ?? null
|
||||
}
|
||||
)
|
||||
/** 关闭页面时清理未完成请求的加载消息。 */
|
||||
onScopeDispose(() => pendingMessage?.destroy())
|
||||
/** 只通知仍在当前项目的真实新结果,不把任务提交当作素材生成完成。 */
|
||||
watch(
|
||||
() => [id.value, operation.value.error, operation.value.notice] as const,
|
||||
([projectId, error, notice], [previousProject, previousError, previousNotice]) => {
|
||||
if (!quietFeedback.value || projectId !== previousProject) return
|
||||
if (projectId !== previousProject) return
|
||||
if (error && error !== previousError) {
|
||||
if (!quietFeedback.value) return
|
||||
const guide = operationGuide.value
|
||||
const content = productionMessage(error)
|
||||
const content =
|
||||
currentSection.value === 'subject-identity'
|
||||
? `${operation.value.label || '主体身份操作'}失败:${productionMessage(error)}`
|
||||
: productionMessage(error)
|
||||
actionMessage?.error(
|
||||
() =>
|
||||
h('div', { class: 'flex max-w-[min(600px,calc(100vw-48px))] flex-wrap items-center gap-3' }, [
|
||||
@@ -181,9 +205,24 @@ watch(
|
||||
{ duration: 8000, closable: true }
|
||||
)
|
||||
} else if (notice && notice !== previousNotice) {
|
||||
if (/生成|提交/.test(operation.value.label))
|
||||
if (!quietFeedback.value) return
|
||||
if (operation.value.noticeType)
|
||||
actionMessage?.[operation.value.noticeType](notice, {
|
||||
duration: operation.value.noticeType === 'warning' ? 8000 : 4000,
|
||||
closable: true
|
||||
})
|
||||
else if (operation.value.label === 'AI 生成主体身份')
|
||||
actionMessage?.success('身份文本已生成并保存。', { duration: 3000, closable: true })
|
||||
else if (operation.value.label === '保存主体身份')
|
||||
actionMessage?.success('主体身份已保存。', { duration: 3000, closable: true })
|
||||
else if (/生成|提交/.test(operation.value.label))
|
||||
actionMessage?.info('任务已提交,完成后会显示结果。', { duration: 4000 })
|
||||
else actionMessage?.success('操作已完成。', { duration: 3000 })
|
||||
// 身份页已消费的反馈立即清除,切换主体或其它工作区都不会遗留旧横幅。
|
||||
if (currentSection.value === 'subject-identity') {
|
||||
operation.value.notice = ''
|
||||
operation.value.noticeType = null
|
||||
}
|
||||
}
|
||||
},
|
||||
{ flush: 'post' }
|
||||
@@ -240,7 +279,12 @@ onScopeDispose(() => {
|
||||
</NPageHeader>
|
||||
</header>
|
||||
<NScrollbar
|
||||
v-if="context.error.value || operation.pending || (!quietFeedback && (operation.error || operation.notice))"
|
||||
v-if="
|
||||
context.error.value ||
|
||||
inlinePendingFeedback ||
|
||||
(!quietFeedback && operation.error) ||
|
||||
(!quietFeedback && operation.notice)
|
||||
"
|
||||
class="project-notices"
|
||||
content-class="project-notices-content"
|
||||
>
|
||||
@@ -250,7 +294,7 @@ onScopeDispose(() => {
|
||||
>重试读取</NButton
|
||||
></NAlert
|
||||
>
|
||||
<NAlert v-if="operation.pending" :show-icon="false" role="status"
|
||||
<NAlert v-if="inlinePendingFeedback" :show-icon="false" role="status"
|
||||
>{{ operation.label || '后台制作任务执行中' }}。可切换页面查看结果,请勿重复提交。</NAlert
|
||||
>
|
||||
<NAlert v-if="operationGuide && !quietFeedback" type="error" :show-icon="false" class="operation-guide">
|
||||
@@ -311,6 +355,8 @@ onScopeDispose(() => {
|
||||
<BreakdownSkeleton v-else-if="isProjectInitialLoading && currentSection === 'breakdown'" />
|
||||
<!-- 以下是视觉风格项目首次读取的骨架屏模块 -->
|
||||
<VisualStyleSkeleton v-else-if="isProjectInitialLoading && currentSection === 'visual-style'" />
|
||||
<!-- 以下是主体身份项目首次读取的骨架屏模块 -->
|
||||
<SubjectIdentitySkeleton v-else-if="isProjectInitialLoading && currentSection === 'subject-identity'" />
|
||||
<NSpin v-else-if="context.loading.value" class="workspace-loading" description="正在读取项目内容…" />
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in new issue
Block a user