From 407f884e84f98687e75fd90cb9dc08973ebe7e25 Mon Sep 17 00:00:00 2001 From: liuziting Date: Thu, 22 Jan 2026 13:12:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E6=95=B4=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E8=87=AA=E5=8A=A8=E9=80=82=E9=85=8D=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改 VueFlow 初始适配视图为 false,改为手动控制适配 优化根节点添加时的视图适配,增加缩放效果 调整子节点适配逻辑,包含所有子节点并允许更大缩放 --- src/App.vue | 2 +- src/composables/useThinkFlow.ts | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/App.vue b/src/App.vue index a398a5a..48d3dfe 100644 --- a/src/App.vue +++ b/src/App.vue @@ -156,7 +156,7 @@ const fitToView = () => {
targetPosition: Position.Left }) + // 初始添加根节点时进行一次较大的缩放,突出根节点 + setTimeout(() => { + fitView({ nodes: [rootId], padding: 0.4, duration: 600, maxZoom: 1.2 }) + }, 50) + ideaInput.value = '' } else { const node = flowNodes.value.find(n => n.id === parentNode.id) @@ -990,12 +995,13 @@ export function useThinkFlow({ t, locale }: { t: Translate; locale: Ref const childEdges = flowEdges.value.filter(e => e.source === currentParentId) const childIds = childEdges.map(e => e.target) - const nodesToFit = [currentParentId, ...childIds.slice(0, 3)] + const nodesToFit = [currentParentId, ...childIds] fitView({ nodes: nodesToFit, - padding: 0.25, - duration: 1000 + padding: 0.15, // 极小边距,使内容充满屏幕 + duration: 1000, + maxZoom: 1.2 // 允许更大的缩放 }) }, 100) }