feat(short-drama-agent-front): 优化分镜界面并新增弹窗手势

This commit is contained in:
GJ committed 2026-11-18 18:50:15 +08:00
1 parent b15a6011ce
commit d68f03471c
59 files changed
+2694 -857

No files matched your search

+89 -7
View File
@@ -2,6 +2,10 @@
import { NButton, NModal, NScrollbar, useThemeVars } from 'naive-ui'
import { CircleAlert, CircleCheck, CircleX } from '@lucide/vue'
import { onBeforeUnmount, onMounted, ref, watch } from 'vue'
import FieldLabel from './FieldLabel.vue'
import MobilePanelHandle from './MobilePanelHandle.vue'
import { useMobileViewport } from '../../composables/useMobileViewport'
import { usePanelScrollState } from '../../composables/usePanelScrollState'
/** 公共弹窗的标题、说明、操作状态和宽度。 */
withDefaults(
@@ -10,6 +14,8 @@ withDefaults(
title: string
/** 可选的简短标题补充,尽量一句话;完整说明与操作影响应放入默认正文插槽。 */
description?: string
/** 操作流程说明放入信息图标,业务状态说明插槽仍直接显示。 */
descriptionAsInfo?: boolean
/** 展示语义状态;默认保持中性,警告、成功和错误仅在标题旁显示对应图标。 */
status?: 'default' | 'warning' | 'success' | 'error'
/** 提交期间锁定关闭操作。 */
@@ -27,6 +33,10 @@ const themeVars = useThemeVars()
const emit = defineEmits<{ closed: [] }>()
/** 弹窗显隐状态,关闭行为由 Naive 管理。 */
const open = defineModel<boolean>('open', { default: false })
/** 手机端使用底部面板,桌面继续采用原居中弹窗。 */
const mobile = useMobileViewport()
/** 正文离开顶部时才显示标题区阴影,底栏始终保持平面。 */
const { bodyScrolled, onBodyScroll } = usePanelScrollState(open)
/** 正文容器隔离子元素外边距,保留完整的自然内容高度。 */
const bodyContent = ref<HTMLElement | null>(null)
/** 正文最大可用高度;未挂载时不限制自然高度。 */
@@ -46,7 +56,7 @@ function updateBodyHeight() {
maxBodyHeight.value = Math.max(
0,
(window.visualViewport?.height ?? window.innerHeight) -
32 -
(mobile.value ? 12 : 32) -
(header?.offsetHeight ?? 0) -
(footer?.offsetHeight ?? 0) -
(contentStyle ? parseFloat(contentStyle.paddingTop) + parseFloat(contentStyle.paddingBottom) : 0) -
@@ -95,17 +105,22 @@ onBeforeUnmount(() => {
:closable="!busy"
:mask-closable="!busy"
:close-on-esc="!busy"
:style="{ width: `${width ?? (wide ? 1040 : 600)}px` }"
:style="{ width: mobile ? '100vw' : `${width ?? (wide ? 1040 : 600)}px` }"
class="app-dialog"
:class="{ 'app-dialog-title-only': !description && !$slots.description }"
:class="{
'app-dialog-title-only': !description && !$slots.description,
'app-mobile-panel': mobile,
'has-body-scroll': bodyScrolled
}"
role="dialog"
:aria-label="title"
@after-leave="emit('closed')"
>
<!-- 以下是固定标题与说明模块,无说明时标题与关闭按钮垂直居中对齐 -->
<template #header>
<div class="min-w-0">
<div class="flex items-center gap-2 text-lg font-semibold">
<div class="min-w-0 w-full">
<MobilePanelHandle v-if="mobile" :active="open" :disabled="busy" @dismiss="open = false" />
<div class="flex min-w-0 items-center gap-2 text-lg font-semibold">
<!-- 以下是可被读屏识别的状态提示,颜色之外保留不同图形 -->
<CircleAlert
v-if="status === 'warning'"
@@ -131,9 +146,20 @@ onBeforeUnmount(() => {
aria-label="错误"
:style="{ color: themeVars.errorColor }"
/>
<span class="min-w-0 wrap-anywhere">{{ title }}</span>
<span class="app-panel-title" :title="title">{{ title }}</span>
<FieldLabel
class="shrink-0"
v-if="descriptionAsInfo && description && !$slots.description"
label="操作"
:description="description"
icon-only
icon="info"
/>
</div>
<div v-if="description || $slots.description" class="mt-[2px] text-sm leading-6 font-normal text-muted">
<div
v-if="$slots.description || (description && !descriptionAsInfo)"
class="mt-[2px] text-sm leading-6 font-normal text-muted"
>
<slot name="description">{{ description }}</slot>
</div>
</div>
@@ -141,6 +167,7 @@ onBeforeUnmount(() => {
<!-- 以下是自然高度正文模块,仅超过剩余视口高度时滚动 -->
<NScrollbar
class="dialog-body-scroll"
@scroll="onBodyScroll"
:style="{ height: 'auto', maxHeight: maxBodyHeight === undefined ? undefined : maxBodyHeight + 'px' }"
>
<div ref="bodyContent" class="flow-root"><slot /></div>
@@ -168,6 +195,16 @@ onBeforeUnmount(() => {
.app-dialog .n-card-header {
@apply shrink-0 items-start;
position: relative;
z-index: 1;
border-bottom: 0;
box-shadow: none;
}
.app-dialog .n-card-header__main {
min-width: 0;
}
.app-dialog.has-body-scroll .n-card-header {
box-shadow: 0 4px 12px -8px color-mix(in srgb, var(--app-shadow) 60%, transparent);
}
/* 无描述的标题栏采用同一条中心线,标题下方保持紧凑的正文间距。 */
.app-dialog.app-dialog-title-only .n-card-header {
@@ -189,6 +226,10 @@ onBeforeUnmount(() => {
display: flex;
align-items: center;
justify-content: flex-end;
position: relative;
z-index: 1;
border-top: 0;
box-shadow: none;
}
.app-dialog .dialog-footer {
@@ -212,4 +253,45 @@ onBeforeUnmount(() => {
padding-top: var(--n-padding-left);
padding-bottom: var(--n-padding-left);
}
/* 手机居中弹窗统一贴底,短内容保持自然高度,长内容只滚动正文。 */
@media (max-width: 639px) {
.app-dialog.app-mobile-panel.n-card {
position: fixed;
inset: auto 0 0;
margin: 0;
max-width: 100vw;
max-height: calc(100dvh - max(12px, env(safe-area-inset-top)));
border-radius: 0;
}
.app-dialog.app-mobile-panel.n-card > .n-card-header {
padding: 44px 16px 16px;
}
.app-dialog.app-mobile-panel .n-card-header__close {
align-self: flex-start;
}
.app-dialog.app-mobile-panel.n-card > .n-card-content {
padding-inline: 16px;
}
.app-dialog.app-mobile-panel.n-card > .n-card__footer {
padding: 16px 16px max(16px, env(safe-area-inset-bottom));
}
.app-dialog.app-mobile-panel:is(.fade-in-scale-up-transition-enter-from, .fade-in-scale-up-transition-leave-to) {
transform: translate3d(0, 100%, 0);
opacity: 1;
}
.app-dialog.app-mobile-panel:is(
.fade-in-scale-up-transition-enter-active,
.fade-in-scale-up-transition-leave-active
) {
transition: transform 220ms cubic-bezier(0.32, 0.72, 0, 1);
}
}
@media (prefers-reduced-motion: reduce) {
.app-dialog.app-mobile-panel:is(
.fade-in-scale-up-transition-enter-active,
.fade-in-scale-up-transition-leave-active
) {
transition-duration: 0.01ms;
}
}
</style>