feat(short-drama-agent-front): 新增视觉风格骨架屏并优化参考图添加
This commit is contained in:
1 parent
3cc65aa056
commit
519b956808
11 files changed
+621
-242
No files matched your search
@@ -1,6 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
|
||||
import DetailDisclosure from '../../components/ui/DetailDisclosure.vue'
|
||||
import { NAlert, NButton } from 'naive-ui'
|
||||
import { LoaderCircle, LockKeyhole, LockKeyholeOpen, Palette, TriangleAlert } from '@lucide/vue'
|
||||
import { computed, ref } from 'vue'
|
||||
@@ -13,9 +12,11 @@ import { visualStyleApi } from './api'
|
||||
import type { AddStyleImageInput, SaveVisualStyleInput, VisualStyle, VisualStyleImage } from './types'
|
||||
import StyleEditor from './components/StyleEditor.vue'
|
||||
import StyleImages from './components/StyleImages.vue'
|
||||
import VisualStyleSkeleton from './VisualStyleSkeleton.vue'
|
||||
|
||||
/** 项目视觉风格工作区:文本编辑、锁定和风格图记录分开管理。 */
|
||||
const { projectId, blocked } = useProjectMutationGuard()
|
||||
const { projectId, operation, blocked } = useProjectMutationGuard()
|
||||
/** 项目阶段就绪状态沿用父布局的真实响应。 */
|
||||
const projectContext = useProjectContext()
|
||||
/** 风格页仅在进入、切换项目或显式刷新时读取。 */
|
||||
const query = useQuery(projectId, async (id, signal) => {
|
||||
@@ -23,11 +24,23 @@ const query = useQuery(projectId, async (id, signal) => {
|
||||
assertProject(style, id)
|
||||
return { style }
|
||||
})
|
||||
/** 已读取的视觉风格,接口返回空值时允许首次人工创建。 */
|
||||
const style = computed(() => query.data.value?.style ?? null)
|
||||
/** 仅首读与项目切换显示骨架,刷新已有风格时保留编辑草稿。 */
|
||||
const initialLoading = computed(() => query.loading.value && !query.data.value)
|
||||
/** 查询失败或项目活动锁生效时禁止写入。 */
|
||||
const disabled = computed(() => blocked.value || !!query.error.value || !query.data.value)
|
||||
/** 保存成功后重建编辑器,确保草稿对应已确认的响应。 */
|
||||
const editorRevision = ref(0)
|
||||
/** 添加图片成功后重建组件,关闭弹窗并清空草稿。 */
|
||||
const imageRevision = ref(0)
|
||||
/** 仅添加参考图期间锁定添加弹窗,查询失败仍可关闭。 */
|
||||
const addingImage = computed(() => operation.value.pending && operation.value.label === '添加风格参考图')
|
||||
/** 添加失败的真实接口反馈同时显示在弹窗中,保留来源与设置。 */
|
||||
const imageAddError = computed(() => (operation.value.label === '添加风格参考图' ? operation.value.error : ''))
|
||||
/** 未保存的风格修改用于阻止 AI 覆盖。 */
|
||||
const dirty = ref(false)
|
||||
/** 后端确认视觉风格准备好后提供下一步入口。 */
|
||||
const nextReady = computed(() => projectContext.stageReadiness.value?.visualStyle.ready === true)
|
||||
|
||||
/** 状态是只读说明,与操作按钮分组;读取失败不能被误报成尚未创建。 */
|
||||
@@ -91,9 +104,12 @@ async function writeImage(label: string, action: (id: string) => Promise<VisualS
|
||||
await query.refresh()
|
||||
}
|
||||
|
||||
/** 登记已存在的图片地址,不上传文件或调用模型。 */
|
||||
/**
|
||||
* 添加已有项目素材或图片链接,成功后关闭添加弹窗并刷新列表。
|
||||
* @param input 图片来源、应用范围、顺序及参与生成设置
|
||||
*/
|
||||
function addImage(input: AddStyleImageInput) {
|
||||
void writeImage('登记风格参考图', id => visualStyleApi.addImage(id, input), true)
|
||||
void writeImage('添加风格参考图', id => visualStyleApi.addImage(id, input), true)
|
||||
}
|
||||
|
||||
/** 风格图启停不受文字锁定影响。 */
|
||||
@@ -108,8 +124,10 @@ function removeImage(image: VisualStyleImage) {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- 以下是视觉风格首次读取的完整骨架屏模块 -->
|
||||
<VisualStyleSkeleton v-if="initialLoading" />
|
||||
<!-- 以下是手机提示、风格工具与正文共同滚动的视觉风格工作区 -->
|
||||
<WorkspacePage compact mobile-scroll class="visual-style-page"
|
||||
<WorkspacePage v-else compact mobile-scroll class="visual-style-page"
|
||||
><template #header>
|
||||
<!-- 以下是标题、锁定状态与生成操作 -->
|
||||
<div class="workspace-toolbar visual-style-toolbar">
|
||||
@@ -131,7 +149,7 @@ function removeImage(image: VisualStyleImage) {
|
||||
</div>
|
||||
</template>
|
||||
<template #notice>
|
||||
<NAlert v-if="nextReady" type="success" :show-icon="false">
|
||||
<NAlert v-if="nextReady && style" type="success" :show-icon="false">
|
||||
视觉风格已准备好,可以继续确认人物、场景和道具的主体身份。
|
||||
<RouterLink :to="`/projects/${projectId}/subject-identity`" class="text-button ml-2"
|
||||
>继续主体身份 →</RouterLink
|
||||
@@ -146,10 +164,16 @@ function removeImage(image: VisualStyleImage) {
|
||||
<p v-if="dirty" class="mb-4 text-xs text-muted">
|
||||
有未保存修改,AI 重生成暂不可用。刷新不会覆盖编辑内容;离开页面不会自动保存。
|
||||
</p>
|
||||
<DetailDisclosure title="风格生成规则">
|
||||
AI
|
||||
生成时,若项目和世界观没有明确其它人物背景,人物风格默认采用中国人物选角基线;人工填写的人物背景和角色事实优先。修改风格只影响之后的生成,旧资产不会自动更新。 </DetailDisclosure
|
||||
><StyleEditor
|
||||
<!-- 以下是始终显示的风格生成规则模块 -->
|
||||
<section v-if="query.data.value" class="panel workspace-panel visual-style-rules">
|
||||
<h3 class="font-medium">风格生成规则</h3>
|
||||
<p class="mt-3 text-xs leading-6 text-muted">
|
||||
AI
|
||||
生成时,若项目和世界观没有明确其它人物背景,人物风格默认采用中国人物选角基线;人工填写的人物背景和角色事实优先。修改风格只影响之后的生成,旧资产不会自动更新。
|
||||
</p>
|
||||
</section>
|
||||
<!-- 以下是风格编辑与始终展开的分类补充模块 -->
|
||||
<StyleEditor
|
||||
v-if="query.data.value"
|
||||
:key="editorRevision"
|
||||
:visual-style="style"
|
||||
@@ -157,11 +181,15 @@ function removeImage(image: VisualStyleImage) {
|
||||
@save="save"
|
||||
@dirty="dirty = $event"
|
||||
/>
|
||||
<p v-else-if="query.loading.value" class="py-8 text-sm text-muted" role="status">正在读取视觉风格…</p>
|
||||
<!-- 以下是读取成功后的参考图列表与添加入口模块 -->
|
||||
<StyleImages
|
||||
v-if="query.data.value"
|
||||
:key="imageRevision"
|
||||
:project-id="projectId"
|
||||
:images="style?.images ?? []"
|
||||
:has-style="!!style"
|
||||
:adding="addingImage"
|
||||
:add-error="imageAddError"
|
||||
:disabled="disabled || !style"
|
||||
@add="addImage"
|
||||
@toggle="toggleImage"
|
||||
|
||||
Reference in new issue
Block a user