0.0.5.1
This commit is contained in:
@@ -139,10 +139,10 @@ export function TreeLayout({
|
||||
|
||||
const hasChildren = member.childrenIds && member.childrenIds.length > 0
|
||||
|
||||
// 获取配偶(取第一个配偶)
|
||||
const spouse = member.spouseIds && member.spouseIds.length > 0
|
||||
? getMember(member.spouseIds[0])
|
||||
: undefined
|
||||
// 获取所有配偶
|
||||
const spouses = member.spouseIds && member.spouseIds.length > 0
|
||||
? member.spouseIds.map(id => getMember(id)).filter(Boolean) as FamilyMember[]
|
||||
: []
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center">
|
||||
@@ -159,7 +159,7 @@ export function TreeLayout({
|
||||
>
|
||||
<FamilyNode
|
||||
member={member}
|
||||
spouse={spouse}
|
||||
spouses={spouses}
|
||||
onSelect={handleNodeClick}
|
||||
isRoot={isRoot}
|
||||
isHighlighted={member.id === highlightedMemberId}
|
||||
@@ -177,9 +177,27 @@ export function TreeLayout({
|
||||
gap: `${HORIZONTAL_GAP}px`
|
||||
}}
|
||||
>
|
||||
{member.childrenIds.map((childId) => (
|
||||
<TreeNode key={childId} memberId={childId} />
|
||||
))}
|
||||
{(() => {
|
||||
// 对子节点进行排序:始祖排最左边,其他按出生日期排序
|
||||
const sortedChildren = [...member.childrenIds].sort((aId, bId) => {
|
||||
const a = getMember(aId)
|
||||
const b = getMember(bId)
|
||||
if (!a || !b) return 0
|
||||
|
||||
// 始祖永远排最左边
|
||||
const aIsFounder = a.tags?.includes('始祖') || a.generation === 1
|
||||
const bIsFounder = b.tags?.includes('始祖') || b.generation === 1
|
||||
if (aIsFounder && !bIsFounder) return -1
|
||||
if (!aIsFounder && bIsFounder) return 1
|
||||
|
||||
// 其他按出生日期排序
|
||||
return (a.birthDate || "").localeCompare(b.birthDate || "")
|
||||
})
|
||||
|
||||
return sortedChildren.map((childId) => (
|
||||
<TreeNode key={childId} memberId={childId} />
|
||||
))
|
||||
})()}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
@@ -205,13 +223,13 @@ export function TreeLayout({
|
||||
return (
|
||||
<div
|
||||
key={index}
|
||||
className="absolute bg-foreground/25"
|
||||
className="absolute bg-black"
|
||||
style={{
|
||||
left: `${left}px`,
|
||||
top: `${top}px`,
|
||||
width: `${width}px`,
|
||||
height: `${height}px`,
|
||||
transform: isHorizontal ? 'scaleY(0.3)' : 'scaleX(0.3)',
|
||||
transform: isHorizontal ? 'scaleY(0.5)' : 'scaleX(0.5)',
|
||||
transformOrigin: 'top left',
|
||||
}}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user