perf(short-drama-agent-front): 优化制作工作台交互与移动端布局

This commit is contained in:
GJ committed 2026-10-10 19:28:47 +08:00
1 parent b5eaed3981
commit 54a381ebd3
37 files changed
+1217 -426

No files matched your search

@@ -2,6 +2,7 @@
import AppForm from '../../components/ui/AppForm.vue'
import { NFormItem } from 'naive-ui'
import { integerRule } from '../../lib/form-rules'
import { useDirectorySelection } from '../../composables/useDirectorySelection'
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
import WorkspaceTools from '../../components/ui/WorkspaceTools.vue'
import {
@@ -17,7 +18,7 @@ import {
NTag
} from 'naive-ui'
import { computed, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useRoute, useRouter, type LocationQueryRaw } from 'vue-router'
import { Check, Circle, UserCheck } from '@lucide/vue'
import { AssetImage, DirectoryItem, EmptyState, StatusBadge } from '../../components/ui'
import { downloadText } from '../../lib/format'
@@ -115,6 +116,13 @@ const filtered = computed(() =>
`${item.name} ${item.ref}`.toLowerCase().includes(search.value.trim().toLowerCase())
)
)
/** 主体目录根节点,复用分镜与生产目录的自动定位和平滑滚动。 */
const subjectDirectoryRoot = ref<HTMLElement | null>(null)
useDirectorySelection(
subjectDirectoryRoot,
() => selectedId.value,
() => filtered.value.map(item => item.id)
)
/** 深链接仅在目标 ID 变化时选择,不因目录轮询把用户切回原主体。 */
const linkedSubjectId = computed(
@@ -133,6 +141,17 @@ watch(selectedId, () => {
castingOpen.value = false
pendingSelection.value = ''
})
/** 当前主体写入地址,刷新和返回页面后恢复相同主体,再定位到对应目录项。 */
watch(
selectedId,
id => {
if (!id || !subjects.value.some(item => item.id === id) || route.query.subjectId === id) return
const query: LocationQueryRaw = { ...route.query, subjectId: id }
delete query.subjectRef
void router.replace({ query })
},
{ flush: 'post' }
)
/** 切换主体前确认放弃当前草稿,避免误丢尚未保存的文本。 */
function select(id: string) {
@@ -292,7 +311,7 @@ function runNextAction() {
</script>
<template>
<WorkspacePage split compact class="identity-workspace-page">
<WorkspacePage split compact mobile-scroll class="identity-workspace-page">
<template #notice>
<NAlert v-if="stageComplete" type="success" :show-icon="false">
所有需要确认的角色身份已经准备好,可以继续制作主体形态图片。
@@ -628,34 +647,37 @@ function runNextAction() {
content-class="directory-list-content identity-subject-list-content"
x-scrollable
>
<DirectoryItem
v-for="item in filtered"
:key="item.id"
:aria-pressed="selectedId === item.id"
:active="selectedId === item.id"
@click="select(item.id)"
class="identity-subject-item"
>{{ item.name }}
<template #leading>
<IdentityThumbnail
:project-id="projectId"
:subject-id="item.id"
:name="item.name"
:module="item.module"
:identity-id="item.identity === null ? null : item.identity?.id"
:source="thumbnailSource(item)"
:refresh-key="thumbnailRefreshKey"
/>
</template>
<template #eyebrow>{{ item.ref }}</template>
<template #meta>
<span>{{ item.forms.length }} 个形态</span
><span v-if="castingBySubject.has(item.id)" class="directory-status">
{{ castingStatusLabel(castingBySubject.get(item.id)!.status) }}</span
>
</template></DirectoryItem
>
<p v-if="!filtered.length" class="py-6 text-xs text-muted">没有匹配主体,请调整筛选。</p>
<!-- 以下是主体选中项自动定位模块,不增加目录布局占位 -->
<div ref="subjectDirectoryRoot" class="identity-directory-items">
<DirectoryItem
v-for="item in filtered"
:key="item.id"
:aria-pressed="selectedId === item.id"
:active="selectedId === item.id"
@click="select(item.id)"
class="identity-subject-item"
>{{ item.name }}
<template #leading>
<IdentityThumbnail
:project-id="projectId"
:subject-id="item.id"
:name="item.name"
:module="item.module"
:identity-id="item.identity === null ? null : item.identity?.id"
:source="thumbnailSource(item)"
:refresh-key="thumbnailRefreshKey"
/>
</template>
<template #eyebrow>{{ item.ref }}</template>
<template #meta>
<span>{{ item.forms.length }} 个形态</span
><span v-if="castingBySubject.has(item.id)" class="directory-status">
{{ castingStatusLabel(castingBySubject.get(item.id)!.status) }}</span
>
</template></DirectoryItem
>
<p v-if="!filtered.length" class="py-6 text-xs text-muted">没有匹配主体,请调整筛选。</p>
</div>
</NScrollbar>
</aside>
<NScrollbar class="identity-detail panel-scroll min-w-0">
@@ -869,6 +891,10 @@ function runNextAction() {
.identity-workspace {
@apply grid grid-cols-[240px_minmax(0,_1fr)] items-start gap-3;
}
/* 主体目录根节点只用于定位,保留桌面纵向和手机横向的自然布局。 */
.identity-directory-items {
display: contents;
}
.identity-subject-list {
@apply max-h-[560px] overflow-hidden;
}
@@ -1025,6 +1051,19 @@ function runNextAction() {
@apply shrink-0;
}
@media (max-width: 760px) {
/* 主体详情自然撑高,提示与主体导航随正文滚走;顶部两行保留固定。 */
.identity-workspace-page .identity-workspace {
height: auto;
flex: none;
overflow: visible;
grid-template-rows: auto auto;
}
.identity-workspace-page .identity-workspace > .identity-detail,
.identity-workspace-page .identity-detail > .n-scrollbar-container {
height: auto;
max-height: none;
overflow: visible;
}
.identity-next-action {
@apply items-start flex-col;
}