feat(short-drama-agent-front): 优化项目查询与工作区界面
This commit is contained in:
1 parent
227db5450d
commit
e6d02a20a7
33 files changed
+439
-513
No files matched your search
@@ -1,32 +1,31 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, onScopeDispose, provide, ref, watchEffect } from 'vue'
|
||||
import { computed, inject, onScopeDispose, provide, watchEffect } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { NScrollbar, NAlert, NButton, NPageHeader, NSpin, NEllipsis } from 'naive-ui'
|
||||
import { NScrollbar, NAlert, NButton, NSpin } from 'naive-ui'
|
||||
import { EmptyState } from '../../components/ui'
|
||||
import { buildDocumentTitle } from '../../lib/document-title'
|
||||
import { projectContextKey, useProjectData } from './context'
|
||||
import { getOperation } from '../workflows/operations'
|
||||
import { isProjectComplete, projectAccessKey, type ProjectAccess } from './access'
|
||||
|
||||
/** 项目标题只保留名称;下游工作区在剧本完成前不挂载,直接链接也无法越过限制。 */
|
||||
/** 下游工作区在剧本完成前不挂载,直接链接也无法越过限制。 */
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
/** 当前路由中的项目 ID。 */
|
||||
const id = computed(() => String(route.params.projectId))
|
||||
/** 移动端标题只截断,不弹悬浮提示;跟随视口变化并在卸载时清理监听。 */
|
||||
const mobileMedia = window.matchMedia('(max-width: 760px)')
|
||||
const isMobile = ref(mobileMedia.matches)
|
||||
function syncMobile() {
|
||||
isMobile.value = mobileMedia.matches
|
||||
}
|
||||
mobileMedia.addEventListener('change', syncMobile)
|
||||
onScopeDispose(() => mobileMedia.removeEventListener('change', syncMobile))
|
||||
|
||||
// 图库使用手动刷新,父布局也停止轮询,避免浏览素材时被周期性更新打断。
|
||||
const isGallery = computed(() => route.path.replace(/\/+$/, '').endsWith('/subject-images'))
|
||||
const context = useProjectData(
|
||||
id,
|
||||
computed(() => (isGallery.value ? false : 6000))
|
||||
)
|
||||
/** 项目数据仅在进入、切换项目或显式刷新时读取。 */
|
||||
const context = useProjectData(id)
|
||||
provide(projectContextKey, context)
|
||||
/** 当前项目名称,仅使用与路由项目 ID 匹配的数据,避免切换项目时短暂显示旧标题。 */
|
||||
const projectTitle = computed(() => {
|
||||
const project = context.project.value
|
||||
return project?.id === id.value ? project.title || project.topic : ''
|
||||
})
|
||||
/** 项目数据或子页面变化时同步浏览器标签标题。 */
|
||||
watchEffect(() => {
|
||||
document.title = buildDocumentTitle(route.meta.title, projectTitle.value)
|
||||
})
|
||||
const operation = computed(() => getOperation(id.value))
|
||||
const complete = computed(() => isProjectComplete(context.project.value, id.value))
|
||||
const isCreation = computed(() => route.path.replace(/\/+$/, '').endsWith('/create-drama'))
|
||||
@@ -38,19 +37,11 @@ watchEffect(() => {
|
||||
})
|
||||
onScopeDispose(() => {
|
||||
if (access?.value === published) access.value = null
|
||||
document.title = buildDocumentTitle(route.meta.title)
|
||||
})
|
||||
</script>
|
||||
<template>
|
||||
<section class="project-frame">
|
||||
<header class="project-header">
|
||||
<NPageHeader @back="router.push('/projects')">
|
||||
<template #title
|
||||
><NEllipsis :key="isMobile ? 'mobile' : 'desktop'" class="project-title" :tooltip="!isMobile">{{
|
||||
context.project.value?.title || context.project.value?.topic || '读取项目'
|
||||
}}</NEllipsis></template
|
||||
>
|
||||
</NPageHeader>
|
||||
</header>
|
||||
<NScrollbar
|
||||
v-if="context.error.value || operation.pending || operation.error || operation.notice"
|
||||
class="project-notices"
|
||||
@@ -74,12 +65,10 @@ onScopeDispose(() => {
|
||||
v-else-if="context.project.value?.id === id"
|
||||
class="project-access-gate"
|
||||
title="请先完成剧本创作"
|
||||
:description="`剧本完成后,才能使用拆解、视觉风格、主体身份、形态图片、分镜设计与镜头生产。${isGallery ? '请手动刷新项目状态。' : '状态会自动更新。'}`"
|
||||
description="剧本完成后,才能使用拆解、视觉风格、主体身份、形态图片、分镜设计与镜头生产。请手动刷新项目状态。"
|
||||
>
|
||||
<NButton type="primary" @click="router.push(`/projects/${id}/create-drama`)">返回剧本创作</NButton>
|
||||
<NButton v-if="isGallery" class="ml-3" :loading="context.loading.value" @click="context.refresh"
|
||||
>刷新项目状态</NButton
|
||||
>
|
||||
<NButton class="ml-3" :loading="context.loading.value" @click="context.refresh">刷新项目状态</NButton>
|
||||
</EmptyState>
|
||||
<NSpin
|
||||
v-else-if="context.loading.value"
|
||||
@@ -96,16 +85,6 @@ onScopeDispose(() => {
|
||||
.project-frame {
|
||||
@apply flex flex-col h-full min-h-0 overflow-hidden;
|
||||
}
|
||||
.project-header {
|
||||
@apply shrink-0 py-[9px] px-5 bg-(--app-surface);
|
||||
}
|
||||
.project-header .n-page-header__main,
|
||||
.project-header .n-page-header__title {
|
||||
@apply min-w-0 overflow-hidden;
|
||||
}
|
||||
.project-title {
|
||||
@apply max-w-full text-base font-semibold;
|
||||
}
|
||||
.project-notices.n-scrollbar {
|
||||
@apply shrink-0 h-auto max-h-[100px] overflow-hidden;
|
||||
}
|
||||
@@ -118,21 +97,10 @@ onScopeDispose(() => {
|
||||
.project-view {
|
||||
@apply flex-1 min-h-0 overflow-hidden;
|
||||
}
|
||||
.project-header .n-page-header-wrapper {
|
||||
@apply min-w-0;
|
||||
}
|
||||
.project-access-gate {
|
||||
@apply h-full;
|
||||
}
|
||||
.workspace-loading {
|
||||
@apply grid place-content-center h-full;
|
||||
}
|
||||
@media (max-width: 760px) {
|
||||
.project-header {
|
||||
@apply py-2 px-3;
|
||||
}
|
||||
.project-title {
|
||||
@apply text-sm;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user