auto-save 2026-05-14 01:11 (+4, ~4)

This commit is contained in:
2026-05-14 01:11:53 +08:00
parent 3684917abe
commit 4610ef89f9
8 changed files with 995 additions and 1 deletions

View File

@@ -499,6 +499,9 @@ export default function Home() {
))
}, [pinnedNodes, setNodes])
// 首次挂载、所有节点都被 ReactFlow 测量到后,自动整理一次(用户偏好:每次刷新自动归位)
const initialLayoutDone = useRef(false)
// 自动排版:保留每个节点的当前宽高(用户为方便看而调过的尺寸),只重新计算 position
// 让卡片按管线列分组、列间和列内留出统一间距,不重叠。
const handleResetLayout = useCallback(() => {
@@ -547,6 +550,20 @@ export default function Home() {
toast.success("已自动排版 · 保留每个节点的尺寸")
}, [setNodes])
// 首次:等所有节点都被 ReactFlow 测量到n.measured 出现)后自动排版一次,避免叠在一起
useEffect(() => {
if (initialLayoutDone.current) return
const main = nodes.filter((n) => n.id !== KEYFRAME_PANEL_ID)
if (main.length === 0) return
const allMeasured = main.every((n) => {
const m = (n as any).measured as { width?: number; height?: number } | undefined
return m && typeof m.width === "number" && typeof m.height === "number" && m.height > 0
})
if (!allMeasured) return
initialLayoutDone.current = true
setTimeout(() => handleResetLayout(), 80)
}, [nodes, handleResetLayout])
// 持久化每个节点宽 / 高到 localStorageKeyframePanelNode 自己管尺寸,不写回)
useEffect(() => {
const sizes: Record<string, NodeSize> = {}