From d854083c7003875be2f2e083e0e24fed12277bde Mon Sep 17 00:00:00 2001 From: wizardchen Date: Mon, 2 Feb 2026 00:47:17 +0800 Subject: [PATCH] feat(organization): enhance invite preview with height transition - Added a shared height transition container for the invite preview body to improve user experience during step transitions. - Implemented a resize observer to dynamically adjust the height of the invite body based on content changes, ensuring smooth transitions. - Updated the template structure for invite preview steps to enhance readability and maintainability. - Enhanced styles for the invite preview body to support the new height transition feature. This update improves the visual experience when navigating through the invite process, making it more fluid and user-friendly. --- .../views/organization/OrganizationList.vue | 144 +++++++++++++++--- 1 file changed, 119 insertions(+), 25 deletions(-) diff --git a/frontend/src/views/organization/OrganizationList.vue b/frontend/src/views/organization/OrganizationList.vue index 1b8df154..e514cd52 100644 --- a/frontend/src/views/organization/OrganizationList.vue +++ b/frontend/src/views/organization/OrganizationList.vue @@ -235,6 +235,9 @@ + +
+
@@ -409,8 +412,7 @@
- +
@@ -591,6 +594,82 @@ const CACHE_DURATION = 5 * 60 * 1000 // 缓存5分钟 // Tab 内容容器 ref,用于高度过渡 const tabContentWrapperRef = ref(null) +// 加入弹框整体 body 高度过渡(输入邀请码 / 搜索空间 / 查看详情) +const inviteBodyInnerRef = ref(null) +const inviteBodyHeightPx = ref(0) +let inviteBodyResizeObserver: ResizeObserver | null = null + +const inviteBodyWrapStyle = computed(() => { + const px = inviteBodyHeightPx.value + if (px <= 0) return {} + return { maxHeight: `${px}px`, minHeight: `${px}px` } +}) + +// 根据当前 body 内容更新高度(用于过渡动画) +function updateInviteBodyHeight() { + const el = inviteBodyInnerRef.value + if (!el || !showInvitePreview.value) return + const h = el.scrollHeight + // 避免把高度写成 0 导致闪缩,仅在得到有效高度时更新 + if (h > 0) inviteBodyHeightPx.value = h +} + +// 观察加入弹框 body 内容高度,用于步骤切换时的高度过渡动画 +function setupInviteBodyResizeObserver() { + if (inviteBodyResizeObserver) return + const el = inviteBodyInnerRef.value + if (!el || !showInvitePreview.value) return + inviteBodyResizeObserver = new ResizeObserver((entries) => { + const entry = entries[0] + if (!entry) return + const h = entry.contentRect.height + // 避免切换瞬间读到 0 导致闪缩 + if (h > 0 || inviteBodyHeightPx.value <= 0) inviteBodyHeightPx.value = h + }) + inviteBodyResizeObserver.observe(el) + inviteBodyHeightPx.value = el.scrollHeight +} + +function teardownInviteBodyResizeObserver() { + if (inviteBodyResizeObserver) { + inviteBodyResizeObserver.disconnect() + inviteBodyResizeObserver = null + } + inviteBodyHeightPx.value = 0 +} + +watch( + [showInvitePreview, inviteBodyInnerRef], + ([show, inner]) => { + if (!show) { + teardownInviteBodyResizeObserver() + return + } + if (inner) { + nextTick(() => { + setupInviteBodyResizeObserver() + }) + } + }, + { flush: 'post' } +) + +// 步骤切换时在布局完成后读取新内容高度,保证高度过渡动画可见 +watch( + [() => invitePreviewLoading.value, () => invitePreviewData.value], + () => { + if (!showInvitePreview.value || !inviteBodyInnerRef.value) return + nextTick(() => { + requestAnimationFrame(() => { + requestAnimationFrame(() => { + updateInviteBodyHeight() + }) + }) + }) + }, + { flush: 'post' } +) + // 更新容器高度的辅助函数 const updateTabContentHeight = () => { if (!tabContentWrapperRef.value) return @@ -1059,6 +1138,7 @@ onMounted(async () => { onUnmounted(() => { window.removeEventListener('openOrganizationDialog', handleOrganizationDialogEvent) + teardownInviteBodyResizeObserver() }) @@ -1847,6 +1927,20 @@ onUnmounted(() => { } } +// 加入弹框 body 外层:高度过渡动画(输入邀请码 ↔ 搜索空间 ↔ 查看详情) +.invite-preview-body-wrap { + flex: 0 0 auto; + overflow: hidden; + height: auto; + transition: + min-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), + max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1); +} + +.invite-body-inner { + display: block; +} + .invite-preview-body { flex: 1; overflow-y: auto;