feat(short-drama-agent-front): 完善镜头定位与项目配置

This commit is contained in:
GJ committed 2026-10-08 19:45:26 +08:00
1 parent 470b52e26d
commit 5b134207b8
66 files changed
+2042 -984

No files matched your search

+54 -25
View File
@@ -2,14 +2,29 @@
import { NModal, NScrollbar } from 'naive-ui'
import { nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue'
/** Naive UI 管理焦点锁定、Esc、遮罩与主题;长弹窗只滚动内部正文。 */
defineProps<{ title: string; description: string; busy?: boolean; wide?: boolean }>()
/** 公共弹窗的标题、说明、操作状态和宽度。 */
withDefaults(
defineProps<{
/** 弹窗标题,同时作为可访问名称。 */
title: string
/** 标题下的默认说明,可使用 description slot 覆盖。 */
description?: string
/** 提交期间锁定关闭操作。 */
busy?: boolean
/** 使用宽弹窗布局。 */
wide?: boolean
}>(),
{ description: '', busy: false, wide: false }
)
/** 弹窗显隐状态,关闭行为由 Naive 管理。 */
const open = defineModel<boolean>('open', { default: false })
/** 正文测量锚点,不包含固定 header 与 footer。 */
const bodyAnchor = ref<HTMLElement | null>(null)
/** 可用正文滚动高度。 */
const bodyHeight = ref(0)
let layoutObserver: ResizeObserver | undefined
/** 正文使用内容高度与剩余视口高度的较小值;为 NScrollbar 提供明确滚动高度。 */
/** 正文使用内容高度与剩余视口高度的较小值,扣除固定标题、说明与 footer。 */
function updateBodyHeight() {
const card = bodyAnchor.value?.closest('.app-dialog')
const scrollContent = bodyAnchor.value?.parentElement
@@ -20,27 +35,34 @@ function updateBodyHeight() {
const contentStyle = content ? getComputedStyle(content) : null
const available = Math.max(
0,
window.innerHeight - 32 - (header?.offsetHeight ?? 0) - (footer?.offsetHeight ?? 0)
- (contentStyle ? parseFloat(contentStyle.paddingTop) + parseFloat(contentStyle.paddingBottom) : 0)
- 2
window.innerHeight -
32 -
(header?.offsetHeight ?? 0) -
(footer?.offsetHeight ?? 0) -
(contentStyle ? parseFloat(contentStyle.paddingTop) + parseFloat(contentStyle.paddingBottom) : 0) -
2
)
bodyHeight.value = Math.min(scrollContent.scrollHeight, available)
}
watch(open, async shown => {
layoutObserver?.disconnect()
if (!shown) return
await nextTick()
updateBodyHeight()
const card = bodyAnchor.value?.closest('.app-dialog')
const scrollContent = bodyAnchor.value?.parentElement
if (!card || !scrollContent) return
layoutObserver = new ResizeObserver(updateBodyHeight)
const header = card.querySelector('.n-card-header')
const footer = card.querySelector('.n-card__footer')
if (header) layoutObserver.observe(header)
if (footer) layoutObserver.observe(footer)
layoutObserver.observe(scrollContent)
}, { flush: 'post' })
watch(
open,
async shown => {
layoutObserver?.disconnect()
if (!shown) return
await nextTick()
updateBodyHeight()
const card = bodyAnchor.value?.closest('.app-dialog')
const scrollContent = bodyAnchor.value?.parentElement
if (!card || !scrollContent) return
layoutObserver = new ResizeObserver(updateBodyHeight)
const header = card.querySelector('.n-card-header')
const footer = card.querySelector('.n-card__footer')
if (header) layoutObserver.observe(header)
if (footer) layoutObserver.observe(footer)
layoutObserver.observe(scrollContent)
},
{ flush: 'post', immediate: true }
)
onMounted(() => window.addEventListener('resize', updateBodyHeight))
onBeforeUnmount(() => {
layoutObserver?.disconnect()
@@ -53,7 +75,6 @@ onBeforeUnmount(() => {
<NModal
v-model:show="open"
preset="card"
:title="title"
:closable="!busy"
:mask-closable="!busy"
:close-on-esc="!busy"
@@ -62,9 +83,18 @@ onBeforeUnmount(() => {
role="dialog"
:aria-label="title"
>
<!-- 以下是固定标题与说明模块,说明位于标题下并可自定义 -->
<template #header>
<div class="min-w-0">
<div class="text-lg font-semibold">{{ title }}</div>
<div v-if="description || $slots.description" class="mt-[2px] text-sm leading-6 font-normal text-muted">
<slot name="description">{{ description }}</slot>
</div>
</div>
</template>
<!-- 以下是弹窗正文滚动模块 -->
<NScrollbar class="dialog-body-scroll" :style="{ height: bodyHeight + 'px' }">
<span ref="bodyAnchor" class="dialog-body-anchor" aria-hidden="true" />
<p v-if="description" class="text-sm leading-6 text-muted">{{ description }}</p>
<slot />
</NScrollbar>
<template v-if="$slots.footer" #footer>
@@ -86,9 +116,8 @@ onBeforeUnmount(() => {
}
.app-dialog .n-card-header {
@apply shrink-0;
@apply shrink-0 items-start;
}
/* 正文容器可收缩,滚动高度由内容与剩余视口共同确定。 */
.app-dialog .n-card-content {
@apply min-h-0 overflow-hidden;
+45
View File
@@ -0,0 +1,45 @@
<script setup lang="ts">
import { ref } from 'vue'
import { NPopover } from 'naive-ui'
import type { PopoverProps } from 'naive-ui'
import { CircleHelp } from '@lucide/vue'
/** 字段标签与按需打开的说明,适用于项目配置和各类生成表单。 */
withDefaults(
defineProps<{
/** 字段标签,保持实际文案与必填标记。 */
label: string
/** 原有字段说明,没有说明时不显示提示图标。 */
description?: string
/** 提示位置可按字段单独指定,默认居中显示在图标上方。 */
placement?: PopoverProps['placement']
}>(),
{ placement: 'top' }
)
/** 点击或键盘激活提示按钮时打开说明,点击外部后关闭。 */
const open = ref(false)
</script>
<template>
<!-- 以下是字段标签与说明提示模块 -->
<span class="inline-flex min-w-0 items-center gap-1.5">
<span>{{ label }}</span>
<!-- 浮层挂到视口层,按字段指定位置并自动翻转,避免被弹窗滚动容器裁剪。 -->
<NPopover v-if="description" v-model:show="open" trigger="click" :placement="placement" :to="true" :flip="true">
<template #trigger>
<button
type="button"
class="inline-flex size-4 shrink-0 items-center justify-center text-muted hover:text-primary focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-current"
:aria-label="`${label}说明`"
:aria-expanded="open"
@click.stop
>
<CircleHelp :size="14" aria-hidden="true" />
</button>
</template>
<div class="max-w-[min(360px,calc(100vw-48px))] whitespace-pre-wrap break-words text-xs leading-5">
{{ description }}
</div>
</NPopover>
</span>
</template>
-2
View File
@@ -62,5 +62,3 @@ const open = defineModel<boolean>('open', { default: false })
@apply grid-cols-[repeat(auto-fit,_minmax(min(100%,_230px),_1fr))];
}
</style>
+1
View File
@@ -1,4 +1,5 @@
/** 公共 UI 的统一导出入口。 */
export { default as FieldLabel } from './FieldLabel.vue'
export { default as AppDialog } from './AppDialog.vue'
export { default as EmptyState } from './EmptyState.vue'
export { default as StatusBadge } from './StatusBadge.vue'