perf: 传统族谱视图全面优化
P0 性能优化: - 连线计算用 requestAnimationFrame + useLayoutEffect 替代 7个 setTimeout 轮询 - 节点注册改为批量 ref 模式,消除 N 次 setState 重渲染 - 初始定位用 useLayoutEffect + 双 rAF 替代 600ms setTimeout - 高亮定位用三 rAF 替代 1000ms setTimeout - 使用 ResizeObserver 替代 window.resize 监听 P1 视觉优化: - 连线从 div 改为 SVG path 绘制,清晰且支持动画 - 背景纹理图从 transparenttextures.com 本地化到 public/ - 添加骨架屏 loading 状态替代 return null P2 代码质量: - 移除 page.tsx 中 5 处 console.log - 移除 family-node.tsx 中 3 处 console.log - 消除 handleD3MemberClick 中的直接 DOM 操作(createElement/innerHTML) - parseName 提取为模块级函数,避免每次渲染重建 P3 增强: - 缩放范围从 0.1~2 调整为 0.15~3 - 工具栏显示当前缩放比例 - SVG 连线添加 transition 动画
This commit is contained in:
@@ -193,10 +193,8 @@ function PersonCard({
|
||||
}
|
||||
|
||||
const url = buildAddUrl(type)
|
||||
console.log('handleAddMember called:', type, url)
|
||||
// 使用 setTimeout 延迟跳转,确保菜单关闭后再执行
|
||||
setTimeout(() => {
|
||||
console.log('Navigating to:', url)
|
||||
window.location.href = url
|
||||
}, 100)
|
||||
}
|
||||
@@ -205,7 +203,6 @@ function PersonCard({
|
||||
const handleConfirmAddParent = () => {
|
||||
if (pendingRelationType) {
|
||||
const url = buildAddUrl(pendingRelationType)
|
||||
console.log('Confirmed add parent, navigating to:', url)
|
||||
setTimeout(() => {
|
||||
window.location.href = url
|
||||
}, 100)
|
||||
|
||||
Reference in New Issue
Block a user